]> git.pld-linux.org Git - packages/kernel.git/blob - patch-2.6.0-test4-bk4
- obsolete
[packages/kernel.git] / patch-2.6.0-test4-bk4
1 diff -Nru a/CREDITS b/CREDITS
2 --- a/CREDITS   Wed Aug 20 04:45:18 2003
3 +++ b/CREDITS   Sun Aug 31 16:14:38 2003
4 @@ -1279,14 +1279,13 @@
5  
6  N: Christoph Hellwig
7  E: hch@infradead.org
8 -E: hch@sgi.com
9  D: all kinds of driver, filesystem & core kernel hacking
10  D: freevxfs driver
11  D: sysvfs maintainer
12  D: chief codingstyle nitpicker
13 -S: Auweg 38
14 -S: 85748 Garching
15 -S: Germany
16 +S: Ampferstr. 50 / 4
17 +S: 6020 Innsbruck
18 +S: Austria
19  
20  N: Richard Henderson
21  E: rth@twiddle.net
22 diff -Nru a/Documentation/DocBook/kernel-locking.tmpl b/Documentation/DocBook/kernel-locking.tmpl
23 --- a/Documentation/DocBook/kernel-locking.tmpl Thu Dec  5 18:56:55 2002
24 +++ b/Documentation/DocBook/kernel-locking.tmpl Sun Aug 31 16:14:01 2003
25 @@ -463,7 +463,7 @@
26        <function>spin_lock_irqsave()</function> 
27        (<filename>include/linux/spinlock.h</filename>) is a variant
28        which saves whether interrupts were on or off in a flags word,
29 -      which is passed to <function>spin_lock_irqrestore()</function>.  This 
30 +      which is passed to <function>spin_unlock_irqrestore()</function>.  This
31        means that the same code can be used inside an hard irq handler (where
32        interrupts are already off) and in softirqs (where the irq
33        disabling is required).
34 diff -Nru a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
35 --- a/Documentation/filesystems/proc.txt        Sun Jun  1 14:12:47 2003
36 +++ b/Documentation/filesystems/proc.txt        Sun Aug 31 16:15:48 2003
37 @@ -25,6 +25,7 @@
38    1.5  SCSI info
39    1.6  Parallel port info in /proc/parport
40    1.7  TTY info in /proc/tty
41 +  1.8  Miscellaneous kernel statistics in /proc/stat
42  
43    2    Modifying System Parameters
44    2.1  /proc/sys/fs - File system data
45 @@ -702,6 +703,58 @@
46    /dev/console         /dev/console    5       1 system:console 
47    /dev/tty             /dev/tty        5       0 system:/dev/tty 
48    unknown              /dev/tty        4    1-63 console 
49 +
50 +
51 +1.8 Miscellaneous kernel statistics in /proc/stat
52 +-------------------------------------------------
53 +
54 +Various pieces   of  information about  kernel activity  are  available in the
55 +/proc/stat file.  All  of  the numbers reported  in  this file are  aggregates
56 +since the system first booted.  For a quick look, simply cat the file:
57 +
58 +  > cat /proc/stat
59 +  cpu  2255 34 2290 22625563 6290 127 456
60 +  cpu0 1132 34 1441 11311718 3675 127 438
61 +  cpu1 1123 0 849 11313845 2614 0 18
62 +  intr 114930548 113199788 3 0 5 263 0 4 [... lots more numbers ...]
63 +  ctxt 1990473
64 +  btime 1062191376
65 +  processes 2915
66 +  procs_running 1
67 +  procs_blocked 0
68 +
69 +The very first  "cpu" line aggregates the  numbers in all  of the other "cpuN"
70 +lines.  These numbers identify the amount of time the CPU has spent performing
71 +different kinds of work.  Time units are in USER_HZ (typically hundredths of a
72 +second).  The meanings of the columns are as follows, from left to right:
73 +
74 +- user: normal processes executing in user mode
75 +- nice: niced processes executing in user mode
76 +- system: processes executing in kernel mode
77 +- idle: twiddling thumbs
78 +- iowait: waiting for I/O to complete
79 +- irq: servicing interrupts
80 +- softirq: servicing softirqs
81 +
82 +The "intr" line gives counts of interrupts  serviced since boot time, for each
83 +of the  possible system interrupts.   The first  column  is the  total of  all
84 +interrupts serviced; each  subsequent column is the  total for that particular
85 +interrupt.
86 +
87 +The "ctxt" line gives the total number of context switches across all CPUs.
88 +
89 +The "btime" line gives  the time at which the  system booted, in seconds since
90 +the Unix epoch.
91 +
92 +The "processes" line gives the number  of processes and threads created, which
93 +includes (but  is not limited  to) those  created by  calls to the  fork() and
94 +clone() system calls.
95 +
96 +The  "procs_running" line gives the  number of processes  currently running on
97 +CPUs.
98 +
99 +The   "procs_blocked" line gives  the  number of  processes currently blocked,
100 +waiting for I/O to complete.
101  
102  
103  ------------------------------------------------------------------------------
104 diff -Nru a/Documentation/ide.txt b/Documentation/ide.txt
105 --- a/Documentation/ide.txt     Mon May 26 17:48:43 2003
106 +++ b/Documentation/ide.txt     Sun Aug 31 16:13:57 2003
107 @@ -1,5 +1,5 @@
108  
109 -       Information regarding the Enhanced IDE drive in Linux 2.5
110 +       Information regarding the Enhanced IDE drive in Linux 2.6
111  
112  ==============================================================================
113  
114 @@ -242,8 +242,23 @@
115                           and quite likely to cause trouble with
116                           older/odd IDE drives.
117  
118 + "hdx=biostimings"     : driver will NOT attempt to tune interface speed
119 +                         (DMA/PIO) but always honour BIOS timings.
120 +
121   "hdx=slow"            : insert a huge pause after each access to the data
122                           port. Should be used only as a last resort.
123 +
124 + "hdx=swapdata"                : when the drive is a disk, byte swap all data
125 +
126 + "hdx=bswap"           : same as above..........
127 +
128 + "hdx=flash"           : allows for more than one ata_flash disk to be
129 +                         registered. In most cases, only one device
130 +                         will be present.
131 +
132 + "hdx=scsi"            : the return of the ide-scsi flag, this is useful for
133 +                         allowing ide-floppy, ide-tape, and ide-cdrom|writers
134 +                         to use ide-scsi emulation on a device specific option.
135                                 
136   "hdxlun=xx"           : set the drive last logical unit
137  
138 @@ -277,27 +292,41 @@
139   "idex=noautotune"     : driver will NOT attempt to tune interface speed 
140                           This is the default for most chipsets,
141                           except the cmd640.
142 +
143 + "idex=biostimings"    : driver will NOT attempt to tune interface speed
144 +                         (DMA/PIO) but always honour BIOS timings.
145                                 
146   "idex=serialize"      : do not overlap operations on idex. Please note
147                           that you will have to specify this option for
148                           both the respecitve primary and secondary channel
149                           to take effect.
150 +
151 + "idex=four"           : four drives on idex and ide(x^1) share same ports
152                         
153   "idex=reset"          : reset interface after probe
154   
155   "idex=dma"            : automatically configure/use DMA if possible.
156  
157 -The following are valid ONLY on ide0, which usually corresponds to the first
158 -ATA interface found on the particular host, and the defaults for the base,ctl
159 -ports must not be altered.
160 + "idex=ata66"          : informs the interface that it has an 80c cable
161 +                         for chipsets that are ATA-66 capable, but the
162 +                         ability to bit test for detection is currently
163 +                         unknown.
164 +
165 + "ide=reverse"         : formerly called to pci sub-system, but now local.
166 +
167 +The following are valid ONLY on ide0 (except dc4030), which usually corresponds
168 +to the first ATA interface found on the particular host, and the defaults for
169 +the base,ctl ports must not be altered.
170  
171   "ide0=dtc2278"                : probe/support DTC2278 interface
172   "ide0=ht6560b"                : probe/support HT6560B interface
173   "ide0=cmd640_vlb"     : *REQUIRED* for VLB cards with the CMD640 chip
174                           (not for PCI -- automatically detected)
175   "ide0=qd65xx"         : probe/support qd65xx interface
176 - "ide0=ali14xx"                : probe/support ali14xx chipsets (ALI M1439/M1445)
177 + "ide0=ali14xx"                : probe/support ali14xx chipsets (ALI M1439/M1443/M1445)
178   "ide0=umc8672"                : probe/support umc8672 chipsets
179 + "idex=dc4030"         : probe/support Promise DC4030VL interface
180 + "ide=doubler"         : probe/support IDE doublers on Amiga
181  
182  There may be more options than shown -- use the source, Luke!
183  
184 @@ -375,3 +404,6 @@
185  
186  Wed Apr 17 22:52:44 CEST 2002 edited by Marcin Dalecki, the current
187  maintainer.
188 +
189 +Wed Aug 20 22:31:29 CEST 2003 updated ide boot uptions to current ide.c
190 +comments at 2.6.0-test4 time. Maciej Soltysiak <solt@dns.toxicfilms.tv>
191 diff -Nru a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
192 --- a/Documentation/kernel-parameters.txt       Mon Aug 18 22:27:07 2003
193 +++ b/Documentation/kernel-parameters.txt       Sun Aug 31 16:14:50 2003
194 @@ -215,7 +215,10 @@
195                         when calculating gettimeofday(). If specicified timesource
196                         is not avalible, it defaults to PIT. 
197                         Format: { pit | tsc | cyclone | ... }
198 -                       
199 +
200 +       hpet=           [IA-32,HPET] option to disable HPET and use PIT.
201 +                       Format: disable
202 +
203         cm206=          [HW,CD]
204                         Format: { auto | [<io>,][<irq>] }
205  
206 diff -Nru a/Documentation/kobject.txt b/Documentation/kobject.txt
207 --- a/Documentation/kobject.txt Tue Jun 17 15:59:07 2003
208 +++ b/Documentation/kobject.txt Sun Aug 31 16:14:13 2003
209 @@ -245,7 +245,9 @@
210    see the sysfs documentation for more information. 
211  
212  - default_attrs: Default attributes to be exported via sysfs when the
213 -  object is registered. 
214 +  object is registered.Note that the last attribute has to be
215 +  initialized to NULL ! You can find a complete implementation
216 +  in drivers/block/genhd.c
217  
218  
219  Instances of struct kobj_type are not registered; only referenced by
220 diff -Nru a/Documentation/sonypi.txt b/Documentation/sonypi.txt
221 --- a/Documentation/sonypi.txt  Tue Mar 11 10:20:18 2003
222 +++ b/Documentation/sonypi.txt  Tue Aug 26 09:02:05 2003
223 @@ -8,7 +8,9 @@
224         Copyright (C) 2000 Andrew Tridgell <tridge@samba.org>
225  
226  This driver enables access to the Sony Programmable I/O Control Device which
227 -can be found in many (all ?) Sony Vaio laptops.
228 +can be found in many Sony Vaio laptops. Some newer Sony laptops (seems to be
229 +limited to new FX series laptops, at least the FX501 and the FX702) lack a
230 +sonypi device and are not supported at all by this driver.
231  
232  It will give access (through a user space utility) to some events those laptops
233  generate, like:
234 @@ -96,6 +98,7 @@
235                                 SONYPI_THUMBPHRASE_MASK         0x0200
236                                 SONYPI_MEYE_MASK                0x0400
237                                 SONYPI_MEMORYSTICK_MASK         0x0800
238 +                               SONYPI_BATTERY_MASK             0x1000
239  
240         useinput:       if set (which is the default) jogdial events are
241                         forwarded to the input subsystem as mouse wheel
242 diff -Nru a/Documentation/sysctl/README b/Documentation/sysctl/README
243 --- a/Documentation/sysctl/README       Tue Feb  5 09:40:37 2002
244 +++ b/Documentation/sysctl/README       Sun Aug 31 16:14:14 2003
245 @@ -55,6 +55,7 @@
246  by piece basis, or just some 'thematic frobbing'.
247  
248  The subdirs are about:
249 +abi/           execution domains & personalities
250  debug/         <empty>
251  dev/           device specific information (eg dev/cdrom/info)
252  fs/            specific filesystems
253 diff -Nru a/Documentation/sysctl/abi.txt b/Documentation/sysctl/abi.txt
254 --- /dev/null   Wed Dec 31 16:00:00 1969
255 +++ b/Documentation/sysctl/abi.txt      Sun Aug 31 16:14:14 2003
256 @@ -0,0 +1,54 @@
257 +Documentation for /proc/sys/abi/* kernel version 2.6.0.test2
258 +       (c) 2003,  Fabian Frederick <ffrederick@users.sourceforge.net>
259 +
260 +For general info : README.
261 +
262 +==============================================================
263 +
264 +This path is binary emulation relevant aka personality types aka abi.
265 +When a process is executed, it's linked to an exec_domain whose
266 +personality is defined using values available from /proc/sys/abi.
267 +You can find further details about abi in include/linux/personality.h.
268 +
269 +Here are the files featuring in 2.6 kernel :
270 +
271 +- defhandler_coff
272 +- defhandler_elf
273 +- defhandler_lcall7
274 +- defhandler_libcso
275 +- fake_utsname
276 +- trace
277 +
278 +===========================================================
279 +defhandler_coff:
280 +defined value :
281 +PER_SCOSVR3
282 +0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS | SHORT_INODE
283 +
284 +===========================================================
285 +defhandler_elf:
286 +defined value :
287 +PER_LINUX
288 +0
289 +
290 +===========================================================
291 +defhandler_lcall7:
292 +defined value :
293 +PER_SVR4
294 +0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
295 +
296 +===========================================================
297 +defhandler_libsco:
298 +defined value:
299 +PER_SVR4
300 +0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,
301 +
302 +===========================================================
303 +fake_utsname:
304 +Unused
305 +
306 +===========================================================
307 +trace:
308 +Unused
309 +
310 +===========================================================
311 diff -Nru a/Documentation/video4linux/meye.txt b/Documentation/video4linux/meye.txt
312 --- a/Documentation/video4linux/meye.txt        Tue Feb 18 03:32:29 2003
313 +++ b/Documentation/video4linux/meye.txt        Fri Aug  1 05:47:51 2003
314 @@ -16,6 +16,23 @@
315  
316  MJPEG hardware grabbing is supported via a private API (see below).
317  
318 +Hardware supported:
319 +-------------------
320 +
321 +This driver supports the 'second' version of the MotionEye camera :)
322 +
323 +The first version was connected directly on the video bus of the Neomagic
324 +video card and is unsupported.
325 +
326 +The second one, made by Kawasaki Steel is fully supported by this 
327 +driver (PCI vendor/device is 0x136b/0xff01)
328 +
329 +The third one, present in recent (more or less last year) Picturebooks
330 +(C1M* models), is not supported. The manufacturer has given the specs
331 +to the developers under a NDA (which allows the develoment of a GPL
332 +driver however), but things are not moving very fast (see
333 +http://r-engine.sourceforge.net/) (PCI vendor/device is 0x10cf/0x2011).
334 +
335  Driver options:
336  ---------------
337  
338 diff -Nru a/MAINTAINERS b/MAINTAINERS
339 --- a/MAINTAINERS       Thu Aug 21 09:09:26 2003
340 +++ b/MAINTAINERS       Sun Aug 31 16:13:57 2003
341 @@ -615,8 +615,6 @@
342  S:     Maintained
343  
344  DRM DRIVERS
345 -P:     Rik Faith
346 -M:     faith@redhat.com
347  L:     dri-devel@lists.sourceforge.net
348  S:     Supported
349  
350 @@ -1087,6 +1085,14 @@
351  L:     kbuild-devel@lists.sourceforge.net
352  W:     http://kbuild.sourceforge.net
353  S:     Maintained 
354 +
355 +KERNEL JANITORS
356 +P:     Several
357 +L:     kernel-janitor-discuss@lists.sf.net
358 +W:     http://www.kerneljanitors.org/
359 +W:     http://sf.net/projects/kernel-janitor/
360 +W:     http://developer.osdl.org/rddunlap/kj-patches/
361 +S:     Maintained
362  
363  KERNEL NFSD
364  P:     Neil Brown
365 diff -Nru a/Makefile b/Makefile
366 --- a/Makefile  Fri Aug 22 16:38:51 2003
367 +++ b/Makefile  Tue Sep  2 04:33:54 2003
368 @@ -268,8 +268,19 @@
369  # Detect when mixed targets is specified, and make a second invocation
370  # of make so .config is not included in this case either (for *config).
371  
372 +no-dot-config-targets := clean mrproper distclean \
373 +                        cscope TAGS tags help %docs check%
374 +
375  config-targets := 0
376  mixed-targets  := 0
377 +dot-config     := 1
378 +
379 +ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
380 +       ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
381 +               dot-config := 0
382 +       endif
383 +endif
384 +
385  ifneq ($(filter config %config,$(MAKECMDGOALS)),)
386         config-targets := 1
387         ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
388 @@ -309,7 +320,26 @@
389  core-y         := usr/
390  SUBDIRS                :=
391  
392 --include .config
393 +ifeq ($(dot-config),1)
394 +# In this section, we need .config
395 +
396 +# Read in dependencies to all Kconfig* files, make sure to run
397 +# oldconfig if changes are detected.
398 +-include .config.cmd
399 +
400 +include .config
401 +
402 +# If .config needs to be updated, it will be done via the dependency
403 +# that autoconf has on .config.
404 +# To avoid any implicit rule to kick in, define an empty command
405 +.config: ;
406 +
407 +# If .config is newer than include/linux/autoconf.h, someone tinkered
408 +# with it and forgot to run make oldconfig
409 +include/linux/autoconf.h: scripts/fixdep .config
410 +       $(Q)$(MAKE) $(build)=scripts/kconfig silentoldconfig
411 +
412 +endif
413  
414  include arch/$(ARCH)/Makefile
415  
416 @@ -338,15 +368,7 @@
417  
418  # Here goes the main Makefile
419  # ---------------------------------------------------------------------------
420 -#
421 -# If the user gave a *config target, it'll be handled in another
422 -# section below, since in this case we cannot include .config
423 -# Same goes for other targets like clean/mrproper etc, which
424 -# don't need .config, either
425  
426 -#      In this section, we need .config
427 -
428 --include .config.cmd
429  
430  ifndef CONFIG_FRAME_POINTER
431  CFLAGS         += -fomit-frame-pointer
432 @@ -521,13 +543,6 @@
433         @scripts/split-include include/linux/autoconf.h include/config
434         @touch $@
435  
436 -#      if .config is newer than include/linux/autoconf.h, someone tinkered
437 -#      with it and forgot to run make oldconfig
438 -
439 -include/linux/autoconf.h: .config scripts/fixdep
440 -       $(Q)$(MAKE) $(build)=scripts/kconfig scripts/kconfig/conf
441 -       ./scripts/kconfig/conf -s arch/$(ARCH)/Kconfig
442 -
443  # Generate some files
444  # ---------------------------------------------------------------------------
445  
446 @@ -579,6 +594,11 @@
447  
448  .PHONY: _modinst_
449  _modinst_:
450 +       @if [ -z "`$(DEPMOD) -V | grep module-init-tools`" ]; then \
451 +               echo "Warning: you may need to install module-init-tools"; \
452 +               echo "See http://www.codemonkey.org.uk/post-halloween-2.5.txt";\
453 +               sleep 1; \
454 +       fi
455         @rm -rf $(MODLIB)/kernel
456         @rm -f $(MODLIB)/build
457         @mkdir -p $(MODLIB)/kernel
458 diff -Nru a/arch/alpha/Kconfig b/arch/alpha/Kconfig
459 --- a/arch/alpha/Kconfig        Sun Aug 17 01:06:24 2003
460 +++ b/arch/alpha/Kconfig        Sun Aug 31 16:14:22 2003
461 @@ -597,40 +597,6 @@
462  
463  source "drivers/pcmcia/Kconfig"
464  
465 -choice
466 -       prompt "Kernel core (/proc/kcore) format"
467 -       depends on PROC_FS
468 -       default KCORE_ELF
469 -
470 -config KCORE_ELF
471 -       bool "ELF"
472 -       ---help---
473 -         If you enabled support for /proc file system then the file
474 -         /proc/kcore will contain the kernel core image. This can be used
475 -         in gdb:
476 -
477 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
478 -
479 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
480 -         /proc/kcore appear in ELF core format as defined by the Executable
481 -         and Linking Format specification. Selecting A.OUT will choose the
482 -         old "a.out" format which may be necessary for some old versions
483 -         of binutils or on some architectures.
484 -
485 -         This is especially useful if you have compiled the kernel with the
486 -         "-g" option to preserve debugging information. It is mainly used
487 -         for examining kernel data structures on the live kernel so if you
488 -         don't understand what this means or are not a kernel hacker, just
489 -         leave it at its default value ELF.
490 -
491 -config KCORE_AOUT
492 -       bool "A.OUT"
493 -       help
494 -         Not necessary unless you're using a very out-of-date binutils
495 -         version.  You probably want KCORE_ELF.
496 -
497 -endchoice
498 -
499  config SRM_ENV
500         tristate "SRM environment through procfs"
501         depends on PROC_FS
502 diff -Nru a/arch/alpha/kernel/core_titan.c b/arch/alpha/kernel/core_titan.c
503 --- a/arch/alpha/kernel/core_titan.c    Sun Aug 17 00:57:42 2003
504 +++ b/arch/alpha/kernel/core_titan.c    Sun Aug 31 16:14:08 2003
505 @@ -717,12 +717,12 @@
506  
507  struct alpha_agp_ops titan_agp_ops =
508  {
509 -       setup:          titan_agp_setup,
510 -       cleanup:        titan_agp_cleanup,
511 -       configure:      titan_agp_configure,
512 -       bind:           titan_agp_bind_memory,
513 -       unbind:         titan_agp_unbind_memory,
514 -       translate:      titan_agp_translate
515 +       .setup          = titan_agp_setup,
516 +       .cleanup        = titan_agp_cleanup,
517 +       .configure      = titan_agp_configure,
518 +       .bind           = titan_agp_bind_memory,
519 +       .unbind         = titan_agp_unbind_memory,
520 +       .translate      = titan_agp_translate
521  };
522  
523  alpha_agp_info *
524 diff -Nru a/arch/arm/Kconfig b/arch/arm/Kconfig
525 --- a/arch/arm/Kconfig  Tue Aug 19 11:44:53 2003
526 +++ b/arch/arm/Kconfig  Sun Aug 31 16:14:22 2003
527 @@ -654,39 +654,6 @@
528           If you do not feel you need a faster FP emulation you should better
529           choose NWFPE.
530  
531 -choice
532 -       prompt "Kernel core (/proc/kcore) format"
533 -       default KCORE_ELF
534 -
535 -config KCORE_ELF
536 -       bool "ELF"
537 -       ---help---
538 -         If you enabled support for /proc file system then the file
539 -         /proc/kcore will contain the kernel core image. This can be used
540 -         in gdb:
541 -
542 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
543 -
544 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
545 -         /proc/kcore appear in ELF core format as defined by the Executable
546 -         and Linking Format specification. Selecting A.OUT will choose the
547 -         old "a.out" format which may be necessary for some old versions
548 -         of binutils or on some architectures.
549 -
550 -         This is especially useful if you have compiled the kernel with the
551 -         "-g" option to preserve debugging information. It is mainly used
552 -         for examining kernel data structures on the live kernel so if you
553 -         don't understand what this means or are not a kernel hacker, just
554 -         leave it at its default value ELF.
555 -
556 -config KCORE_AOUT
557 -       bool "A.OUT"
558 -       help
559 -         Not necessary unless you're using a very out-of-date binutils
560 -         version.  You probably want KCORE_ELF.
561 -
562 -endchoice
563 -
564  source "fs/Kconfig.binfmt"
565  
566  source "drivers/base/Kconfig"
567 diff -Nru a/arch/arm/Makefile b/arch/arm/Makefile
568 --- a/arch/arm/Makefile Tue Aug 19 11:44:53 2003
569 +++ b/arch/arm/Makefile Wed Aug 13 16:23:42 2003
570 @@ -24,6 +24,7 @@
571  CFLAGS         += -mbig-endian
572  AS             += -EB
573  LD             += -EB
574 +AFLAGS         += -mbig-endian
575  endif
576  
577  check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi)
578 diff -Nru a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
579 --- a/arch/arm/boot/Makefile    Tue Apr 15 08:12:47 2003
580 +++ b/arch/arm/boot/Makefile    Wed Aug 13 16:46:20 2003
581 @@ -42,11 +42,12 @@
582  ifeq ($(CONFIG_ARCH_SA1100),y)
583     zreladdr-$(CONFIG_SA1111)           := 0xc0208000
584  endif
585 -  zreladdr-$(CONFIG_ARCH_PXA)          := 0xa0008000
586 -  zreladdr-$(CONFIG_ARCH_ANAKIN)       := 0x20008000
587 -  zreladdr-$(CONFIG_ARCH_IQ80310)      := 0xa0008000
588 -  zreladdr-$(CONFIG_ARCH_IQ80321)      := 0xa0008000
589 -  zreladdr-$(CONFIG_ARCH_ADIFCC)       := 0xc0008000
590 +   zreladdr-$(CONFIG_ARCH_PXA)         := 0xa0008000
591 +   zreladdr-$(CONFIG_ARCH_ANAKIN)      := 0x20008000
592 +   zreladdr-$(CONFIG_ARCH_IOP3XX)      := 0xa0008000
593 +params-phys-$(CONFIG_ARCH_IOP3XX)      := 0xa0000100
594 +   zreladdr-$(CONFIG_ARCH_ADIFCC)      := 0xc0008000
595 +params-phys-$(CONFIG_ARCH_ADIFCC)      := 0xc0000100
596  
597  ZRELADDR    := $(zreladdr-y)
598  ZTEXTADDR   := $(ztextaddr-y)
599 diff -Nru a/arch/arm/common/amba.c b/arch/arm/common/amba.c
600 --- a/arch/arm/common/amba.c    Fri Aug 15 15:22:52 2003
601 +++ b/arch/arm/common/amba.c    Sun Aug 24 07:16:13 2003
602 @@ -41,13 +41,35 @@
603         return amba_lookup(pcdrv->id_table, pcdev) != NULL;
604  }
605  
606 +static int amba_suspend(struct device *dev, u32 state)
607 +{
608 +       struct amba_driver *drv = to_amba_driver(dev->driver);
609 +       int ret = 0;
610 +
611 +       if (dev->driver && drv->suspend)
612 +               ret = drv->suspend(to_amba_device(dev), state);
613 +       return ret;
614 +}
615 +
616 +static int amba_resume(struct device *dev)
617 +{
618 +       struct amba_driver *drv = to_amba_driver(dev->driver);
619 +       int ret = 0;
620 +
621 +       if (dev->driver && drv->resume)
622 +               ret = drv->resume(to_amba_device(dev));
623 +       return ret;
624 +}
625 +
626  /*
627   * Primecells are part of the Advanced Microcontroller Bus Architecture,
628   * so we call the bus "amba".
629   */
630 -struct bus_type amba_bustype = {
631 -       .name   = "amba",
632 -       .match  = amba_match,
633 +static struct bus_type amba_bustype = {
634 +       .name           = "amba",
635 +       .match          = amba_match,
636 +       .suspend        = amba_suspend,
637 +       .resume         = amba_resume,
638  };
639  
640  static int __init amba_init(void)
641 @@ -84,18 +106,6 @@
642         drv->shutdown(to_amba_device(dev));
643  }
644  
645 -static int amba_suspend(struct device *dev, u32 state, u32 level)
646 -{
647 -       struct amba_driver *drv = to_amba_driver(dev->driver);
648 -       return drv->suspend(to_amba_device(dev), state, level);
649 -}
650 -
651 -static int amba_resume(struct device *dev, u32 level)
652 -{
653 -       struct amba_driver *drv = to_amba_driver(dev->driver);
654 -       return drv->resume(to_amba_device(dev), level);
655 -}
656 -
657  /**
658   *     amba_driver_register - register an AMBA device driver
659   *     @drv: amba device driver structure
660 @@ -112,8 +122,6 @@
661         SETFN(probe);
662         SETFN(remove);
663         SETFN(shutdown);
664 -       SETFN(suspend);
665 -       SETFN(resume);
666  
667         return driver_register(&drv->drv);
668  }
669 diff -Nru a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
670 --- a/arch/arm/common/sa1111.c  Fri Aug 15 15:22:52 2003
671 +++ b/arch/arm/common/sa1111.c  Sun Aug 24 07:45:04 2003
672 @@ -790,10 +790,13 @@
673         struct sa1111 *sachip = dev_get_drvdata(dev);
674         struct sa1111_save_data *save;
675         unsigned long flags;
676 +       unsigned int val;
677         char *base;
678  
679 -       if (!dev->saved_state && level == SUSPEND_NOTIFY)
680 -               dev->saved_state = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
681 +       if (level != SUSPEND_DISABLE)
682 +               return 0;
683 +
684 +       dev->saved_state = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
685         if (!dev->saved_state)
686                 return -ENOMEM;
687  
688 @@ -804,36 +807,31 @@
689         /*
690          * Save state.
691          */
692 -       if (level == SUSPEND_SAVE_STATE) {
693 -               base = sachip->base;
694 -               save->skcr     = sa1111_readl(base + SA1111_SKCR);
695 -               save->skpcr    = sa1111_readl(base + SA1111_SKPCR);
696 -               save->skcdr    = sa1111_readl(base + SA1111_SKCDR);
697 -               save->skaud    = sa1111_readl(base + SA1111_SKAUD);
698 -               save->skpwm0   = sa1111_readl(base + SA1111_SKPWM0);
699 -               save->skpwm1   = sa1111_readl(base + SA1111_SKPWM1);
700 -
701 -               base = sachip->base + SA1111_INTC;
702 -               save->intpol0  = sa1111_readl(base + SA1111_INTPOL0);
703 -               save->intpol1  = sa1111_readl(base + SA1111_INTPOL1);
704 -               save->inten0   = sa1111_readl(base + SA1111_INTEN0);
705 -               save->inten1   = sa1111_readl(base + SA1111_INTEN1);
706 -               save->wakepol0 = sa1111_readl(base + SA1111_WAKEPOL0);
707 -               save->wakepol1 = sa1111_readl(base + SA1111_WAKEPOL1);
708 -               save->wakeen0  = sa1111_readl(base + SA1111_WAKEEN0);
709 -               save->wakeen1  = sa1111_readl(base + SA1111_WAKEEN1);
710 -       }
711 +       base = sachip->base;
712 +       save->skcr     = sa1111_readl(base + SA1111_SKCR);
713 +       save->skpcr    = sa1111_readl(base + SA1111_SKPCR);
714 +       save->skcdr    = sa1111_readl(base + SA1111_SKCDR);
715 +       save->skaud    = sa1111_readl(base + SA1111_SKAUD);
716 +       save->skpwm0   = sa1111_readl(base + SA1111_SKPWM0);
717 +       save->skpwm1   = sa1111_readl(base + SA1111_SKPWM1);
718 +
719 +       base = sachip->base + SA1111_INTC;
720 +       save->intpol0  = sa1111_readl(base + SA1111_INTPOL0);
721 +       save->intpol1  = sa1111_readl(base + SA1111_INTPOL1);
722 +       save->inten0   = sa1111_readl(base + SA1111_INTEN0);
723 +       save->inten1   = sa1111_readl(base + SA1111_INTEN1);
724 +       save->wakepol0 = sa1111_readl(base + SA1111_WAKEPOL0);
725 +       save->wakepol1 = sa1111_readl(base + SA1111_WAKEPOL1);
726 +       save->wakeen0  = sa1111_readl(base + SA1111_WAKEEN0);
727 +       save->wakeen1  = sa1111_readl(base + SA1111_WAKEEN1);
728  
729         /*
730          * Disable.
731          */
732 -       if (level == SUSPEND_POWER_DOWN && state == 4) {
733 -               unsigned int val = sa1111_readl(sachip->base + SA1111_SKCR);
734 -
735 -               sa1111_writel(val | SKCR_SLEEP, sachip->base + SA1111_SKCR);
736 -               sa1111_writel(0, sachip->base + SA1111_SKPWM0);
737 -               sa1111_writel(0, sachip->base + SA1111_SKPWM1);
738 -       }
739 +       val = sa1111_readl(sachip->base + SA1111_SKCR);
740 +       sa1111_writel(val | SKCR_SLEEP, sachip->base + SA1111_SKCR);
741 +       sa1111_writel(0, sachip->base + SA1111_SKPWM0);
742 +       sa1111_writel(0, sachip->base + SA1111_SKPWM1);
743  
744         spin_unlock_irqrestore(&sachip->lock, flags);
745  
746 @@ -857,6 +855,9 @@
747         unsigned long flags, id;
748         char *base;
749  
750 +       if (level != RESUME_ENABLE)
751 +               return 0;
752 +
753         save = (struct sa1111_save_data *)dev->saved_state;
754         if (!save)
755                 return 0;
756 @@ -878,39 +879,32 @@
757         /*
758          * First of all, wake up the chip.
759          */
760 -       if (level == RESUME_POWER_ON) {
761 -               sa1111_wake(sachip);
762 -
763 -               sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN0);
764 -               sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN1);
765 -       }
766 -
767 -       if (level == RESUME_RESTORE_STATE) {
768 -               base = sachip->base;
769 -               sa1111_writel(save->skcr,     base + SA1111_SKCR);
770 -               sa1111_writel(save->skpcr,    base + SA1111_SKPCR);
771 -               sa1111_writel(save->skcdr,    base + SA1111_SKCDR);
772 -               sa1111_writel(save->skaud,    base + SA1111_SKAUD);
773 -               sa1111_writel(save->skpwm0,   base + SA1111_SKPWM0);
774 -               sa1111_writel(save->skpwm1,   base + SA1111_SKPWM1);
775 -
776 -               base = sachip->base + SA1111_INTC;
777 -               sa1111_writel(save->intpol0,  base + SA1111_INTPOL0);
778 -               sa1111_writel(save->intpol1,  base + SA1111_INTPOL1);
779 -               sa1111_writel(save->inten0,   base + SA1111_INTEN0);
780 -               sa1111_writel(save->inten1,   base + SA1111_INTEN1);
781 -               sa1111_writel(save->wakepol0, base + SA1111_WAKEPOL0);
782 -               sa1111_writel(save->wakepol1, base + SA1111_WAKEPOL1);
783 -               sa1111_writel(save->wakeen0,  base + SA1111_WAKEEN0);
784 -               sa1111_writel(save->wakeen1,  base + SA1111_WAKEEN1);
785 -       }
786 +       sa1111_wake(sachip);
787 +       sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN0);
788 +       sa1111_writel(0, sachip->base + SA1111_INTC + SA1111_INTEN1);
789 +
790 +       base = sachip->base;
791 +       sa1111_writel(save->skcr,     base + SA1111_SKCR);
792 +       sa1111_writel(save->skpcr,    base + SA1111_SKPCR);
793 +       sa1111_writel(save->skcdr,    base + SA1111_SKCDR);
794 +       sa1111_writel(save->skaud,    base + SA1111_SKAUD);
795 +       sa1111_writel(save->skpwm0,   base + SA1111_SKPWM0);
796 +       sa1111_writel(save->skpwm1,   base + SA1111_SKPWM1);
797 +
798 +       base = sachip->base + SA1111_INTC;
799 +       sa1111_writel(save->intpol0,  base + SA1111_INTPOL0);
800 +       sa1111_writel(save->intpol1,  base + SA1111_INTPOL1);
801 +       sa1111_writel(save->inten0,   base + SA1111_INTEN0);
802 +       sa1111_writel(save->inten1,   base + SA1111_INTEN1);
803 +       sa1111_writel(save->wakepol0, base + SA1111_WAKEPOL0);
804 +       sa1111_writel(save->wakepol1, base + SA1111_WAKEPOL1);
805 +       sa1111_writel(save->wakeen0,  base + SA1111_WAKEEN0);
806 +       sa1111_writel(save->wakeen1,  base + SA1111_WAKEEN1);
807  
808         spin_unlock_irqrestore(&sachip->lock, flags);
809  
810 -       if (level == RESUME_ENABLE) {
811 -               dev->saved_state = NULL;
812 -               kfree(save);
813 -       }
814 +       dev->saved_state = NULL;
815 +       kfree(save);
816  
817         return 0;
818  }
819 @@ -1135,9 +1129,55 @@
820         return dev->devid == drv->devid;
821  }
822  
823 +static int sa1111_bus_suspend(struct device *dev, u32 state)
824 +{
825 +       struct sa1111_dev *sadev = SA1111_DEV(dev);
826 +       struct sa1111_driver *drv = SA1111_DRV(dev->driver);
827 +       int ret = 0;
828 +
829 +       if (drv && drv->suspend)
830 +               ret = drv->suspend(sadev, state);
831 +       return ret;
832 +}
833 +
834 +static int sa1111_bus_resume(struct device *dev)
835 +{
836 +       struct sa1111_dev *sadev = SA1111_DEV(dev);
837 +       struct sa1111_driver *drv = SA1111_DRV(dev->driver);
838 +       int ret = 0;
839 +
840 +       if (drv && drv->resume)
841 +               ret = drv->resume(sadev);
842 +       return ret;
843 +}
844 +
845 +static int sa1111_bus_probe(struct device *dev)
846 +{
847 +       struct sa1111_dev *sadev = SA1111_DEV(dev);
848 +       struct sa1111_driver *drv = SA1111_DRV(dev->driver);
849 +       int ret = -ENODEV;
850 +
851 +       if (drv->probe)
852 +               ret = drv->probe(sadev);
853 +       return ret;
854 +}
855 +
856 +static int sa1111_bus_remove(struct device *dev)
857 +{
858 +       struct sa1111_dev *sadev = SA1111_DEV(dev);
859 +       struct sa1111_driver *drv = SA1111_DRV(dev->driver);
860 +       int ret = 0;
861 +
862 +       if (drv->remove)
863 +               ret = drv->remove(sadev);
864 +       return ret;
865 +}
866 +
867  struct bus_type sa1111_bus_type = {
868 -       .name   = "RAB",
869 -       .match  = sa1111_match,
870 +       .name           = "sa1111-rab",
871 +       .match          = sa1111_match,
872 +       .suspend        = sa1111_bus_suspend,
873 +       .resume         = sa1111_bus_resume,
874  };
875  
876  static int sa1111_rab_bus_init(void)
877 @@ -1147,6 +1187,19 @@
878  
879  postcore_initcall(sa1111_rab_bus_init);
880  
881 +int sa1111_driver_register(struct sa1111_driver *driver)
882 +{
883 +       driver->drv.probe = sa1111_bus_probe;
884 +       driver->drv.remove = sa1111_bus_remove;
885 +       driver->drv.bus = &sa1111_bus_type;
886 +       return driver_register(&driver->drv);
887 +}
888 +
889 +void sa1111_driver_unregister(struct sa1111_driver *driver)
890 +{
891 +       driver_unregister(&driver->drv);
892 +}
893 +
894  EXPORT_SYMBOL(sa1111_check_dma_bug);
895  EXPORT_SYMBOL(sa1111_select_audio_mode);
896  EXPORT_SYMBOL(sa1111_set_audio_rate);
897 @@ -1155,3 +1208,5 @@
898  EXPORT_SYMBOL(sa1111_disable_device);
899  EXPORT_SYMBOL(sa1111_pll_clock);
900  EXPORT_SYMBOL(sa1111_bus_type);
901 +EXPORT_SYMBOL(sa1111_driver_register);
902 +EXPORT_SYMBOL(sa1111_driver_unregister);
903 diff -Nru a/arch/arm/def-configs/iq80310 b/arch/arm/def-configs/iq80310
904 --- a/arch/arm/def-configs/iq80310      Tue Apr 15 07:34:41 2003
905 +++ b/arch/arm/def-configs/iq80310      Wed Aug 13 16:46:20 2003
906 @@ -19,6 +19,12 @@
907  # CONFIG_BSD_PROCESS_ACCT is not set
908  CONFIG_SYSCTL=y
909  CONFIG_LOG_BUF_SHIFT=14
910 +# CONFIG_EMBEDDED is not set
911 +CONFIG_KALLSYMS=y
912 +CONFIG_FUTEX=y
913 +CONFIG_EPOLL=y
914 +CONFIG_IOSCHED_AS=y
915 +CONFIG_IOSCHED_DEADLINE=y
916  
917  #
918  # Loadable module support
919 @@ -34,7 +40,6 @@
920  #
921  # CONFIG_ARCH_ADIFCC is not set
922  # CONFIG_ARCH_ANAKIN is not set
923 -# CONFIG_ARCH_ARCA5K is not set
924  # CONFIG_ARCH_CLPS7500 is not set
925  # CONFIG_ARCH_CLPS711X is not set
926  # CONFIG_ARCH_CO285 is not set
927 @@ -50,14 +55,6 @@
928  # CONFIG_ARCH_SHARK is not set
929  
930  #
931 -# Archimedes/A5000 Implementations
932 -#
933 -
934 -#
935 -# Archimedes/A5000 Implementations (select only ONE)
936 -#
937 -
938 -#
939  # CLPS711X/EP721X Implementations
940  #
941  
942 @@ -73,7 +70,9 @@
943  # IOP3xx Implementation Options
944  #
945  CONFIG_ARCH_IQ80310=y
946 +# CONFIG_ARCH_IQ80321 is not set
947  CONFIG_ARCH_IOP310=y
948 +# CONFIG_ARCH_IOP321 is not set
949  
950  #
951  # IOP3xx Chipset Features
952 @@ -84,6 +83,14 @@
953  # CONFIG_IOP3XX_PMON is not set
954  
955  #
956 +# ADIFCC Implementation Options
957 +#
958 +
959 +#
960 +# ADI Board Types
961 +#
962 +
963 +#
964  # Intel PXA250/210 Implementations
965  #
966  
967 @@ -96,6 +103,7 @@
968  #
969  CONFIG_CPU_32=y
970  CONFIG_CPU_XSCALE=y
971 +CONFIG_XS80200=y
972  CONFIG_CPU_32v5=y
973  
974  #
975 @@ -116,9 +124,15 @@
976  # CONFIG_HOTPLUG is not set
977  
978  #
979 +# MMC/SD Card support
980 +#
981 +# CONFIG_MMC is not set
982 +
983 +#
984  # At least one math emulation must be selected
985  #
986  CONFIG_FPE_NWFPE=y
987 +# CONFIG_FPE_NWFPE_XP is not set
988  # CONFIG_FPE_FASTFPE is not set
989  CONFIG_KCORE_ELF=y
990  # CONFIG_KCORE_AOUT is not set
991 @@ -154,6 +168,7 @@
992  CONFIG_MTD_BLOCK=y
993  # CONFIG_FTL is not set
994  # CONFIG_NFTL is not set
995 +# CONFIG_INFTL is not set
996  
997  #
998  # RAM/ROM/Flash chip drivers
999 @@ -164,6 +179,7 @@
1000  # CONFIG_MTD_CFI_ADV_OPTIONS is not set
1001  CONFIG_MTD_CFI_INTELEXT=y
1002  # CONFIG_MTD_CFI_AMDSTD is not set
1003 +# CONFIG_MTD_CFI_STAA is not set
1004  # CONFIG_MTD_RAM is not set
1005  # CONFIG_MTD_ROM is not set
1006  # CONFIG_MTD_ABSENT is not set
1007 @@ -172,13 +188,11 @@
1008  #
1009  # Mapping drivers for chip access
1010  #
1011 +# CONFIG_MTD_COMPLEX_MAPPINGS is not set
1012  # CONFIG_MTD_PHYSMAP is not set
1013 -# CONFIG_MTD_NORA is not set
1014  # CONFIG_MTD_ARM_INTEGRATOR is not set
1015  CONFIG_MTD_IQ80310=y
1016  # CONFIG_MTD_EDB7312 is not set
1017 -# CONFIG_MTD_PCI is not set
1018 -# CONFIG_MTD_UCLINUX is not set
1019  
1020  #
1021  # Self-contained MTD device drivers
1022 @@ -191,9 +205,9 @@
1023  #
1024  # Disk-On-Chip Device Drivers
1025  #
1026 -# CONFIG_MTD_DOC1000 is not set
1027  # CONFIG_MTD_DOC2000 is not set
1028  # CONFIG_MTD_DOC2001 is not set
1029 +# CONFIG_MTD_DOC2001PLUS is not set
1030  
1031  #
1032  # NAND Flash Device Drivers
1033 @@ -236,7 +250,6 @@
1034  # CONFIG_NETLINK_DEV is not set
1035  CONFIG_NETFILTER=y
1036  # CONFIG_NETFILTER_DEBUG is not set
1037 -# CONFIG_FILTER is not set
1038  CONFIG_UNIX=y
1039  # CONFIG_NET_KEY is not set
1040  CONFIG_INET=y
1041 @@ -253,7 +266,7 @@
1042  # CONFIG_SYN_COOKIES is not set
1043  # CONFIG_INET_AH is not set
1044  # CONFIG_INET_ESP is not set
1045 -# CONFIG_XFRM_USER is not set
1046 +# CONFIG_INET_IPCOMP is not set
1047  
1048  #
1049  # IP: Netfilter Configuration
1050 @@ -264,7 +277,13 @@
1051  # CONFIG_IP_NF_ARPTABLES is not set
1052  # CONFIG_IP_NF_COMPAT_IPCHAINS is not set
1053  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
1054 +
1055 +#
1056 +# IP: Virtual Server Configuration
1057 +#
1058 +# CONFIG_IP_VS is not set
1059  # CONFIG_IPV6 is not set
1060 +# CONFIG_XFRM_USER is not set
1061  
1062  #
1063  # SCTP Configuration (EXPERIMENTAL)
1064 @@ -310,6 +329,7 @@
1065  #
1066  CONFIG_NET_ETHERNET=y
1067  CONFIG_MII=y
1068 +# CONFIG_SMC91X is not set
1069  # CONFIG_HAPPYMEAL is not set
1070  # CONFIG_SUNGEM is not set
1071  # CONFIG_NET_VENDOR_3COM is not set
1072 @@ -351,6 +371,11 @@
1073  # CONFIG_R8169 is not set
1074  # CONFIG_SK98LIN is not set
1075  # CONFIG_TIGON3 is not set
1076 +
1077 +#
1078 +# Ethernet (10000 Mbit)
1079 +#
1080 +# CONFIG_IXGB is not set
1081  # CONFIG_FDDI is not set
1082  # CONFIG_HIPPI is not set
1083  # CONFIG_PPP is not set
1084 @@ -402,6 +427,7 @@
1085  CONFIG_BLK_DEV_IDECD=y
1086  # CONFIG_BLK_DEV_IDEFLOPPY is not set
1087  # CONFIG_IDE_TASK_IOCTL is not set
1088 +# CONFIG_IDE_TASKFILE_IO is not set
1089  
1090  #
1091  # IDE chipset support/bugfixes
1092 @@ -409,7 +435,7 @@
1093  # CONFIG_BLK_DEV_IDEPCI is not set
1094  
1095  #
1096 -# SCSI support
1097 +# SCSI device support
1098  #
1099  # CONFIG_SCSI is not set
1100  
1101 @@ -481,6 +507,7 @@
1102  #
1103  # I2C Hardware Sensors Chip support
1104  #
1105 +# CONFIG_I2C_SENSOR is not set
1106  
1107  #
1108  # L3 serial bus support
1109 @@ -534,6 +561,8 @@
1110  # CONFIG_VIDEO_PMS is not set
1111  # CONFIG_VIDEO_CPIA is not set
1112  # CONFIG_VIDEO_STRADIS is not set
1113 +# CONFIG_VIDEO_HEXIUM_ORION is not set
1114 +# CONFIG_VIDEO_HEXIUM_GEMINI is not set
1115  
1116  #
1117  # Radio Adapters
1118 @@ -551,18 +580,29 @@
1119  #
1120  # Supported Frontend Modules
1121  #
1122 -CONFIG_DVB_ALPS_BSRU6=y
1123 +# CONFIG_DVB_STV0299 is not set
1124  # CONFIG_DVB_ALPS_BSRV2 is not set
1125  # CONFIG_DVB_ALPS_TDLB7 is not set
1126  # CONFIG_DVB_ALPS_TDMB7 is not set
1127 +# CONFIG_DVB_ATMEL_AT76C651 is not set
1128 +# CONFIG_DVB_CX24110 is not set
1129  # CONFIG_DVB_GRUNDIG_29504_491 is not set
1130  # CONFIG_DVB_GRUNDIG_29504_401 is not set
1131 +# CONFIG_DVB_MT312 is not set
1132  # CONFIG_DVB_VES1820 is not set
1133 +# CONFIG_DVB_TDA1004X is not set
1134  
1135  #
1136 -# Supported DVB Adapters
1137 +# Supported SAA7146 based PCI Adapters
1138  #
1139  # CONFIG_DVB_AV7110 is not set
1140 +# CONFIG_DVB_BUDGET is not set
1141 +
1142 +#
1143 +# Supported FlexCopII (B2C2) Adapters
1144 +#
1145 +# CONFIG_DVB_B2C2_SKYSTAR is not set
1146 +# CONFIG_VIDEO_BTCX is not set
1147  
1148  #
1149  # File systems
1150 @@ -598,6 +638,7 @@
1151  CONFIG_PROC_FS=y
1152  # CONFIG_DEVFS_FS is not set
1153  CONFIG_DEVPTS_FS=y
1154 +# CONFIG_DEVPTS_FS_XATTR is not set
1155  CONFIG_TMPFS=y
1156  CONFIG_RAMFS=y
1157  
1158 @@ -631,13 +672,13 @@
1159  CONFIG_ROOT_NFS=y
1160  CONFIG_LOCKD=y
1161  # CONFIG_EXPORTFS is not set
1162 +CONFIG_SUNRPC=y
1163 +# CONFIG_SUNRPC_GSS is not set
1164  # CONFIG_SMB_FS is not set
1165  # CONFIG_CIFS is not set
1166  # CONFIG_NCP_FS is not set
1167  # CONFIG_CODA_FS is not set
1168  # CONFIG_INTERMEZZO_FS is not set
1169 -CONFIG_SUNRPC=y
1170 -# CONFIG_SUNRPC_GSS is not set
1171  # CONFIG_AFS_FS is not set
1172  
1173  #
1174 @@ -655,6 +696,7 @@
1175  # CONFIG_SOLARIS_X86_PARTITION is not set
1176  # CONFIG_UNIXWARE_DISKLABEL is not set
1177  # CONFIG_LDM_PARTITION is not set
1178 +# CONFIG_NEC98_PARTITION is not set
1179  # CONFIG_SGI_PARTITION is not set
1180  # CONFIG_ULTRIX_PARTITION is not set
1181  # CONFIG_SUN_PARTITION is not set
1182 @@ -666,13 +708,6 @@
1183  # CONFIG_FB is not set
1184  
1185  #
1186 -# Console display driver support
1187 -#
1188 -# CONFIG_VGA_CONSOLE is not set
1189 -# CONFIG_MDA_CONSOLE is not set
1190 -CONFIG_DUMMY_CONSOLE=y
1191 -
1192 -#
1193  # Sound
1194  #
1195  # CONFIG_SOUND is not set
1196 @@ -695,6 +730,7 @@
1197  # USB support
1198  #
1199  # CONFIG_USB is not set
1200 +# CONFIG_USB_GADGET is not set
1201  
1202  #
1203  # Bluetooth support
1204 @@ -714,7 +750,6 @@
1205  # CONFIG_DEBUG_WAITQ is not set
1206  CONFIG_DEBUG_BUGVERBOSE=y
1207  CONFIG_DEBUG_ERRORS=y
1208 -CONFIG_KALLSYMS=y
1209  CONFIG_DEBUG_LL=y
1210  
1211  #
1212 diff -Nru a/arch/arm/def-configs/iq80321 b/arch/arm/def-configs/iq80321
1213 --- a/arch/arm/def-configs/iq80321      Sat Aug  2 12:59:32 2003
1214 +++ b/arch/arm/def-configs/iq80321      Wed Aug 13 16:46:20 2003
1215 @@ -9,7 +9,7 @@
1216  #
1217  # Code maturity level options
1218  #
1219 -# CONFIG_EXPERIMENTAL is not set
1220 +CONFIG_EXPERIMENTAL=y
1221  
1222  #
1223  # General setup
1224 @@ -19,6 +19,12 @@
1225  # CONFIG_BSD_PROCESS_ACCT is not set
1226  CONFIG_SYSCTL=y
1227  CONFIG_LOG_BUF_SHIFT=14
1228 +# CONFIG_EMBEDDED is not set
1229 +CONFIG_KALLSYMS=y
1230 +CONFIG_FUTEX=y
1231 +CONFIG_EPOLL=y
1232 +CONFIG_IOSCHED_AS=y
1233 +CONFIG_IOSCHED_DEADLINE=y
1234  
1235  #
1236  # Loadable module support
1237 @@ -26,6 +32,7 @@
1238  CONFIG_MODULES=y
1239  # CONFIG_MODULE_UNLOAD is not set
1240  CONFIG_OBSOLETE_MODPARM=y
1241 +# CONFIG_MODVERSIONS is not set
1242  CONFIG_KMOD=y
1243  
1244  #
1245 @@ -33,7 +40,6 @@
1246  #
1247  # CONFIG_ARCH_ADIFCC is not set
1248  # CONFIG_ARCH_ANAKIN is not set
1249 -# CONFIG_ARCH_ARCA5K is not set
1250  # CONFIG_ARCH_CLPS7500 is not set
1251  # CONFIG_ARCH_CLPS711X is not set
1252  # CONFIG_ARCH_CO285 is not set
1253 @@ -49,14 +55,6 @@
1254  # CONFIG_ARCH_SHARK is not set
1255  
1256  #
1257 -# Archimedes/A5000 Implementations
1258 -#
1259 -
1260 -#
1261 -# Archimedes/A5000 Implementations (select only ONE)
1262 -#
1263 -
1264 -#
1265  # CLPS711X/EP721X Implementations
1266  #
1267  
1268 @@ -79,6 +77,18 @@
1269  #
1270  # IOP3xx Chipset Features
1271  #
1272 +# CONFIG_IOP3XX_AAU is not set
1273 +# CONFIG_IOP3XX_DMA is not set
1274 +# CONFIG_IOP3XX_MU is not set
1275 +# CONFIG_IOP3XX_PMON is not set
1276 +
1277 +#
1278 +# ADIFCC Implementation Options
1279 +#
1280 +
1281 +#
1282 +# ADI Board Types
1283 +#
1284  
1285  #
1286  # Intel PXA250/210 Implementations
1287 @@ -98,6 +108,7 @@
1288  #
1289  # Processor Features
1290  #
1291 +# CONFIG_ARM_THUMB is not set
1292  CONFIG_XSCALE_PMU=y
1293  
1294  #
1295 @@ -112,17 +123,25 @@
1296  # CONFIG_HOTPLUG is not set
1297  
1298  #
1299 +# MMC/SD Card support
1300 +#
1301 +# CONFIG_MMC is not set
1302 +
1303 +#
1304  # At least one math emulation must be selected
1305  #
1306  CONFIG_FPE_NWFPE=y
1307 +# CONFIG_FPE_NWFPE_XP is not set
1308 +# CONFIG_FPE_FASTFPE is not set
1309  CONFIG_KCORE_ELF=y
1310  # CONFIG_KCORE_AOUT is not set
1311  CONFIG_BINFMT_AOUT=y
1312  CONFIG_BINFMT_ELF=y
1313  # CONFIG_BINFMT_MISC is not set
1314  # CONFIG_PM is not set
1315 +# CONFIG_PREEMPT is not set
1316  # CONFIG_ARTHUR is not set
1317 -CONFIG_CMDLINE="ip=boot root=nfs console=ttyS0,115200"
1318 +CONFIG_CMDLINE="ip=boot root=nfs console=ttyS0,115200 mem=128M@0xa0000000"
1319  CONFIG_ALIGNMENT_TRAP=y
1320  
1321  #
1322 @@ -148,6 +167,7 @@
1323  CONFIG_MTD_BLOCK=y
1324  # CONFIG_FTL is not set
1325  # CONFIG_NFTL is not set
1326 +# CONFIG_INFTL is not set
1327  
1328  #
1329  # RAM/ROM/Flash chip drivers
1330 @@ -158,6 +178,7 @@
1331  # CONFIG_MTD_CFI_ADV_OPTIONS is not set
1332  CONFIG_MTD_CFI_INTELEXT=y
1333  # CONFIG_MTD_CFI_AMDSTD is not set
1334 +# CONFIG_MTD_CFI_STAA is not set
1335  # CONFIG_MTD_RAM is not set
1336  # CONFIG_MTD_ROM is not set
1337  # CONFIG_MTD_ABSENT is not set
1338 @@ -166,13 +187,10 @@
1339  #
1340  # Mapping drivers for chip access
1341  #
1342 +# CONFIG_MTD_COMPLEX_MAPPINGS is not set
1343  # CONFIG_MTD_PHYSMAP is not set
1344 -# CONFIG_MTD_NORA is not set
1345  # CONFIG_MTD_ARM_INTEGRATOR is not set
1346 -CONFIG_MTD_IQ80321=y
1347  # CONFIG_MTD_EDB7312 is not set
1348 -# CONFIG_MTD_PCI is not set
1349 -# CONFIG_MTD_UCLINUX is not set
1350  
1351  #
1352  # Self-contained MTD device drivers
1353 @@ -185,9 +203,9 @@
1354  #
1355  # Disk-On-Chip Device Drivers
1356  #
1357 -# CONFIG_MTD_DOC1000 is not set
1358  # CONFIG_MTD_DOC2000 is not set
1359  # CONFIG_MTD_DOC2001 is not set
1360 +# CONFIG_MTD_DOC2001PLUS is not set
1361  
1362  #
1363  # NAND Flash Device Drivers
1364 @@ -206,6 +224,7 @@
1365  # CONFIG_BLK_CPQ_DA is not set
1366  # CONFIG_BLK_CPQ_CISS_DA is not set
1367  # CONFIG_BLK_DEV_DAC960 is not set
1368 +# CONFIG_BLK_DEV_UMEM is not set
1369  # CONFIG_BLK_DEV_LOOP is not set
1370  # CONFIG_BLK_DEV_NBD is not set
1371  CONFIG_BLK_DEV_RAM=y
1372 @@ -229,7 +248,6 @@
1373  # CONFIG_NETLINK_DEV is not set
1374  CONFIG_NETFILTER=y
1375  # CONFIG_NETFILTER_DEBUG is not set
1376 -# CONFIG_FILTER is not set
1377  CONFIG_UNIX=y
1378  # CONFIG_NET_KEY is not set
1379  CONFIG_INET=y
1380 @@ -241,24 +259,47 @@
1381  # CONFIG_IP_PNP_RARP is not set
1382  # CONFIG_NET_IPIP is not set
1383  # CONFIG_NET_IPGRE is not set
1384 +# CONFIG_ARPD is not set
1385  # CONFIG_INET_ECN is not set
1386  # CONFIG_SYN_COOKIES is not set
1387  # CONFIG_INET_AH is not set
1388  # CONFIG_INET_ESP is not set
1389 -# CONFIG_XFRM_USER is not set
1390 +# CONFIG_INET_IPCOMP is not set
1391  
1392  #
1393  # IP: Netfilter Configuration
1394  #
1395  # CONFIG_IP_NF_CONNTRACK is not set
1396 +# CONFIG_IP_NF_QUEUE is not set
1397  # CONFIG_IP_NF_IPTABLES is not set
1398  # CONFIG_IP_NF_ARPTABLES is not set
1399  # CONFIG_IP_NF_COMPAT_IPCHAINS is not set
1400  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
1401 +
1402 +#
1403 +# IP: Virtual Server Configuration
1404 +#
1405 +# CONFIG_IP_VS is not set
1406 +# CONFIG_IPV6 is not set
1407 +# CONFIG_XFRM_USER is not set
1408 +
1409 +#
1410 +# SCTP Configuration (EXPERIMENTAL)
1411 +#
1412 +CONFIG_IPV6_SCTP__=y
1413 +# CONFIG_IP_SCTP is not set
1414 +# CONFIG_ATM is not set
1415  # CONFIG_VLAN_8021Q is not set
1416  # CONFIG_LLC is not set
1417  # CONFIG_DECNET is not set
1418  # CONFIG_BRIDGE is not set
1419 +# CONFIG_X25 is not set
1420 +# CONFIG_LAPB is not set
1421 +# CONFIG_NET_DIVERT is not set
1422 +# CONFIG_ECONET is not set
1423 +# CONFIG_WAN_ROUTER is not set
1424 +# CONFIG_NET_FASTROUTE is not set
1425 +# CONFIG_NET_HW_FLOWCONTROL is not set
1426  
1427  #
1428  # QoS and/or fair queueing
1429 @@ -279,12 +320,14 @@
1430  # CONFIG_BONDING is not set
1431  # CONFIG_EQUALIZER is not set
1432  # CONFIG_TUN is not set
1433 +# CONFIG_ETHERTAP is not set
1434  
1435  #
1436  # Ethernet (10 or 100Mbit)
1437  #
1438  CONFIG_NET_ETHERNET=y
1439  # CONFIG_MII is not set
1440 +# CONFIG_SMC91X is not set
1441  # CONFIG_HAPPYMEAL is not set
1442  # CONFIG_SUNGEM is not set
1443  # CONFIG_NET_VENDOR_3COM is not set
1444 @@ -298,6 +341,7 @@
1445  # CONFIG_PCNET32 is not set
1446  # CONFIG_AMD8111_ETH is not set
1447  # CONFIG_ADAPTEC_STARFIRE is not set
1448 +# CONFIG_B44 is not set
1449  # CONFIG_DGRS is not set
1450  CONFIG_EEPRO100=y
1451  # CONFIG_EEPRO100_PIO is not set
1452 @@ -305,6 +349,7 @@
1453  # CONFIG_FEALNX is not set
1454  # CONFIG_NATSEMI is not set
1455  # CONFIG_NE2K_PCI is not set
1456 +# CONFIG_8139CP is not set
1457  # CONFIG_8139TOO is not set
1458  # CONFIG_SIS900 is not set
1459  # CONFIG_EPIC100 is not set
1460 @@ -317,13 +362,21 @@
1461  #
1462  # CONFIG_ACENIC is not set
1463  # CONFIG_DL2K is not set
1464 -# CONFIG_E1000 is not set
1465 +CONFIG_E1000=y
1466 +CONFIG_E1000_NAPI=y
1467  # CONFIG_NS83820 is not set
1468  # CONFIG_HAMACHI is not set
1469 +# CONFIG_YELLOWFIN is not set
1470  # CONFIG_R8169 is not set
1471  # CONFIG_SK98LIN is not set
1472  # CONFIG_TIGON3 is not set
1473 +
1474 +#
1475 +# Ethernet (10000 Mbit)
1476 +#
1477 +# CONFIG_IXGB is not set
1478  # CONFIG_FDDI is not set
1479 +# CONFIG_HIPPI is not set
1480  # CONFIG_PPP is not set
1481  # CONFIG_SLIP is not set
1482  
1483 @@ -335,6 +388,8 @@
1484  #
1485  # Token Ring devices (depends on LLC=y)
1486  #
1487 +# CONFIG_RCPCI is not set
1488 +# CONFIG_SHAPER is not set
1489  
1490  #
1491  # Wan interfaces
1492 @@ -371,6 +426,7 @@
1493  CONFIG_BLK_DEV_IDECD=y
1494  # CONFIG_BLK_DEV_IDEFLOPPY is not set
1495  # CONFIG_IDE_TASK_IOCTL is not set
1496 +# CONFIG_IDE_TASKFILE_IO is not set
1497  
1498  #
1499  # IDE chipset support/bugfixes
1500 @@ -379,11 +435,13 @@
1501  # CONFIG_BLK_DEV_GENERIC is not set
1502  # CONFIG_IDEPCI_SHARE_IRQ is not set
1503  CONFIG_BLK_DEV_IDEDMA_PCI=y
1504 +# CONFIG_BLK_DEV_IDE_TCQ is not set
1505  # CONFIG_BLK_DEV_OFFBOARD is not set
1506  # CONFIG_BLK_DEV_IDEDMA_FORCED is not set
1507  CONFIG_IDEDMA_PCI_AUTO=y
1508  # CONFIG_IDEDMA_ONLYDISK is not set
1509  CONFIG_BLK_DEV_IDEDMA=y
1510 +# CONFIG_IDEDMA_PCI_WIP is not set
1511  CONFIG_BLK_DEV_ADMA=y
1512  # CONFIG_BLK_DEV_AEC62XX is not set
1513  # CONFIG_BLK_DEV_ALI15X3 is not set
1514 @@ -391,11 +449,13 @@
1515  CONFIG_BLK_DEV_CMD64X=y
1516  # CONFIG_BLK_DEV_TRIFLEX is not set
1517  # CONFIG_BLK_DEV_CY82C693 is not set
1518 +# CONFIG_BLK_DEV_CS5520 is not set
1519  # CONFIG_BLK_DEV_HPT34X is not set
1520  # CONFIG_BLK_DEV_HPT366 is not set
1521  # CONFIG_BLK_DEV_SC1200 is not set
1522  # CONFIG_BLK_DEV_PIIX is not set
1523  # CONFIG_BLK_DEV_NS87415 is not set
1524 +# CONFIG_BLK_DEV_OPTI621 is not set
1525  # CONFIG_BLK_DEV_PDC202XX_OLD is not set
1526  # CONFIG_BLK_DEV_PDC202XX_NEW is not set
1527  # CONFIG_BLK_DEV_SVWKS is not set
1528 @@ -408,11 +468,16 @@
1529  # CONFIG_IDEDMA_IVB is not set
1530  
1531  #
1532 -# SCSI support
1533 +# SCSI device support
1534  #
1535  # CONFIG_SCSI is not set
1536  
1537  #
1538 +# IEEE 1394 (FireWire) support (EXPERIMENTAL)
1539 +#
1540 +# CONFIG_IEEE1394 is not set
1541 +
1542 +#
1543  # I2O device support
1544  #
1545  # CONFIG_I2O is not set
1546 @@ -450,11 +515,16 @@
1547  #
1548  # Serial drivers
1549  #
1550 +CONFIG_SERIAL_8250=y
1551 +CONFIG_SERIAL_8250_CONSOLE=y
1552 +# CONFIG_SERIAL_8250_EXTENDED is not set
1553  
1554  #
1555  # Non-8250 serial port support
1556  #
1557  # CONFIG_SERIAL_DZ is not set
1558 +CONFIG_SERIAL_CORE=y
1559 +CONFIG_SERIAL_CORE_CONSOLE=y
1560  CONFIG_UNIX98_PTYS=y
1561  CONFIG_UNIX98_PTY_COUNT=256
1562  
1563 @@ -470,6 +540,7 @@
1564  #
1565  # I2C Hardware Sensors Chip support
1566  #
1567 +# CONFIG_I2C_SENSOR is not set
1568  
1569  #
1570  # L3 serial bus support
1571 @@ -522,6 +593,9 @@
1572  #
1573  # CONFIG_VIDEO_PMS is not set
1574  # CONFIG_VIDEO_CPIA is not set
1575 +# CONFIG_VIDEO_STRADIS is not set
1576 +# CONFIG_VIDEO_HEXIUM_ORION is not set
1577 +# CONFIG_VIDEO_HEXIUM_GEMINI is not set
1578  
1579  #
1580  # Radio Adapters
1581 @@ -534,6 +608,7 @@
1582  # Digital Video Broadcasting Devices
1583  #
1584  # CONFIG_DVB is not set
1585 +# CONFIG_VIDEO_BTCX is not set
1586  
1587  #
1588  # File systems
1589 @@ -567,16 +642,25 @@
1590  # Pseudo filesystems
1591  #
1592  CONFIG_PROC_FS=y
1593 +# CONFIG_DEVFS_FS is not set
1594  CONFIG_DEVPTS_FS=y
1595 +# CONFIG_DEVPTS_FS_XATTR is not set
1596  CONFIG_TMPFS=y
1597  CONFIG_RAMFS=y
1598  
1599  #
1600  # Miscellaneous filesystems
1601  #
1602 +# CONFIG_ADFS_FS is not set
1603 +# CONFIG_AFFS_FS is not set
1604 +# CONFIG_HFS_FS is not set
1605 +# CONFIG_BEFS_FS is not set
1606 +# CONFIG_BFS_FS is not set
1607 +# CONFIG_EFS_FS is not set
1608  # CONFIG_JFFS_FS is not set
1609  CONFIG_JFFS2_FS=y
1610  CONFIG_JFFS2_FS_DEBUG=0
1611 +# CONFIG_JFFS2_FS_NAND is not set
1612  # CONFIG_CRAMFS is not set
1613  # CONFIG_VXFS_FS is not set
1614  # CONFIG_HPFS_FS is not set
1615 @@ -589,15 +673,19 @@
1616  #
1617  CONFIG_NFS_FS=y
1618  # CONFIG_NFS_V3 is not set
1619 +# CONFIG_NFS_V4 is not set
1620  # CONFIG_NFSD is not set
1621  CONFIG_ROOT_NFS=y
1622  CONFIG_LOCKD=y
1623  # CONFIG_EXPORTFS is not set
1624 +CONFIG_SUNRPC=y
1625 +# CONFIG_SUNRPC_GSS is not set
1626  # CONFIG_SMB_FS is not set
1627  # CONFIG_CIFS is not set
1628  # CONFIG_NCP_FS is not set
1629  # CONFIG_CODA_FS is not set
1630 -CONFIG_SUNRPC=y
1631 +# CONFIG_INTERMEZZO_FS is not set
1632 +# CONFIG_AFS_FS is not set
1633  
1634  #
1635  # Partition Types
1636 @@ -614,6 +702,7 @@
1637  # CONFIG_SOLARIS_X86_PARTITION is not set
1638  # CONFIG_UNIXWARE_DISKLABEL is not set
1639  # CONFIG_LDM_PARTITION is not set
1640 +# CONFIG_NEC98_PARTITION is not set
1641  # CONFIG_SGI_PARTITION is not set
1642  # CONFIG_ULTRIX_PARTITION is not set
1643  # CONFIG_SUN_PARTITION is not set
1644 @@ -625,13 +714,6 @@
1645  # CONFIG_FB is not set
1646  
1647  #
1648 -# Console display driver support
1649 -#
1650 -# CONFIG_VGA_CONSOLE is not set
1651 -# CONFIG_MDA_CONSOLE is not set
1652 -CONFIG_DUMMY_CONSOLE=y
1653 -
1654 -#
1655  # Sound
1656  #
1657  # CONFIG_SOUND is not set
1658 @@ -654,6 +736,7 @@
1659  # USB support
1660  #
1661  # CONFIG_USB is not set
1662 +# CONFIG_USB_GADGET is not set
1663  
1664  #
1665  # Bluetooth support
1666 @@ -664,7 +747,7 @@
1667  # Kernel hacking
1668  #
1669  CONFIG_FRAME_POINTER=y
1670 -CONFIG_DEBUG_USER=y
1671 +# CONFIG_DEBUG_USER is not set
1672  # CONFIG_DEBUG_INFO is not set
1673  CONFIG_DEBUG_KERNEL=y
1674  # CONFIG_DEBUG_SLAB is not set
1675 @@ -673,7 +756,6 @@
1676  # CONFIG_DEBUG_WAITQ is not set
1677  CONFIG_DEBUG_BUGVERBOSE=y
1678  CONFIG_DEBUG_ERRORS=y
1679 -# CONFIG_KALLSYMS is not set
1680  CONFIG_DEBUG_LL=y
1681  
1682  #
1683 diff -Nru a/arch/arm/kernel/apm.c b/arch/arm/kernel/apm.c
1684 --- a/arch/arm/kernel/apm.c     Wed Mar 26 05:00:46 2003
1685 +++ b/arch/arm/kernel/apm.c     Sun Aug 31 16:14:08 2003
1686 @@ -26,6 +26,7 @@
1687  #include <linux/init.h>
1688  #include <linux/completion.h>
1689  
1690 +#include <asm/apm.h> /* apm_power_info */
1691  #include <asm/system.h>
1692  
1693  /*
1694 @@ -93,18 +94,7 @@
1695  
1696  static const char driver_version[] = "1.13";   /* no spaces */
1697  
1698 -/*
1699 - * This structure gets filled in by the machine specific 'get_power_status'
1700 - * implementation.  Any fields which are not set default to a safe value.
1701 - */
1702 -struct apm_power_info {
1703 -       unsigned char   ac_line_status;
1704 -       unsigned char   battery_status;
1705 -       unsigned char   battery_flag;
1706 -       unsigned char   battery_life;
1707 -       int             time;
1708 -       int             units;
1709 -};
1710 +
1711  
1712  /*
1713   * Compatibility cruft until the IPAQ people move over to the new
1714 @@ -388,18 +378,18 @@
1715  }
1716  
1717  static struct file_operations apm_bios_fops = {
1718 -       owner:          THIS_MODULE,
1719 -       read:           apm_read,
1720 -       poll:           apm_poll,
1721 -       ioctl:          apm_ioctl,
1722 -       open:           apm_open,
1723 -       release:        apm_release,
1724 +       .owner          = THIS_MODULE,
1725 +       .read           = apm_read,
1726 +       .poll           = apm_poll,
1727 +       .ioctl          = apm_ioctl,
1728 +       .open           = apm_open,
1729 +       .release        = apm_release,
1730  };
1731  
1732  static struct miscdevice apm_device = {
1733 -       minor:          APM_MINOR_DEV,
1734 -       name:           "apm_bios",
1735 -       fops:           &apm_bios_fops
1736 +       .minor          = APM_MINOR_DEV,
1737 +       .name           = "apm_bios",
1738 +       .fops           = &apm_bios_fops
1739  };
1740  
1741  
1742 diff -Nru a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
1743 --- a/arch/arm/kernel/bios32.c  Thu Jul 31 16:47:19 2003
1744 +++ b/arch/arm/kernel/bios32.c  Sun Aug 24 06:12:42 2003
1745 @@ -263,7 +263,7 @@
1746  void __devinit pcibios_update_irq(struct pci_dev *dev, int irq)
1747  {
1748         if (debug_pci)
1749 -               printk("PCI: Assigning IRQ %02d to %s\n", irq, dev->dev.name);
1750 +               printk("PCI: Assigning IRQ %02d to %s\n", irq, pci_name(dev));
1751         pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
1752  }
1753  
1754 @@ -362,6 +362,19 @@
1755                         isa_bridge = dev;
1756                         break;
1757  #endif
1758 +               case PCI_CLASS_BRIDGE_PCI:
1759 +                       pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &status);
1760 +                       status |= PCI_BRIDGE_CTL_PARITY|PCI_BRIDGE_CTL_MASTER_ABORT;
1761 +                       status &= ~(PCI_BRIDGE_CTL_BUS_RESET|PCI_BRIDGE_CTL_FAST_BACK);
1762 +                       pci_write_config_word(dev, PCI_BRIDGE_CONTROL, status);
1763 +                       break;
1764 +
1765 +               case PCI_CLASS_BRIDGE_CARDBUS:
1766 +                       pci_read_config_word(dev, PCI_CB_BRIDGE_CONTROL, &status);
1767 +                       status |= PCI_CB_BRIDGE_CTL_PARITY|PCI_CB_BRIDGE_CTL_MASTER_ABORT;
1768 +                       pci_write_config_word(dev, PCI_CB_BRIDGE_CONTROL, status);
1769 +                       break;
1770 +               }
1771         }
1772  
1773         /*
1774 diff -Nru a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c
1775 --- a/arch/arm/kernel/ecard.c   Fri Aug 15 15:22:53 2003
1776 +++ b/arch/arm/kernel/ecard.c   Sun Aug 24 05:44:40 2003
1777 @@ -896,7 +896,7 @@
1778  static ssize_t ecard_show_vendor(struct device *dev, char *buf)
1779  {
1780         struct expansion_card *ec = ECARD_DEV(dev);
1781 -       return sprintf(buf, "%u\n", ec->manufacturer);
1782 +       return sprintf(buf, "%u\n", ec->cid.manufacturer);
1783  }
1784  
1785  static DEVICE_ATTR(vendor, S_IRUGO, ecard_show_vendor, NULL);
1786 @@ -904,7 +904,7 @@
1787  static ssize_t ecard_show_device(struct device *dev, char *buf)
1788  {
1789         struct expansion_card *ec = ECARD_DEV(dev);
1790 -       return sprintf(buf, "%u\n", ec->product);
1791 +       return sprintf(buf, "%u\n", ec->cid.product);
1792  }
1793  
1794  static DEVICE_ATTR(device, S_IRUGO, ecard_show_device, NULL);
1795 diff -Nru a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
1796 --- a/arch/arm/kernel/entry-header.S    Tue Mar  4 16:47:50 2003
1797 +++ b/arch/arm/kernel/entry-header.S    Sun Aug 24 06:17:52 2003
1798 @@ -63,13 +63,7 @@
1799  #define S_OFF          8
1800  
1801         .macro  set_cpsr_c, reg, mode
1802 -#if 1
1803 -       /* broken binutils */
1804 -       mov     \reg, \mode
1805 -       msr     cpsr_c, \reg
1806 -#else
1807         msr     cpsr_c, \mode
1808 -#endif
1809         .endm
1810  
1811         .macro  disable_irq, temp
1812 diff -Nru a/arch/arm/kernel/pm.c b/arch/arm/kernel/pm.c
1813 --- a/arch/arm/kernel/pm.c      Sat Jun 21 03:42:03 2003
1814 +++ b/arch/arm/kernel/pm.c      Sun Aug 24 05:40:01 2003
1815 @@ -36,23 +36,7 @@
1816         if (ret != 0)
1817                 goto out;
1818  
1819 -       /*
1820 -        * Tell LDM devices we're going to suspend.
1821 -        */
1822 -       ret = device_suspend(4, SUSPEND_NOTIFY);
1823 -       if (ret != 0)
1824 -               goto resume_legacy;
1825 -
1826 -       /*
1827 -        * Disable, devices, and save state.
1828 -        */
1829 -       device_suspend(4, SUSPEND_DISABLE);
1830 -       device_suspend(4, SUSPEND_SAVE_STATE);
1831 -
1832 -       /*
1833 -        * Tell devices that they're going to be powered off.
1834 -        */
1835 -       device_suspend(4, SUSPEND_POWER_DOWN);
1836 +       device_suspend(3);
1837  
1838         local_irq_disable();
1839         leds_event(led_stop);
1840 @@ -62,21 +46,8 @@
1841         leds_event(led_start);
1842         local_irq_enable();
1843  
1844 -       /*
1845 -        * Tell devices that they now have power.
1846 -        */
1847 -       device_resume(RESUME_POWER_ON);
1848 -
1849 -       /*
1850 -        * Resume LDM devices.
1851 -        */
1852 -       device_resume(RESUME_RESTORE_STATE);
1853 -       device_resume(RESUME_ENABLE);
1854 +       device_resume();
1855  
1856 - resume_legacy:
1857 -       /*
1858 -        * Resume "legacy" devices.
1859 -        */
1860         pm_send_all(PM_RESUME, (void *)0);
1861  
1862   out:
1863 diff -Nru a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
1864 --- a/arch/arm/kernel/vmlinux.lds.S     Mon Aug  4 20:39:42 2003
1865 +++ b/arch/arm/kernel/vmlinux.lds.S     Sun Aug 24 04:26:29 2003
1866 @@ -1,21 +1,134 @@
1867 -#include <linux/config.h>
1868 -
1869 -#ifdef CONFIG_CPU_26
1870 -
1871 -#ifdef CONFIG_ROM_KERNEL
1872 -
1873 -#include "vmlinux-armo-rom.lds.in"
1874 -
1875 +/* ld script to make ARM Linux kernel
1876 + * taken from the i386 version by Russell King
1877 + * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
1878 + */
1879 +
1880 +#include <asm-generic/vmlinux.lds.h>
1881 +       
1882 +OUTPUT_ARCH(arm)
1883 +ENTRY(stext)
1884 +#ifndef __ARMEB__
1885 +jiffies = jiffies_64;
1886  #else
1887 -
1888 -#include "vmlinux-armo.lds.in"
1889 -
1890 -#endif
1891 -
1892 -#endif
1893 -
1894 -#ifdef CONFIG_CPU_32
1895 -
1896 -#include "vmlinux-armv.lds.in"
1897 -
1898 +jiffies = jiffies_64 + 4;
1899  #endif
1900 +SECTIONS
1901 +{
1902 +       . = TEXTADDR;
1903 +       .init : {                       /* Init code and data           */
1904 +               _stext = .;
1905 +               __init_begin = .;
1906 +                       _sinittext = .;
1907 +                       *(.init.text)
1908 +                       _einittext = .;
1909 +               __proc_info_begin = .;
1910 +                       *(.proc.info)
1911 +               __proc_info_end = .;
1912 +               __arch_info_begin = .;
1913 +                       *(.arch.info)
1914 +               __arch_info_end = .;
1915 +               __tagtable_begin = .;
1916 +                       *(.taglist)
1917 +               __tagtable_end = .;
1918 +                       *(.init.data)
1919 +               . = ALIGN(16);
1920 +               __setup_start = .;
1921 +                       *(.init.setup)
1922 +               __setup_end = .;
1923 +               __early_begin = .;
1924 +                       *(__early_param)
1925 +               __early_end = .;
1926 +               __start___param = .;
1927 +                       *(__param)
1928 +               __stop___param = .;
1929 +               __initcall_start = .;
1930 +                       *(.initcall1.init)
1931 +                       *(.initcall2.init)
1932 +                       *(.initcall3.init)
1933 +                       *(.initcall4.init)
1934 +                       *(.initcall5.init)
1935 +                       *(.initcall6.init)
1936 +                       *(.initcall7.init)
1937 +               __initcall_end = .;
1938 +               __con_initcall_start = .;
1939 +                       *(.con_initcall.init)
1940 +               __con_initcall_end = .;
1941 +               __security_initcall_start = .;
1942 +                       *(.security_initcall.init)
1943 +               __security_initcall_end = .;
1944 +               . = ALIGN(32);
1945 +               __initramfs_start = .;
1946 +                       usr/built-in.o(.init.ramfs)
1947 +               __initramfs_end = .;
1948 +               . = ALIGN(4096);
1949 +               __init_end = .;
1950 +       }
1951 +
1952 +       /DISCARD/ : {                   /* Exit code and data           */
1953 +               *(.exit.text)
1954 +               *(.exit.data)
1955 +               *(.exitcall.exit)
1956 +       }
1957 +
1958 +       .text : {                       /* Real text segment            */
1959 +               _text = .;              /* Text and read-only data      */
1960 +                       *(.text)
1961 +                       *(.fixup)
1962 +                       *(.gnu.warning)
1963 +                       *(.rodata)
1964 +                       *(.rodata.*)
1965 +                       *(.glue_7)
1966 +                       *(.glue_7t)
1967 +               *(.got)                 /* Global offset table          */
1968 +
1969 +               _etext = .;             /* End of text section          */
1970 +       }
1971 +
1972 +       . = ALIGN(16);
1973 +       __ex_table : {                  /* Exception table              */
1974 +               __start___ex_table = .;
1975 +                       *(__ex_table)
1976 +               __stop___ex_table = .;
1977 +       }
1978 +
1979 +       RODATA
1980 +
1981 +       . = ALIGN(8192);
1982 +
1983 +       .data : {
1984 +               /*
1985 +                * first, the init task union, aligned
1986 +                * to an 8192 byte boundary.
1987 +                */
1988 +               *(.init.task)
1989 +
1990 +               /*
1991 +                * then the cacheline aligned data
1992 +                */
1993 +               . = ALIGN(32);
1994 +               *(.data.cacheline_aligned)
1995 +
1996 +               /*
1997 +                * and the usual data section
1998 +                */
1999 +               *(.data)
2000 +               CONSTRUCTORS
2001 +
2002 +               _edata = .;
2003 +       }
2004 +
2005 +       .bss : {
2006 +               __bss_start = .;        /* BSS                          */
2007 +               *(.bss)
2008 +               *(COMMON)
2009 +               _end = . ;
2010 +       }
2011 +                                       /* Stabs debugging sections.    */
2012 +       .stab 0 : { *(.stab) }
2013 +       .stabstr 0 : { *(.stabstr) }
2014 +       .stab.excl 0 : { *(.stab.excl) }
2015 +       .stab.exclstr 0 : { *(.stab.exclstr) }
2016 +       .stab.index 0 : { *(.stab.index) }
2017 +       .stab.indexstr 0 : { *(.stab.indexstr) }
2018 +       .comment 0 : { *(.comment) }
2019 +}
2020 diff -Nru a/arch/arm/mach-footbridge/netwinder-pci.c b/arch/arm/mach-footbridge/netwinder-pci.c
2021 --- a/arch/arm/mach-footbridge/netwinder-pci.c  Thu Jul 31 16:47:19 2003
2022 +++ b/arch/arm/mach-footbridge/netwinder-pci.c  Sun Aug 24 04:37:15 2003
2023 @@ -36,8 +36,8 @@
2024                 return IRQ_NETWINDER_ETHER10;
2025  
2026         default:
2027 -               printk(KERN_ERR "PCI: unknown device in slot %s: %s\n",
2028 -                       pci_name(dev), dev->dev.name);
2029 +               printk(KERN_ERR "PCI: unknown device in slot %s\n",
2030 +                       pci_name(dev));
2031                 return 0;
2032         }
2033  }
2034 diff -Nru a/arch/arm/mach-iop3xx/iop321-time.c b/arch/arm/mach-iop3xx/iop321-time.c
2035 --- a/arch/arm/mach-iop3xx/iop321-time.c        Tue Apr 15 08:12:47 2003
2036 +++ b/arch/arm/mach-iop3xx/iop321-time.c        Wed Aug 13 16:46:20 2003
2037 @@ -51,7 +51,8 @@
2038         return usec;
2039  }
2040  
2041 -static void iop321_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2042 +static irqreturn_t
2043 +iop321_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2044  {
2045         u32 tisr;
2046  
2047 @@ -62,6 +63,8 @@
2048         asm volatile("mcr p6, 0, %0, c6, c1, 0" : : "r" (tisr));
2049  
2050         do_timer(regs);
2051 +
2052 +       return IRQ_HANDLED;
2053  }
2054  
2055  extern unsigned long (*gettimeoffset)(void);
2056 diff -Nru a/arch/arm/mach-iop3xx/iq80310-time.c b/arch/arm/mach-iop3xx/iq80310-time.c
2057 --- a/arch/arm/mach-iop3xx/iq80310-time.c       Mon Apr 21 15:43:40 2003
2058 +++ b/arch/arm/mach-iop3xx/iq80310-time.c       Wed Aug 13 16:46:20 2003
2059 @@ -88,7 +88,8 @@
2060  }
2061  
2062  
2063 -static void iq80310_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2064 +static irqreturn_t
2065 +iq80310_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2066  {
2067         volatile u_char *timer_en = (volatile u_char *)IQ80310_TIMER_EN;
2068  
2069 @@ -96,21 +97,9 @@
2070         *timer_en &= ~2;
2071         *timer_en |= 2;
2072  
2073 -       /*
2074 -        * AHEM..HACK
2075 -        *
2076 -        * Since the timer interrupt is cascaded through the CPLD and
2077 -        * the 80312 and the demux code calls do_IRQ, the irq count is
2078 -        * going to be at least 2 when we get here and this will cause the
2079 -        * kernel to increment the system tick counter even if we're
2080 -        * idle. This causes it to look like there's always 100% system
2081 -        * time, which is not the case.  To get around it, we just decrement
2082 -        * the IRQ count before calling do_timer. We increment it again
2083 -        * b/c otherwise it will go negative and than bad things happen.
2084 -        *
2085 -        * -DS
2086 -        */
2087         do_timer(regs);
2088 +
2089 +       return IRQ_HANDLED;
2090  }
2091  
2092  extern unsigned long (*gettimeoffset)(void);
2093 @@ -126,7 +115,9 @@
2094         volatile u_char *timer_en = (volatile u_char *)IQ80310_TIMER_EN;
2095  
2096         gettimeoffset = iq80310_gettimeoffset;
2097 +
2098         setup_irq(IRQ_IQ80310_TIMER, &timer_irq);
2099 +
2100         *timer_en = 0;
2101         iq80310_write_timer(LATCH);
2102         *timer_en |= 2;
2103 diff -Nru a/arch/arm/mach-sa1100/leds-simpad.c b/arch/arm/mach-sa1100/leds-simpad.c
2104 --- a/arch/arm/mach-sa1100/leds-simpad.c        Mon Feb  4 23:53:46 2002
2105 +++ b/arch/arm/mach-sa1100/leds-simpad.c        Thu Aug  7 11:40:46 2003
2106 @@ -9,6 +9,7 @@
2107  #include <asm/hardware.h>
2108  #include <asm/leds.h>
2109  #include <asm/system.h>
2110 +#include <asm/arch/simpad.h>
2111  
2112  #include "leds.h"
2113  
2114 diff -Nru a/arch/arm/mach-sa1100/leds.c b/arch/arm/mach-sa1100/leds.c
2115 --- a/arch/arm/mach-sa1100/leds.c       Wed Dec 11 06:27:36 2002
2116 +++ b/arch/arm/mach-sa1100/leds.c       Thu Aug  7 11:40:46 2003
2117 @@ -41,6 +41,8 @@
2118                 leds_event = adsbitsy_leds_event;
2119         if (machine_is_pt_system3())
2120                 leds_event = system3_leds_event;
2121 +       if (machine_is_simpad())
2122 +               leds_event = simpad_leds_event; /* what about machine registry? including led, apm... -zecke */
2123  
2124         leds_event(led_start);
2125         return 0;
2126 diff -Nru a/arch/arm/mach-sa1100/leds.h b/arch/arm/mach-sa1100/leds.h
2127 --- a/arch/arm/mach-sa1100/leds.h       Wed Dec 11 06:27:36 2002
2128 +++ b/arch/arm/mach-sa1100/leds.h       Thu Aug  7 11:40:46 2003
2129 @@ -11,3 +11,4 @@
2130  extern void graphicsmaster_leds_event(led_event_t evt);
2131  extern void adsbitsy_leds_event(led_event_t evt);
2132  extern void system3_leds_event(led_event_t evt);
2133 +extern void simpad_leds_event(led_event_t evt);
2134 diff -Nru a/arch/arm/vmlinux-armo.lds.in b/arch/arm/vmlinux-armo.lds.in
2135 --- a/arch/arm/vmlinux-armo.lds.in      Wed Jun 11 17:40:04 2003
2136 +++ /dev/null   Wed Dec 31 16:00:00 1969
2137 @@ -1,114 +0,0 @@
2138 -/* ld script to make ARM Linux kernel
2139 - * taken from the i386 version by Russell King
2140 - * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
2141 - */
2142 -
2143 -#include <asm-generic/vmlinux.lds.h>
2144 -       
2145 -OUTPUT_ARCH(arm)
2146 -ENTRY(stext)
2147 -jiffies = jiffies_64;
2148 -SECTIONS
2149 -{
2150 -       . = TEXTADDR;
2151 -       .init : {                       /* Init code and data           */
2152 -               _stext = .;
2153 -               __init_begin = .;
2154 -                       _sinittext = .;
2155 -                       *(.init.text)
2156 -                       _einittext = .;
2157 -               __proc_info_begin = .;
2158 -                       *(.proc.info)
2159 -               __proc_info_end = .;
2160 -               __arch_info_begin = .;
2161 -                       *(.arch.info)
2162 -               __arch_info_end = .;
2163 -               __tagtable_begin = .;
2164 -                       *(.taglist)
2165 -               __tagtable_end = .;
2166 -                       *(.init.data)
2167 -               . = ALIGN(16);
2168 -               __setup_start = .;
2169 -                       *(.init.setup)
2170 -               __setup_end = .;
2171 -               __initcall_start = .;
2172 -                       *(.initcall1.init)
2173 -                       *(.initcall2.init)
2174 -                       *(.initcall3.init)
2175 -                       *(.initcall4.init)
2176 -                       *(.initcall5.init)
2177 -                       *(.initcall6.init)
2178 -                       *(.initcall7.init)
2179 -               __initcall_end = .;
2180 -               __con_initcall_start = .;
2181 -                       *(.con_initcall.init)
2182 -               __con_initcall_end = .;
2183 -               SECURITY_INIT
2184 -               . = ALIGN(32768);
2185 -               __init_end = .;
2186 -       }
2187 -
2188 -       .init.task : {
2189 -               *(.init.task)
2190 -       }
2191 -
2192 -       /DISCARD/ : {                   /* Exit code and data           */
2193 -               *(.exit.text)
2194 -               *(.exit.data)
2195 -               *(.exitcall.exit)
2196 -       }
2197 -
2198 -       .text : {                       /* Real text segment            */
2199 -               _text = .;              /* Text and read-only data      */
2200 -                       *(.text)
2201 -                       *(.fixup)
2202 -                       *(.gnu.warning)
2203 -                       *(.rodata)
2204 -                       *(.rodata.*)
2205 -                       *(.glue_7)
2206 -                       *(.glue_7t)
2207 -               *(.got)                 /* Global offset table          */
2208 -
2209 -               _etext = .;             /* End of text section          */
2210 -       }
2211 -
2212 -       . = ALIGN(16);
2213 -       __ex_table : {                  /* Exception table              */
2214 -               __start___ex_table = .;
2215 -                       *(__ex_table)
2216 -               __stop___ex_table = .;
2217 -       }
2218 -
2219 -       RODATA
2220 -
2221 -       .data : {
2222 -               /*
2223 -                * The cacheline aligned data
2224 -                */
2225 -               . = ALIGN(32);
2226 -               *(.data.cacheline_aligned)
2227 -
2228 -               /*
2229 -                * and the usual data section
2230 -                */
2231 -               *(.data)
2232 -               CONSTRUCTORS
2233 -
2234 -               _edata = .;
2235 -       }
2236 -
2237 -       .bss : {
2238 -               __bss_start = .;        /* BSS                          */
2239 -               *(.bss)
2240 -               *(COMMON)
2241 -               _end = . ;
2242 -       }
2243 -                                       /* Stabs debugging sections.    */
2244 -       .stab 0 : { *(.stab) }
2245 -       .stabstr 0 : { *(.stabstr) }
2246 -       .stab.excl 0 : { *(.stab.excl) }
2247 -       .stab.exclstr 0 : { *(.stab.exclstr) }
2248 -       .stab.index 0 : { *(.stab.index) }
2249 -       .stab.indexstr 0 : { *(.stab.indexstr) }
2250 -       .comment 0 : { *(.comment) }
2251 -}
2252 diff -Nru a/arch/arm/vmlinux-armv.lds.in b/arch/arm/vmlinux-armv.lds.in
2253 --- a/arch/arm/vmlinux-armv.lds.in      Wed Jun 18 16:33:31 2003
2254 +++ /dev/null   Wed Dec 31 16:00:00 1969
2255 @@ -1,134 +0,0 @@
2256 -/* ld script to make ARM Linux kernel
2257 - * taken from the i386 version by Russell King
2258 - * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
2259 - */
2260 -
2261 -#include <asm-generic/vmlinux.lds.h>
2262 -       
2263 -OUTPUT_ARCH(arm)
2264 -ENTRY(stext)
2265 -#ifndef __ARMEB__
2266 -jiffies = jiffies_64;
2267 -#else
2268 -jiffies = jiffies_64 + 4;
2269 -#endif
2270 -SECTIONS
2271 -{
2272 -       . = TEXTADDR;
2273 -       .init : {                       /* Init code and data           */
2274 -               _stext = .;
2275 -               __init_begin = .;
2276 -                       _sinittext = .;
2277 -                       *(.init.text)
2278 -                       _einittext = .;
2279 -               __proc_info_begin = .;
2280 -                       *(.proc.info)
2281 -               __proc_info_end = .;
2282 -               __arch_info_begin = .;
2283 -                       *(.arch.info)
2284 -               __arch_info_end = .;
2285 -               __tagtable_begin = .;
2286 -                       *(.taglist)
2287 -               __tagtable_end = .;
2288 -                       *(.init.data)
2289 -               . = ALIGN(16);
2290 -               __setup_start = .;
2291 -                       *(.init.setup)
2292 -               __setup_end = .;
2293 -               __early_begin = .;
2294 -                       *(__early_param)
2295 -               __early_end = .;
2296 -               __start___param = .;
2297 -                       *(__param)
2298 -               __stop___param = .;
2299 -               __initcall_start = .;
2300 -                       *(.initcall1.init)
2301 -                       *(.initcall2.init)
2302 -                       *(.initcall3.init)
2303 -                       *(.initcall4.init)
2304 -                       *(.initcall5.init)
2305 -                       *(.initcall6.init)
2306 -                       *(.initcall7.init)
2307 -               __initcall_end = .;
2308 -               __con_initcall_start = .;
2309 -                       *(.con_initcall.init)
2310 -               __con_initcall_end = .;
2311 -               __security_initcall_start = .;
2312 -                       *(.security_initcall.init)
2313 -               __security_initcall_end = .;
2314 -               . = ALIGN(32);
2315 -               __initramfs_start = .;
2316 -                       usr/built-in.o(.init.ramfs)
2317 -               __initramfs_end = .;
2318 -               . = ALIGN(4096);
2319 -               __init_end = .;
2320 -       }
2321 -
2322 -       /DISCARD/ : {                   /* Exit code and data           */
2323 -               *(.exit.text)
2324 -               *(.exit.data)
2325 -               *(.exitcall.exit)
2326 -       }
2327 -
2328 -       .text : {                       /* Real text segment            */
2329 -               _text = .;              /* Text and read-only data      */
2330 -                       *(.text)
2331 -                       *(.fixup)
2332 -                       *(.gnu.warning)
2333 -                       *(.rodata)
2334 -                       *(.rodata.*)
2335 -                       *(.glue_7)
2336 -                       *(.glue_7t)
2337 -               *(.got)                 /* Global offset table          */
2338 -
2339 -               _etext = .;             /* End of text section          */
2340 -       }
2341 -
2342 -       . = ALIGN(16);
2343 -       __ex_table : {                  /* Exception table              */
2344 -               __start___ex_table = .;
2345 -                       *(__ex_table)
2346 -               __stop___ex_table = .;
2347 -       }
2348 -
2349 -       RODATA
2350 -
2351 -       . = ALIGN(8192);
2352 -
2353 -       .data : {
2354 -               /*
2355 -                * first, the init task union, aligned
2356 -                * to an 8192 byte boundary.
2357 -                */
2358 -               *(.init.task)
2359 -
2360 -               /*
2361 -                * then the cacheline aligned data
2362 -                */
2363 -               . = ALIGN(32);
2364 -               *(.data.cacheline_aligned)
2365 -
2366 -               /*
2367 -                * and the usual data section
2368 -                */
2369 -               *(.data)
2370 -               CONSTRUCTORS
2371 -
2372 -               _edata = .;
2373 -       }
2374 -
2375 -       .bss : {
2376 -               __bss_start = .;        /* BSS                          */
2377 -               *(.bss)
2378 -               *(COMMON)
2379 -               _end = . ;
2380 -       }
2381 -                                       /* Stabs debugging sections.    */
2382 -       .stab 0 : { *(.stab) }
2383 -       .stabstr 0 : { *(.stabstr) }
2384 -       .stab.excl 0 : { *(.stab.excl) }
2385 -       .stab.exclstr 0 : { *(.stab.exclstr) }
2386 -       .stab.index 0 : { *(.stab.index) }
2387 -       .stab.indexstr 0 : { *(.stab.indexstr) }
2388 -       .comment 0 : { *(.comment) }
2389 -}
2390 diff -Nru a/arch/arm26/Kconfig b/arch/arm26/Kconfig
2391 --- a/arch/arm26/Kconfig        Sat Aug  2 14:26:16 2003
2392 +++ b/arch/arm26/Kconfig        Sun Aug 31 16:14:22 2003
2393 @@ -146,39 +146,6 @@
2394           You may say N here if you are going to load the Acorn FPEmulator
2395           early in the bootup.
2396  
2397 -choice
2398 -       prompt "Kernel core (/proc/kcore) format"
2399 -       default KCORE_ELF
2400 -
2401 -config KCORE_ELF
2402 -       bool "ELF"
2403 -       ---help---
2404 -         If you enabled support for /proc file system then the file
2405 -         /proc/kcore will contain the kernel core image. This can be used
2406 -         in gdb:
2407 -
2408 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
2409 -
2410 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
2411 -         /proc/kcore appear in ELF core format as defined by the Executable
2412 -         and Linking Format specification. Selecting A.OUT will choose the
2413 -         old "a.out" format which may be necessary for some old versions
2414 -         of binutils or on some architectures.
2415 -
2416 -         This is especially useful if you have compiled the kernel with the
2417 -         "-g" option to preserve debugging information. It is mainly used
2418 -         for examining kernel data structures on the live kernel so if you
2419 -         don't understand what this means or are not a kernel hacker, just
2420 -         leave it at its default value ELF.
2421 -
2422 -config KCORE_AOUT
2423 -       bool "A.OUT"
2424 -       help
2425 -         Not necessary unless you're using a very out-of-date binutils
2426 -         version.  You probably want KCORE_ELF.
2427 -
2428 -endchoice
2429 -
2430  source "fs/Kconfig.binfmt"
2431  
2432  config PREEMPT
2433 diff -Nru a/arch/arm26/kernel/setup.c b/arch/arm26/kernel/setup.c
2434 --- a/arch/arm26/kernel/setup.c Thu Jul  3 15:03:57 2003
2435 +++ b/arch/arm26/kernel/setup.c Sun Aug 31 16:14:08 2003
2436 @@ -304,12 +304,12 @@
2437  
2438  #if defined(CONFIG_DUMMY_CONSOLE)
2439  struct screen_info screen_info = {
2440 - orig_video_lines:     30,
2441 - orig_video_cols:      80,
2442 - orig_video_mode:      0,
2443 - orig_video_ega_bx:    0,
2444 - orig_video_isVGA:     1,
2445 - orig_video_points:    8
2446 + .orig_video_lines     = 30,
2447 + .orig_video_cols      = 80,
2448 + .orig_video_mode      = 0,
2449 + .orig_video_ega_bx    = 0,
2450 + .orig_video_isVGA     = 1,
2451 + .orig_video_points    = 8
2452  };
2453  
2454  static int __init parse_tag_videotext(const struct tag *tag)
2455 diff -Nru a/arch/cris/arch-v10/drivers/eeprom.c b/arch/cris/arch-v10/drivers/eeprom.c
2456 --- a/arch/cris/arch-v10/drivers/eeprom.c       Fri Jul  4 03:27:37 2003
2457 +++ b/arch/cris/arch-v10/drivers/eeprom.c       Tue Aug 26 09:25:41 2003
2458 @@ -441,9 +441,9 @@
2459  static int eeprom_open(struct inode * inode, struct file * file)
2460  {
2461  
2462 -  if(minor(inode->i_rdev) != EEPROM_MINOR_NR)
2463 +  if(iminor(inode) != EEPROM_MINOR_NR)
2464       return -ENXIO;
2465 -  if(major(inode->i_rdev) != EEPROM_MAJOR_NR)
2466 +  if(imajor(inode) != EEPROM_MAJOR_NR)
2467       return -ENXIO;
2468  
2469    if( eeprom.size > 0 )
2470 diff -Nru a/arch/cris/arch-v10/drivers/gpio.c b/arch/cris/arch-v10/drivers/gpio.c
2471 --- a/arch/cris/arch-v10/drivers/gpio.c Fri Jul  4 03:27:37 2003
2472 +++ b/arch/cris/arch-v10/drivers/gpio.c Tue Aug 26 09:25:40 2003
2473 @@ -386,7 +386,7 @@
2474  gpio_open(struct inode *inode, struct file *filp)
2475  {
2476         struct gpio_private *priv;
2477 -       int p = minor(inode->i_rdev);
2478 +       int p = iminor(inode);
2479  
2480         if (p > GPIO_MINOR_LAST)
2481                 return -EINVAL;
2482 diff -Nru a/arch/cris/arch-v10/drivers/pcf8563.c b/arch/cris/arch-v10/drivers/pcf8563.c
2483 --- a/arch/cris/arch-v10/drivers/pcf8563.c      Wed Jul 23 07:38:45 2003
2484 +++ b/arch/cris/arch-v10/drivers/pcf8563.c      Sun Aug 31 16:14:08 2003
2485 @@ -57,10 +57,10 @@
2486  int pcf8563_release(struct inode *, struct file *);
2487  
2488  static struct file_operations pcf8563_fops = {
2489 -       owner: THIS_MODULE,
2490 -       ioctl: pcf8563_ioctl,
2491 -       open: pcf8563_open,
2492 -       release: pcf8563_release,
2493 +       .owner = THIS_MODULE,
2494 +       .ioctl = pcf8563_ioctl,
2495 +       .open = pcf8563_open,
2496 +       .release = pcf8563_release,
2497  };
2498  
2499  unsigned char
2500 diff -Nru a/arch/h8300/Kconfig b/arch/h8300/Kconfig
2501 --- a/arch/h8300/Kconfig        Thu Aug 21 08:42:22 2003
2502 +++ b/arch/h8300/Kconfig        Sun Aug 31 16:14:22 2003
2503 @@ -177,13 +177,6 @@
2504  
2505  menu "Executable file formats"
2506  
2507 -config KCORE_AOUT
2508 -       bool
2509 -       default y
2510 -
2511 -config KCORE_ELF
2512 -       default y
2513 -
2514  source "fs/Kconfig.binfmt"
2515  
2516  endmenu
2517 diff -Nru a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c
2518 --- a/arch/h8300/kernel/setup.c Sun Jul 27 20:40:08 2003
2519 +++ b/arch/h8300/kernel/setup.c Sun Aug 31 16:14:08 2003
2520 @@ -91,12 +91,12 @@
2521  }
2522  
2523  static const struct console gdb_console = {
2524 -       name:           "gdb_con",
2525 -       write:          gdb_console_output,
2526 -       device:         NULL,
2527 -       setup:          gdb_console_setup,
2528 -       flags:          CON_PRINTBUFFER,
2529 -       index:          -1,
2530 +       .name           = "gdb_con",
2531 +       .write          = gdb_console_output,
2532 +       .device         = NULL,
2533 +       .setup          = gdb_console_setup,
2534 +       .flags          = CON_PRINTBUFFER,
2535 +       .index          = -1,
2536  };
2537  #endif
2538  
2539 @@ -260,8 +260,8 @@
2540  }
2541  
2542  struct seq_operations cpuinfo_op = {
2543 -       start:  c_start,
2544 -       next:   c_next,
2545 -       stop:   c_stop,
2546 -       show:   show_cpuinfo,
2547 +       .start  = c_start,
2548 +       .next   = c_next,
2549 +       .stop   = c_stop,
2550 +       .show   = show_cpuinfo,
2551  };
2552 diff -Nru a/arch/h8300/platform/h8300h/ints.c b/arch/h8300/platform/h8300h/ints.c
2553 --- a/arch/h8300/platform/h8300h/ints.c Thu Aug 21 08:42:22 2003
2554 +++ b/arch/h8300/platform/h8300h/ints.c Wed Aug 27 08:10:22 2003
2555 @@ -32,15 +32,6 @@
2556  #include <asm/regs306x.h>
2557  #include <asm/errno.h>
2558  
2559 -#define EXT_IRQ0 12
2560 -#define EXT_IRQ1 13
2561 -#define EXT_IRQ2 14
2562 -#define EXT_IRQ3 15
2563 -#define EXT_IRQ4 16
2564 -#define EXT_IRQ5 17
2565 -#define EXT_IRQ6 18
2566 -#define EXT_IRQ7 19
2567 -
2568  /*
2569   * This structure has only 4 elements for speed reasons
2570   */
2571 @@ -57,17 +48,20 @@
2572  
2573  extern unsigned long *interrupt_redirect_table;
2574  
2575 +#define CPU_VECTOR ((unsigned long *)0x000000)
2576 +#define ADDR_MASK (0xffffff)
2577 +
2578  static inline unsigned long *get_vector_address(void)
2579  {
2580 -       unsigned long *rom_vector = (unsigned long *)0x000000;
2581 +       unsigned long *rom_vector = CPU_VECTOR;
2582         unsigned long base,tmp;
2583         int vec_no;
2584  
2585 -       base = rom_vector[EXT_IRQ0];
2586 +       base = rom_vector[EXT_IRQ0] & ADDR_MASK;
2587         
2588         /* check romvector format */
2589         for (vec_no = EXT_IRQ1; vec_no <= EXT_IRQ5; vec_no++) {
2590 -               if ((base+(vec_no - EXT_IRQ0)*4) != rom_vector[vec_no])
2591 +               if ((base+(vec_no - EXT_IRQ0)*4) != (rom_vector[vec_no] & ADDR_MASK))
2592                         return NULL;
2593         }
2594  
2595 @@ -171,7 +165,7 @@
2596                        irq, irq_list[irq]->devname);
2597         if (irq >= EXT_IRQ0 && irq <= EXT_IRQ5)
2598                 *(volatile unsigned char *)IER &= ~(1 << (irq - EXT_IRQ0));
2599 -       if ((irq_list[irq] & 0x80000000) == 0) {
2600 +       if (((unsigned long)irq_list[irq] & 0x80000000) == 0) {
2601                 kfree(irq_list[irq]);
2602                 irq_list[irq] = NULL;
2603         }
2604 @@ -241,8 +235,9 @@
2605  {
2606  }
2607  
2608 -static void __init enable_kmalloc(void)
2609 +static int __init enable_kmalloc(void)
2610  {
2611         use_kmalloc = 1;
2612 +       return 0;
2613  }
2614 -__initcall(enable_kmalloc);
2615 +core_initcall(enable_kmalloc);
2616 diff -Nru a/arch/h8300/platform/h8s/ints.c b/arch/h8300/platform/h8s/ints.c
2617 --- a/arch/h8300/platform/h8s/ints.c    Thu Aug 21 08:42:22 2003
2618 +++ b/arch/h8300/platform/h8s/ints.c    Wed Aug 27 08:10:22 2003
2619 @@ -33,23 +33,6 @@
2620  #include <asm/regs267x.h>
2621  #include <asm/errno.h>
2622  
2623 -#define EXT_IRQ0 16
2624 -#define EXT_IRQ1 17
2625 -#define EXT_IRQ2 18
2626 -#define EXT_IRQ3 19
2627 -#define EXT_IRQ4 20
2628 -#define EXT_IRQ5 21
2629 -#define EXT_IRQ6 22
2630 -#define EXT_IRQ7 23
2631 -#define EXT_IRQ8 24
2632 -#define EXT_IRQ9 25
2633 -#define EXT_IRQ10 26
2634 -#define EXT_IRQ11 27
2635 -#define EXT_IRQ12 28
2636 -#define EXT_IRQ13 29
2637 -#define EXT_IRQ14 30
2638 -#define EXT_IRQ15 31
2639 -
2640  /*
2641   * This structure has only 4 elements for speed reasons
2642   */
2643 @@ -95,17 +78,20 @@
2644  
2645  extern unsigned long *interrupt_redirect_table;
2646  
2647 +#define CPU_VECTOR ((unsigned long *)0x000000)
2648 +#define ADDR_MASK (0xffffff)
2649 +
2650  static inline unsigned long *get_vector_address(void)
2651  {
2652 -       volatile unsigned long *rom_vector = (unsigned long *)0x000000;
2653 +       volatile unsigned long *rom_vector = CPU_VECTOR;
2654         unsigned long base,tmp;
2655         int vec_no;
2656  
2657 -       base = rom_vector[EXT_IRQ0];
2658 +       base = rom_vector[EXT_IRQ0] & ADDR_MASK;
2659         
2660         /* check romvector format */
2661         for (vec_no = EXT_IRQ1; vec_no <= EXT_IRQ15; vec_no++) {
2662 -               if ((base+(vec_no - EXT_IRQ0)*4) != rom_vector[vec_no])
2663 +               if ((base+(vec_no - EXT_IRQ0)*4) != (rom_vector[vec_no] & ADDR_MASK))
2664                         return NULL;
2665         }
2666  
2667 @@ -307,4 +293,4 @@
2668         use_kmalloc = 1;
2669         return 0;
2670  }
2671 -__initcall(enable_kmalloc);
2672 +core_initcall(enable_kmalloc);
2673 diff -Nru a/arch/i386/Kconfig b/arch/i386/Kconfig
2674 --- a/arch/i386/Kconfig Wed Aug 20 12:16:36 2003
2675 +++ b/arch/i386/Kconfig Sun Aug 31 16:15:07 2003
2676 @@ -408,6 +408,17 @@
2677  
2678           Otherwise, say N.
2679  
2680 +config HPET_TIMER
2681 +       bool "HPET Timer Support"
2682 +       help
2683 +         This enables the use of the HPET for the kernel's internal timer.
2684 +         HPET is the next generation timer replacing legacy 8254s.
2685 +         You can safely choose Y here.  However, HPET will only be
2686 +         activated if the platform and the BIOS support this feature.
2687 +         Otherwise the 8254 will be used for timing services.
2688 +
2689 +         Choose N to continue using the legacy 8254 timer.
2690 +
2691  config SMP
2692         bool "Symmetric multi-processing support"
2693         ---help---
2694 @@ -1155,40 +1166,6 @@
2695  
2696  
2697  menu "Executable file formats"
2698 -
2699 -choice
2700 -       prompt "Kernel core (/proc/kcore) format"
2701 -       depends on PROC_FS
2702 -       default KCORE_ELF
2703 -
2704 -config KCORE_ELF
2705 -       bool "ELF"
2706 -       ---help---
2707 -         If you enabled support for /proc file system then the file
2708 -         /proc/kcore will contain the kernel core image. This can be used
2709 -         in gdb:
2710 -
2711 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
2712 -
2713 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
2714 -         /proc/kcore appear in ELF core format as defined by the Executable
2715 -         and Linking Format specification. Selecting A.OUT will choose the
2716 -         old "a.out" format which may be necessary for some old versions
2717 -         of binutils or on some architectures.
2718 -
2719 -         This is especially useful if you have compiled the kernel with the
2720 -         "-g" option to preserve debugging information. It is mainly used
2721 -         for examining kernel data structures on the live kernel so if you
2722 -         don't understand what this means or are not a kernel hacker, just
2723 -         leave it at its default value ELF.
2724 -
2725 -config KCORE_AOUT
2726 -       bool "A.OUT"
2727 -       help
2728 -         Not necessary unless you're using a very out-of-date binutils
2729 -         version.  You probably want KCORE_ELF.
2730 -
2731 -endchoice
2732  
2733  source "fs/Kconfig.binfmt"
2734  
2735 diff -Nru a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
2736 --- a/arch/i386/kernel/Makefile Mon Aug 18 11:16:59 2003
2737 +++ b/arch/i386/kernel/Makefile Sun Aug 31 16:14:50 2003
2738 @@ -31,6 +31,7 @@
2739  obj-$(CONFIG_MODULES)          += module.o
2740  obj-y                          += sysenter.o vsyscall.o
2741  obj-$(CONFIG_ACPI_SRAT)        += srat.o
2742 +obj-$(CONFIG_HPET_TIMER)       += time_hpet.o
2743  
2744  EXTRA_AFLAGS   := -traditional
2745  
2746 diff -Nru a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
2747 --- a/arch/i386/kernel/acpi/boot.c      Thu Aug 21 11:08:59 2003
2748 +++ b/arch/i386/kernel/acpi/boot.c      Sun Aug 31 16:14:49 2003
2749 @@ -41,6 +41,7 @@
2750  #define PREFIX                 "ACPI: "
2751  
2752  extern int acpi_disabled;
2753 +extern int acpi_irq;
2754  extern int acpi_ht;
2755  
2756  int acpi_lapic = 0;
2757 @@ -269,6 +270,27 @@
2758         return 0;
2759  }
2760  
2761 +#ifdef CONFIG_HPET_TIMER
2762 +extern unsigned long hpet_address;
2763 +
2764 +static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
2765 +{
2766 +       struct acpi_table_hpet *hpet_tbl;
2767 +
2768 +       hpet_tbl = __va(phys);
2769 +
2770 +       if (hpet_tbl->addr.space_id != ACPI_SPACE_MEM) {
2771 +               printk(KERN_WARNING PREFIX "HPET timers must be located in "
2772 +                      "memory.\n");
2773 +               return -1;
2774 +       }
2775 +
2776 +       hpet_address = hpet_tbl->addr.addrl;
2777 +       printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", hpet_tbl->id,
2778 +              hpet_address);
2779 +       return 0;
2780 +}
2781 +#endif
2782  
2783  unsigned long __init
2784  acpi_find_rsdp (void)
2785 @@ -407,7 +429,7 @@
2786          * If MPS is present, it will handle them,
2787          * otherwise the system will stay in PIC mode
2788          */
2789 -       if (acpi_disabled) {
2790 +       if (acpi_disabled || !acpi_irq) {
2791                 return 1;
2792          }
2793  
2794 @@ -457,6 +479,9 @@
2795                 smp_found_config = 1;
2796                 clustered_apic_check();
2797         }
2798 +#endif
2799 +#ifdef CONFIG_HPET_TIMER
2800 +       acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
2801  #endif
2802  
2803         return 0;
2804 diff -Nru a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
2805 --- a/arch/i386/kernel/apic.c   Mon Aug 18 22:27:07 2003
2806 +++ b/arch/i386/kernel/apic.c   Fri Aug 29 03:51:17 2003
2807 @@ -34,6 +34,7 @@
2808  #include <asm/pgalloc.h>
2809  #include <asm/desc.h>
2810  #include <asm/arch_hooks.h>
2811 +#include <asm/hpet.h>
2812  
2813  #include <mach_apic.h>
2814  
2815 @@ -779,7 +780,8 @@
2816         return count;
2817  }
2818  
2819 -void __init wait_8254_wraparound(void)
2820 +/* next tick in 8254 can be caught by catching timer wraparound */
2821 +static void __init wait_8254_wraparound(void)
2822  {
2823         unsigned int curr_count, prev_count=~0;
2824         int delta;
2825 @@ -801,6 +803,12 @@
2826  }
2827  
2828  /*
2829 + * Default initialization for 8254 timers. If we use other timers like HPET,
2830 + * we override this later
2831 + */
2832 +void (*wait_timer_tick)(void) = wait_8254_wraparound;
2833 +
2834 +/*
2835   * This function sets up the local APIC timer, with a timeout of
2836   * 'clocks' APIC bus clock. During calibration we actually call
2837   * this function twice on the boot CPU, once with a bogus timeout
2838 @@ -841,7 +849,7 @@
2839         /*
2840          * Wait for IRQ0's slice:
2841          */
2842 -       wait_8254_wraparound();
2843 +       wait_timer_tick();
2844  
2845         __setup_APIC_LVTT(clocks);
2846  
2847 @@ -884,7 +892,7 @@
2848          * (the current tick might have been already half done)
2849          */
2850  
2851 -       wait_8254_wraparound();
2852 +       wait_timer_tick();
2853  
2854         /*
2855          * We wrapped around just now. Let's start:
2856 @@ -897,7 +905,7 @@
2857          * Let's wait LOOPS wraprounds:
2858          */
2859         for (i = 0; i < LOOPS; i++)
2860 -               wait_8254_wraparound();
2861 +               wait_timer_tick();
2862  
2863         tt2 = apic_read(APIC_TMCCT);
2864         if (cpu_has_tsc)
2865 diff -Nru a/arch/i386/kernel/cpu/mtrr/if.c b/arch/i386/kernel/cpu/mtrr/if.c
2866 --- a/arch/i386/kernel/cpu/mtrr/if.c    Wed May 14 23:43:54 2003
2867 +++ b/arch/i386/kernel/cpu/mtrr/if.c    Sun Aug 31 16:14:43 2003
2868 @@ -17,6 +17,22 @@
2869  
2870  #define FILE_FCOUNT(f) (((struct seq_file *)((f)->private_data))->private)
2871  
2872 +static char *mtrr_strings[MTRR_NUM_TYPES] =
2873 +{
2874 +    "uncachable",               /* 0 */
2875 +    "write-combining",          /* 1 */
2876 +    "?",                        /* 2 */
2877 +    "?",                        /* 3 */
2878 +    "write-through",            /* 4 */
2879 +    "write-protect",            /* 5 */
2880 +    "write-back",               /* 6 */
2881 +};
2882 +
2883 +char *mtrr_attrib_to_str(int x)
2884 +{
2885 +       return (x <= 6) ? mtrr_strings[x] : "?";
2886 +}
2887 +
2888  static int
2889  mtrr_file_add(unsigned long base, unsigned long size,
2890               unsigned int type, char increment, struct file *file, int page)
2891 @@ -300,11 +316,6 @@
2892  
2893  #  endif                       /*  CONFIG_PROC_FS  */
2894  
2895 -char * attrib_to_str(int x)
2896 -{
2897 -       return (x <= 6) ? mtrr_strings[x] : "?";
2898 -}
2899 -
2900  static int mtrr_seq_show(struct seq_file *seq, void *offset)
2901  {
2902         char factor;
2903 @@ -332,7 +343,7 @@
2904                         len += seq_printf(seq, 
2905                                    "reg%02i: base=0x%05lx000 (%4liMB), size=%4i%cB: %s, count=%d\n",
2906                              i, base, base >> (20 - PAGE_SHIFT), size, factor,
2907 -                            attrib_to_str(type), usage_table[i]);
2908 +                            mtrr_attrib_to_str(type), usage_table[i]);
2909                 }
2910         }
2911         return 0;
2912 diff -Nru a/arch/i386/kernel/cpu/mtrr/main.c b/arch/i386/kernel/cpu/mtrr/main.c
2913 --- a/arch/i386/kernel/cpu/mtrr/main.c  Thu Aug 21 11:48:14 2003
2914 +++ b/arch/i386/kernel/cpu/mtrr/main.c  Sun Aug 31 16:14:43 2003
2915 @@ -111,11 +111,6 @@
2916         num_var_ranges = config & 0xff;
2917  }
2918  
2919 -static char * attrib_to_str(int x)
2920 -{
2921 -       return (x <= 6) ? mtrr_strings[x] : "?";
2922 -}
2923 -
2924  static void init_table(void)
2925  {
2926         int i, max;
2927 @@ -362,8 +357,8 @@
2928                         if (type == MTRR_TYPE_UNCACHABLE)
2929                                 continue;
2930                         printk (KERN_WARNING "mtrr: type mismatch for %lx000,%lx000 old: %s new: %s\n",
2931 -                            base, size, attrib_to_str(ltype),
2932 -                            attrib_to_str(type));
2933 +                            base, size, mtrr_attrib_to_str(ltype),
2934 +                            mtrr_attrib_to_str(type));
2935                         goto out;
2936                 }
2937                 if (increment)
2938 @@ -703,16 +698,4 @@
2939         return -ENXIO;
2940  }
2941  
2942 -char *mtrr_strings[MTRR_NUM_TYPES] =
2943 -{
2944 -    "uncachable",               /* 0 */
2945 -    "write-combining",          /* 1 */
2946 -    "?",                        /* 2 */
2947 -    "?",                        /* 3 */
2948 -    "write-through",            /* 4 */
2949 -    "write-protect",            /* 5 */
2950 -    "write-back",               /* 6 */
2951 -};
2952 -
2953  subsys_initcall(mtrr_init);
2954 -
2955 diff -Nru a/arch/i386/kernel/cpu/mtrr/mtrr.h b/arch/i386/kernel/cpu/mtrr/mtrr.h
2956 --- a/arch/i386/kernel/cpu/mtrr/mtrr.h  Wed Nov 27 22:37:22 2002
2957 +++ b/arch/i386/kernel/cpu/mtrr/mtrr.h  Sun Aug 31 16:14:43 2003
2958 @@ -95,5 +95,6 @@
2959  
2960  void finalize_mtrr_state(void);
2961  void mtrr_state_warn(void);
2962 +char *mtrr_attrib_to_str(int x);
2963  
2964  extern char * mtrr_if_name[];
2965 diff -Nru a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c
2966 --- a/arch/i386/kernel/cpuid.c  Mon Aug 18 19:46:23 2003
2967 +++ b/arch/i386/kernel/cpuid.c  Tue Aug 26 09:25:40 2003
2968 @@ -115,7 +115,7 @@
2969    u32 data[4];
2970    size_t rv;
2971    u32 reg = *ppos;
2972 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
2973 +  int cpu = iminor(file->f_dentry->d_inode);
2974    
2975    if ( count % 16 )
2976      return -EINVAL; /* Invalid chunk size */
2977 @@ -133,7 +133,7 @@
2978  
2979  static int cpuid_open(struct inode *inode, struct file *file)
2980  {
2981 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
2982 +  int cpu = iminor(file->f_dentry->d_inode);
2983    struct cpuinfo_x86 *c = &(cpu_data)[cpu];
2984  
2985    if (!cpu_online(cpu))
2986 diff -Nru a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c
2987 --- a/arch/i386/kernel/mpparse.c        Tue Aug 19 21:21:36 2003
2988 +++ b/arch/i386/kernel/mpparse.c        Sun Aug 31 16:14:25 2003
2989 @@ -850,7 +850,7 @@
2990                         return i;
2991         }
2992  
2993 -       printk(KERN_ERR "ERROR: Unable to locate IOAPIC for IRQ %d/n", irq);
2994 +       printk(KERN_ERR "ERROR: Unable to locate IOAPIC for IRQ %d\n", irq);
2995  
2996         return -1;
2997  }
2998 diff -Nru a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c
2999 --- a/arch/i386/kernel/msr.c    Mon Aug 18 19:46:23 2003
3000 +++ b/arch/i386/kernel/msr.c    Tue Aug 26 09:25:40 2003
3001 @@ -194,7 +194,7 @@
3002    u32 data[2];
3003    size_t rv;
3004    u32 reg = *ppos;
3005 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
3006 +  int cpu = iminor(file->f_dentry->d_inode);
3007    int err;
3008  
3009    if ( count % 8 )
3010 @@ -219,7 +219,7 @@
3011    u32 data[2];
3012    size_t rv;
3013    u32 reg = *ppos;
3014 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
3015 +  int cpu = iminor(file->f_dentry->d_inode);
3016    int err;
3017  
3018    if ( count % 8 )
3019 @@ -239,7 +239,7 @@
3020  
3021  static int msr_open(struct inode *inode, struct file *file)
3022  {
3023 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
3024 +  int cpu = iminor(file->f_dentry->d_inode);
3025    struct cpuinfo_x86 *c = &(cpu_data)[cpu];
3026    
3027    if (!cpu_online(cpu))
3028 diff -Nru a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
3029 --- a/arch/i386/kernel/process.c        Wed Aug 20 10:43:52 2003
3030 +++ b/arch/i386/kernel/process.c        Tue Sep  2 00:37:21 2003
3031 @@ -452,7 +452,7 @@
3032  
3033         /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
3034  
3035 -       unlazy_fpu(prev_p);
3036 +       __unlazy_fpu(prev_p);
3037  
3038         /*
3039          * Reload esp0, LDT and the page table pointer:
3040 diff -Nru a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
3041 --- a/arch/i386/kernel/setup.c  Thu Aug 21 11:08:59 2003
3042 +++ b/arch/i386/kernel/setup.c  Sun Aug 31 16:14:11 2003
3043 @@ -71,6 +71,7 @@
3044  EXPORT_SYMBOL(acpi_disabled);
3045  
3046  #ifdef CONFIG_ACPI_BOOT
3047 +       int acpi_irq __initdata = 1;    /* enable IRQ */
3048         int acpi_ht __initdata = 1;     /* enable HT */
3049  #endif
3050  
3051 @@ -542,6 +543,11 @@
3052                 else if (!memcmp(from, "acpi=ht", 7)) {
3053                         acpi_ht = 1;
3054                         if (!acpi_force) acpi_disabled = 1;
3055 +               }
3056 +
3057 +               /* "pci=noacpi" disables ACPI interrupt routing */
3058 +               else if (!memcmp(from, "pci=noacpi", 10)) {
3059 +                       acpi_irq = 0;
3060                 }
3061  
3062  #ifdef CONFIG_X86_LOCAL_APIC
3063 diff -Nru a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
3064 --- a/arch/i386/kernel/time.c   Thu Jul 10 22:22:57 2003
3065 +++ b/arch/i386/kernel/time.c   Fri Aug 29 03:51:17 2003
3066 @@ -60,6 +60,8 @@
3067  #include <linux/timex.h>
3068  #include <linux/config.h>
3069  
3070 +#include <asm/hpet.h>
3071 +
3072  #include <asm/arch_hooks.h>
3073  
3074  #include "io_ports.h"
3075 @@ -291,8 +293,38 @@
3076  
3077  device_initcall(time_init_device);
3078  
3079 +#ifdef CONFIG_HPET_TIMER
3080 +extern void (*late_time_init)(void);
3081 +/* Duplicate of time_init() below, with hpet_enable part added */
3082 +void __init hpet_time_init(void)
3083 +{
3084 +       xtime.tv_sec = get_cmos_time();
3085 +       wall_to_monotonic.tv_sec = -xtime.tv_sec;
3086 +       xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
3087 +       wall_to_monotonic.tv_nsec = -xtime.tv_nsec;
3088 +
3089 +       if (hpet_enable() >= 0) {
3090 +               printk("Using HPET for base-timer\n");
3091 +       }
3092 +
3093 +       cur_timer = select_timer();
3094 +       time_init_hook();
3095 +}
3096 +#endif
3097 +
3098  void __init time_init(void)
3099  {
3100 +#ifdef CONFIG_HPET_TIMER
3101 +       if (is_hpet_capable()) {
3102 +               /*
3103 +                * HPET initialization needs to do memory-mapped io. So, let
3104 +                * us do a late initialization after mem_init().
3105 +                */
3106 +               late_time_init = hpet_time_init;
3107 +               return;
3108 +       }
3109 +#endif
3110 +
3111         xtime.tv_sec = get_cmos_time();
3112         wall_to_monotonic.tv_sec = -xtime.tv_sec;
3113         xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
3114 diff -Nru a/arch/i386/kernel/time_hpet.c b/arch/i386/kernel/time_hpet.c
3115 --- /dev/null   Wed Dec 31 16:00:00 1969
3116 +++ b/arch/i386/kernel/time_hpet.c      Sun Aug 31 16:15:40 2003
3117 @@ -0,0 +1,392 @@
3118 +/*
3119 + *  linux/arch/i386/kernel/time_hpet.c
3120 + *  This code largely copied from arch/x86_64/kernel/time.c
3121 + *  See that file for credits.
3122 + *
3123 + *  2003-06-30    Venkatesh Pallipadi - Additional changes for HPET support
3124 + */
3125 +
3126 +#include <linux/errno.h>
3127 +#include <linux/kernel.h>
3128 +#include <linux/param.h>
3129 +#include <linux/string.h>
3130 +#include <linux/init.h>
3131 +#include <linux/smp.h>
3132 +
3133 +#include <asm/timer.h>
3134 +#include <asm/fixmap.h>
3135 +#include <asm/apic.h>
3136 +
3137 +#include <linux/timex.h>
3138 +#include <linux/config.h>
3139 +
3140 +#include <asm/hpet.h>
3141 +
3142 +unsigned long hpet_period;     /* fsecs / HPET clock */
3143 +unsigned long hpet_tick;       /* hpet clks count per tick */
3144 +unsigned long hpet_address;    /* hpet memory map physical address */
3145 +
3146 +static int use_hpet;           /* can be used for runtime check of hpet */
3147 +static int boot_hpet_disable;  /* boottime override for HPET timer */
3148 +static unsigned long hpet_virt_address;        /* hpet kernel virtual address */
3149 +
3150 +#define FSEC_TO_USEC (1000000000UL)
3151 +
3152 +int hpet_readl(unsigned long a)
3153 +{
3154 +       return readl(hpet_virt_address + a);
3155 +}
3156 +
3157 +void hpet_writel(unsigned long d, unsigned long a)
3158 +{
3159 +       writel(d, hpet_virt_address + a);
3160 +}
3161 +
3162 +#ifdef CONFIG_X86_LOCAL_APIC
3163 +/*
3164 + * HPET counters dont wrap around on every tick. They just change the
3165 + * comparator value and continue. Next tick can be caught by checking
3166 + * for a change in the comparator value. Used in apic.c.
3167 + */
3168 +void __init wait_hpet_tick(void)
3169 +{
3170 +       unsigned int start_cmp_val, end_cmp_val;
3171 +
3172 +       start_cmp_val = hpet_readl(HPET_T0_CMP);
3173 +       do {
3174 +               end_cmp_val = hpet_readl(HPET_T0_CMP);
3175 +       } while (start_cmp_val == end_cmp_val);
3176 +}
3177 +#endif
3178 +
3179 +/*
3180 + * Check whether HPET was found by ACPI boot parse. If yes setup HPET
3181 + * counter 0 for kernel base timer.
3182 + */
3183 +int __init hpet_enable(void)
3184 +{
3185 +       unsigned int cfg, id;
3186 +       unsigned long tick_fsec_low, tick_fsec_high; /* tick in femto sec */
3187 +       unsigned long hpet_tick_rem;
3188 +
3189 +       if (boot_hpet_disable)
3190 +               return -1;
3191 +
3192 +       if (!hpet_address) {
3193 +               return -1;
3194 +       }
3195 +       hpet_virt_address = (unsigned long) ioremap_nocache(hpet_address,
3196 +                                                           HPET_MMAP_SIZE);
3197 +       /*
3198 +        * Read the period, compute tick and quotient.
3199 +        */
3200 +       id = hpet_readl(HPET_ID);
3201 +
3202 +       /*
3203 +        * We are checking for value '1' or more in number field.
3204 +        * So, we are OK with HPET_EMULATE_RTC part too, where we need
3205 +        * to have atleast 2 timers.
3206 +        */
3207 +       if (!(id & HPET_ID_NUMBER) ||
3208 +           !(id & HPET_ID_LEGSUP))
3209 +               return -1;
3210 +
3211 +       if (((id & HPET_ID_VENDOR) >> HPET_ID_VENDOR_SHIFT) !=
3212 +                               HPET_ID_VENDOR_8086)
3213 +               return -1;
3214 +
3215 +       hpet_period = hpet_readl(HPET_PERIOD);
3216 +       if ((hpet_period < HPET_MIN_PERIOD) || (hpet_period > HPET_MAX_PERIOD))
3217 +               return -1;
3218 +
3219 +       /*
3220 +        * 64 bit math
3221 +        * First changing tick into fsec
3222 +        * Then 64 bit div to find number of hpet clk per tick
3223 +        */
3224 +       ASM_MUL64_REG(tick_fsec_low, tick_fsec_high,
3225 +                       KERNEL_TICK_USEC, FSEC_TO_USEC);
3226 +       ASM_DIV64_REG(hpet_tick, hpet_tick_rem,
3227 +                       hpet_period, tick_fsec_low, tick_fsec_high);
3228 +
3229 +       if (hpet_tick_rem > (hpet_period >> 1))
3230 +               hpet_tick++; /* rounding the result */
3231 +
3232 +       /*
3233 +        * Stop the timers and reset the main counter.
3234 +        */
3235 +       cfg = hpet_readl(HPET_CFG);
3236 +       cfg &= ~HPET_CFG_ENABLE;
3237 +       hpet_writel(cfg, HPET_CFG);
3238 +       hpet_writel(0, HPET_COUNTER);
3239 +       hpet_writel(0, HPET_COUNTER + 4);
3240 +
3241 +       /*
3242 +        * Set up timer 0, as periodic with first interrupt to happen at
3243 +        * hpet_tick, and period also hpet_tick.
3244 +        */
3245 +       cfg = hpet_readl(HPET_T0_CFG);
3246 +       cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC |
3247 +              HPET_TN_SETVAL | HPET_TN_32BIT;
3248 +       hpet_writel(cfg, HPET_T0_CFG);
3249 +       hpet_writel(hpet_tick, HPET_T0_CMP);
3250 +
3251 +       /*
3252 +        * Go!
3253 +        */
3254 +       cfg = hpet_readl(HPET_CFG);
3255 +       cfg |= HPET_CFG_ENABLE | HPET_CFG_LEGACY;
3256 +       hpet_writel(cfg, HPET_CFG);
3257 +
3258 +       use_hpet = 1;
3259 +#ifdef CONFIG_X86_LOCAL_APIC
3260 +       wait_timer_tick = wait_hpet_tick;
3261 +#endif
3262 +       return 0;
3263 +}
3264 +
3265 +int is_hpet_enabled(void)
3266 +{
3267 +       return use_hpet;
3268 +}
3269 +
3270 +int is_hpet_capable(void)
3271 +{
3272 +       if (!boot_hpet_disable && hpet_address)
3273 +               return 1;
3274 +       return 0;
3275 +}
3276 +
3277 +static int __init hpet_setup(char* str)
3278 +{
3279 +       if (str) {
3280 +               if (!strncmp("disable", str, 7))
3281 +                       boot_hpet_disable = 1;
3282 +       }
3283 +       return 1;
3284 +}
3285 +
3286 +__setup("hpet=", hpet_setup);
3287 +
3288 +#ifdef CONFIG_HPET_EMULATE_RTC
3289 +/* HPET in LegacyReplacement Mode eats up RTC interrupt line. When, HPET
3290 + * is enabled, we support RTC interrupt functionality in software.
3291 + * RTC has 3 kinds of interrupts:
3292 + * 1) Update Interrupt - generate an interrupt, every sec, when RTC clock
3293 + *    is updated
3294 + * 2) Alarm Interrupt - generate an interrupt at a specific time of day
3295 + * 3) Periodic Interrupt - generate periodic interrupt, with frequencies
3296 + *    2Hz-8192Hz (2Hz-64Hz for non-root user) (all freqs in powers of 2)
3297 + * (1) and (2) above are implemented using polling at a frequency of
3298 + * 64 Hz. The exact frequency is a tradeoff between accuracy and interrupt
3299 + * overhead. (DEFAULT_RTC_INT_FREQ)
3300 + * For (3), we use interrupts at 64Hz or user specified periodic
3301 + * frequency, whichever is higher.
3302 + */
3303 +#include <linux/mc146818rtc.h>
3304 +#include <linux/rtc.h>
3305 +
3306 +extern irqreturn_t rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs);
3307 +extern void get_rtc_time(struct rtc_time *rtc_tm);
3308 +
3309 +#define DEFAULT_RTC_INT_FREQ   64
3310 +#define RTC_NUM_INTS           1
3311 +
3312 +static unsigned long UIE_on;
3313 +static unsigned long prev_update_sec;
3314 +
3315 +static unsigned long AIE_on;
3316 +static struct rtc_time alarm_time;
3317 +
3318 +static unsigned long PIE_on;
3319 +static unsigned long PIE_freq = DEFAULT_RTC_INT_FREQ;
3320 +static unsigned long PIE_count;
3321 +
3322 +static unsigned long hpet_rtc_int_freq; /* RTC interrupt frequency */
3323 +
3324 +/*
3325 + * Timer 1 for RTC, we do not use periodic interrupt feature,
3326 + * even if HPET supports periodic interrupts on Timer 1.
3327 + * The reason being, to set up a periodic interrupt in HPET, we need to
3328 + * stop the main counter. And if we do that everytime someone diables/enables
3329 + * RTC, we will have adverse effect on main kernel timer running on Timer 0.
3330 + * So, for the time being, simulate the periodic interrupt in software.
3331 + *
3332 + * hpet_rtc_timer_init() is called for the first time and during subsequent
3333 + * interuppts reinit happens through hpet_rtc_timer_reinit().
3334 + */
3335 +int hpet_rtc_timer_init(void)
3336 +{
3337 +       unsigned int cfg, cnt;
3338 +       unsigned long flags;
3339 +
3340 +       if (!is_hpet_enabled())
3341 +               return 0;
3342 +       /*
3343 +        * Set the counter 1 and enable the interrupts.
3344 +        */
3345 +       if (PIE_on && (PIE_freq > DEFAULT_RTC_INT_FREQ))
3346 +               hpet_rtc_int_freq = PIE_freq;
3347 +       else
3348 +               hpet_rtc_int_freq = DEFAULT_RTC_INT_FREQ;
3349 +
3350 +       local_irq_save(flags);
3351 +       cnt = hpet_readl(HPET_COUNTER);
3352 +       cnt += ((hpet_tick*HZ)/hpet_rtc_int_freq);
3353 +       hpet_writel(cnt, HPET_T1_CMP);
3354 +       local_irq_restore(flags);
3355 +
3356 +       cfg = hpet_readl(HPET_T1_CFG);
3357 +       cfg |= HPET_TN_ENABLE | HPET_TN_SETVAL | HPET_TN_32BIT;
3358 +       hpet_writel(cfg, HPET_T1_CFG);
3359 +
3360 +       return 1;
3361 +}
3362 +
3363 +static void hpet_rtc_timer_reinit(void)
3364 +{
3365 +       unsigned int cfg, cnt;
3366 +
3367 +       if (!(PIE_on | AIE_on | UIE_on))
3368 +               return;
3369 +
3370 +       if (PIE_on && (PIE_freq > DEFAULT_RTC_INT_FREQ))
3371 +               hpet_rtc_int_freq = PIE_freq;
3372 +       else
3373 +               hpet_rtc_int_freq = DEFAULT_RTC_INT_FREQ;
3374 +
3375 +       /* It is more accurate to use the comparator value than current count.*/
3376 +       cnt = hpet_readl(HPET_T1_CMP);
3377 +       cnt += hpet_tick*HZ/hpet_rtc_int_freq;
3378 +       hpet_writel(cnt, HPET_T1_CMP);
3379 +
3380 +       cfg = hpet_readl(HPET_T1_CFG);
3381 +       cfg |= HPET_TN_ENABLE | HPET_TN_SETVAL | HPET_TN_32BIT;
3382 +       hpet_writel(cfg, HPET_T1_CFG);
3383 +
3384 +       return;
3385 +}
3386 +
3387 +/*
3388 + * The functions below are called from rtc driver.
3389 + * Return 0 if HPET is not being used.
3390 + * Otherwise do the necessary changes and return 1.
3391 + */
3392 +int hpet_mask_rtc_irq_bit(unsigned long bit_mask)
3393 +{
3394 +       if (!is_hpet_enabled())
3395 +               return 0;
3396 +
3397 +       if (bit_mask & RTC_UIE)
3398 +               UIE_on = 0;
3399 +       if (bit_mask & RTC_PIE)
3400 +               PIE_on = 0;
3401 +       if (bit_mask & RTC_AIE)
3402 +               AIE_on = 0;
3403 +
3404 +       return 1;
3405 +}
3406 +
3407 +int hpet_set_rtc_irq_bit(unsigned long bit_mask)
3408 +{
3409 +       int timer_init_reqd = 0;
3410 +
3411 +       if (!is_hpet_enabled())
3412 +               return 0;
3413 +
3414 +       if (!(PIE_on | AIE_on | UIE_on))
3415 +               timer_init_reqd = 1;
3416 +
3417 +       if (bit_mask & RTC_UIE) {
3418 +               UIE_on = 1;
3419 +       }
3420 +       if (bit_mask & RTC_PIE) {
3421 +               PIE_on = 1;
3422 +               PIE_count = 0;
3423 +       }
3424 +       if (bit_mask & RTC_AIE) {
3425 +               AIE_on = 1;
3426 +       }
3427 +
3428 +       if (timer_init_reqd)
3429 +               hpet_rtc_timer_init();
3430 +
3431 +       return 1;
3432 +}
3433 +
3434 +int hpet_set_alarm_time(unsigned char hrs, unsigned char min, unsigned char sec)
3435 +{
3436 +       if (!is_hpet_enabled())
3437 +               return 0;
3438 +
3439 +       alarm_time.tm_hour = hrs;
3440 +       alarm_time.tm_min = min;
3441 +       alarm_time.tm_sec = sec;
3442 +
3443 +       return 1;
3444 +}
3445 +
3446 +int hpet_set_periodic_freq(unsigned long freq)
3447 +{
3448 +       if (!is_hpet_enabled())
3449 +               return 0;
3450 +
3451 +       PIE_freq = freq;
3452 +       PIE_count = 0;
3453 +
3454 +       return 1;
3455 +}
3456 +
3457 +int hpet_rtc_dropped_irq(void)
3458 +{
3459 +       if (!is_hpet_enabled())
3460 +               return 0;
3461 +
3462 +       return 1;
3463 +}
3464 +
3465 +irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
3466 +{
3467 +       struct rtc_time curr_time;
3468 +       unsigned long rtc_int_flag = 0;
3469 +       int call_rtc_interrupt = 0;
3470 +
3471 +       hpet_rtc_timer_reinit();
3472 +
3473 +       if (UIE_on | AIE_on) {
3474 +               get_rtc_time(&curr_time);
3475 +       }
3476 +       if (UIE_on) {
3477 +               if (curr_time.tm_sec != prev_update_sec) {
3478 +                       /* Set update int info, call real rtc int routine */
3479 +                       call_rtc_interrupt = 1;
3480 +                       rtc_int_flag = RTC_UF;
3481 +                       prev_update_sec = curr_time.tm_sec;
3482 +               }
3483 +       }
3484 +       if (PIE_on) {
3485 +               PIE_count++;
3486 +               if (PIE_count >= hpet_rtc_int_freq/PIE_freq) {
3487 +                       /* Set periodic int info, call real rtc int routine */
3488 +                       call_rtc_interrupt = 1;
3489 +                       rtc_int_flag |= RTC_PF;
3490 +                       PIE_count = 0;
3491 +               }
3492 +       }
3493 +       if (AIE_on) {
3494 +               if ((curr_time.tm_sec == alarm_time.tm_sec) &&
3495 +                   (curr_time.tm_min == alarm_time.tm_min) &&
3496 +                   (curr_time.tm_hour == alarm_time.tm_hour)) {
3497 +                       /* Set alarm int info, call real rtc int routine */
3498 +                       call_rtc_interrupt = 1;
3499 +                       rtc_int_flag |= RTC_AF;
3500 +               }
3501 +       }
3502 +       if (call_rtc_interrupt) {
3503 +               rtc_int_flag |= (RTC_IRQF | (RTC_NUM_INTS << 8));
3504 +               rtc_interrupt(rtc_int_flag, dev_id, regs);
3505 +       }
3506 +       return IRQ_HANDLED;
3507 +}
3508 +#endif
3509 +
3510 diff -Nru a/arch/i386/kernel/timers/Makefile b/arch/i386/kernel/timers/Makefile
3511 --- a/arch/i386/kernel/timers/Makefile  Sun May  4 23:38:34 2003
3512 +++ b/arch/i386/kernel/timers/Makefile  Sun Aug 31 16:14:50 2003
3513 @@ -5,3 +5,4 @@
3514  obj-y := timer.o timer_none.o timer_tsc.o timer_pit.o
3515  
3516  obj-$(CONFIG_X86_CYCLONE_TIMER)        += timer_cyclone.o
3517 +obj-$(CONFIG_HPET_TIMER)       += timer_hpet.o
3518 diff -Nru a/arch/i386/kernel/timers/timer.c b/arch/i386/kernel/timers/timer.c
3519 --- a/arch/i386/kernel/timers/timer.c   Wed Jul  2 21:21:34 2003
3520 +++ b/arch/i386/kernel/timers/timer.c   Sun Aug 31 16:15:21 2003
3521 @@ -3,10 +3,21 @@
3522  #include <linux/string.h>
3523  #include <asm/timer.h>
3524  
3525 +#ifdef CONFIG_HPET_TIMER
3526 +/*
3527 + * HPET memory read is slower than tsc reads, but is more dependable as it
3528 + * always runs at constant frequency and reduces complexity due to
3529 + * cpufreq. So, we prefer HPET timer to tsc based one. Also, we cannot use
3530 + * timer_pit when HPET is active. So, we default to timer_tsc.
3531 + */
3532 +#endif
3533  /* list of timers, ordered by preference, NULL terminated */
3534  static struct timer_opts* timers[] = {
3535  #ifdef CONFIG_X86_CYCLONE_TIMER
3536         &timer_cyclone,
3537 +#endif
3538 +#ifdef CONFIG_HPET_TIMER
3539 +       &timer_hpet,
3540  #endif
3541         &timer_tsc,
3542         &timer_pit,
3543 diff -Nru a/arch/i386/kernel/timers/timer_hpet.c b/arch/i386/kernel/timers/timer_hpet.c
3544 --- /dev/null   Wed Dec 31 16:00:00 1969
3545 +++ b/arch/i386/kernel/timers/timer_hpet.c      Sun Aug 31 16:15:29 2003
3546 @@ -0,0 +1,241 @@
3547 +/*
3548 + * This code largely moved from arch/i386/kernel/time.c.
3549 + * See comments there for proper credits.
3550 + */
3551 +
3552 +#include <linux/spinlock.h>
3553 +#include <linux/init.h>
3554 +#include <linux/timex.h>
3555 +#include <linux/errno.h>
3556 +#include <linux/string.h>
3557 +#include <linux/jiffies.h>
3558 +
3559 +#include <asm/timer.h>
3560 +#include <asm/io.h>
3561 +#include <asm/processor.h>
3562 +
3563 +#include "io_ports.h"
3564 +#include "mach_timer.h"
3565 +#include <asm/hpet.h>
3566 +
3567 +static unsigned long hpet_usec_quotient;       /* convert hpet clks to usec */
3568 +static unsigned long tsc_hpet_quotient;                /* convert tsc to hpet clks */
3569 +static unsigned long hpet_last;        /* hpet counter value at last tick*/
3570 +static unsigned long last_tsc_low;     /* lsb 32 bits of Time Stamp Counter */
3571 +static unsigned long last_tsc_high;    /* msb 32 bits of Time Stamp Counter */
3572 +static unsigned long long monotonic_base;
3573 +static rwlock_t monotonic_lock = RW_LOCK_UNLOCKED;
3574 +
3575 +/* convert from cycles(64bits) => nanoseconds (64bits)
3576 + *  basic equation:
3577 + *             ns = cycles / (freq / ns_per_sec)
3578 + *             ns = cycles * (ns_per_sec / freq)
3579 + *             ns = cycles * (10^9 / (cpu_mhz * 10^6))
3580 + *             ns = cycles * (10^3 / cpu_mhz)
3581 + *
3582 + *     Then we use scaling math (suggested by george@mvista.com) to get:
3583 + *             ns = cycles * (10^3 * SC / cpu_mhz) / SC
3584 + *             ns = cycles * cyc2ns_scale / SC
3585 + *
3586 + *     And since SC is a constant power of two, we can convert the div
3587 + *  into a shift.
3588 + *                     -johnstul@us.ibm.com "math is hard, lets go shopping!"
3589 + */
3590 +static unsigned long cyc2ns_scale;
3591 +#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */
3592 +
3593 +static inline void set_cyc2ns_scale(unsigned long cpu_mhz)
3594 +{
3595 +       cyc2ns_scale = (1000 << CYC2NS_SCALE_FACTOR)/cpu_mhz;
3596 +}
3597 +
3598 +static inline unsigned long long cycles_2_ns(unsigned long long cyc)
3599 +{
3600 +       return (cyc * cyc2ns_scale) >> CYC2NS_SCALE_FACTOR;
3601 +}
3602 +
3603 +static unsigned long long monotonic_clock_hpet(void)
3604 +{
3605 +       unsigned long long last_offset, this_offset, base;
3606 +
3607 +       /* atomically read monotonic base & last_offset */
3608 +       read_lock_irq(&monotonic_lock);
3609 +       last_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
3610 +       base = monotonic_base;
3611 +       read_unlock_irq(&monotonic_lock);
3612 +
3613 +       /* Read the Time Stamp Counter */
3614 +       rdtscll(this_offset);
3615 +
3616 +       /* return the value in ns */
3617 +       return base + cycles_2_ns(this_offset - last_offset);
3618 +}
3619 +
3620 +static unsigned long get_offset_hpet(void)
3621 +{
3622 +       register unsigned long eax, edx;
3623 +
3624 +       eax = hpet_readl(HPET_COUNTER);
3625 +       eax -= hpet_last;       /* hpet delta */
3626 +
3627 +       /*
3628 +         * Time offset = (hpet delta) * ( usecs per HPET clock )
3629 +        *             = (hpet delta) * ( usecs per tick / HPET clocks per tick)
3630 +        *             = (hpet delta) * ( hpet_usec_quotient ) / (2^32)
3631 +        *
3632 +        * Where,
3633 +        * hpet_usec_quotient = (2^32 * usecs per tick)/HPET clocks per tick
3634 +        *
3635 +        * Using a mull instead of a divl saves some cycles in critical path.
3636 +         */
3637 +       ASM_MUL64_REG(eax, edx, hpet_usec_quotient, eax);
3638 +
3639 +       /* our adjusted time offset in microseconds */
3640 +       return edx;
3641 +}
3642 +
3643 +static void mark_offset_hpet(void)
3644 +{
3645 +       unsigned long long this_offset, last_offset;
3646 +       unsigned long offset;
3647 +
3648 +       write_lock(&monotonic_lock);
3649 +       last_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
3650 +       rdtsc(last_tsc_low, last_tsc_high);
3651 +
3652 +       offset = hpet_readl(HPET_T0_CMP) - hpet_tick;
3653 +       if (unlikely(((offset - hpet_last) > hpet_tick) && (hpet_last != 0))) {
3654 +               int lost_ticks = (offset - hpet_last) / hpet_tick;
3655 +               jiffies += lost_ticks;
3656 +       }
3657 +       hpet_last = offset;
3658 +
3659 +       /* update the monotonic base value */
3660 +       this_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
3661 +       monotonic_base += cycles_2_ns(this_offset - last_offset);
3662 +       write_unlock(&monotonic_lock);
3663 +}
3664 +
3665 +void delay_hpet(unsigned long loops)
3666 +{
3667 +       unsigned long hpet_start, hpet_end;
3668 +       unsigned long eax;
3669 +
3670 +       /* loops is the number of cpu cycles. Convert it to hpet clocks */
3671 +       ASM_MUL64_REG(eax, loops, tsc_hpet_quotient, loops);
3672 +
3673 +       hpet_start = hpet_readl(HPET_COUNTER);
3674 +       do {
3675 +               rep_nop();
3676 +               hpet_end = hpet_readl(HPET_COUNTER);
3677 +       } while ((hpet_end - hpet_start) < (loops));
3678 +}
3679 +
3680 +/* ------ Calibrate the TSC -------
3681 + * Return 2^32 * (1 / (TSC clocks per usec)) for getting the CPU freq.
3682 + * Set 2^32 * (1 / (tsc per HPET clk)) for delay_hpet().
3683 + * calibrate_tsc() calibrates the processor TSC by comparing
3684 + * it to the HPET timer of known frequency.
3685 + * Too much 64-bit arithmetic here to do this cleanly in C
3686 + */
3687 +#define CALIBRATE_CNT_HPET     (5 * hpet_tick)
3688 +#define CALIBRATE_TIME_HPET    (5 * KERNEL_TICK_USEC)
3689 +
3690 +static unsigned long __init calibrate_tsc(void)
3691 +{
3692 +       unsigned long tsc_startlow, tsc_starthigh;
3693 +       unsigned long tsc_endlow, tsc_endhigh;
3694 +       unsigned long hpet_start, hpet_end;
3695 +       unsigned long result, remain;
3696 +
3697 +       hpet_start = hpet_readl(HPET_COUNTER);
3698 +       rdtsc(tsc_startlow, tsc_starthigh);
3699 +       do {
3700 +               hpet_end = hpet_readl(HPET_COUNTER);
3701 +       } while ((hpet_end - hpet_start) < CALIBRATE_CNT_HPET);
3702 +       rdtsc(tsc_endlow, tsc_endhigh);
3703 +
3704 +       /* 64-bit subtract - gcc just messes up with long longs */
3705 +       __asm__("subl %2,%0\n\t"
3706 +               "sbbl %3,%1"
3707 +               :"=a" (tsc_endlow), "=d" (tsc_endhigh)
3708 +               :"g" (tsc_startlow), "g" (tsc_starthigh),
3709 +                "0" (tsc_endlow), "1" (tsc_endhigh));
3710 +
3711 +       /* Error: ECPUTOOFAST */
3712 +       if (tsc_endhigh)
3713 +               goto bad_calibration;
3714 +
3715 +       /* Error: ECPUTOOSLOW */
3716 +       if (tsc_endlow <= CALIBRATE_TIME_HPET)
3717 +               goto bad_calibration;
3718 +
3719 +       ASM_DIV64_REG(result, remain, tsc_endlow, 0, CALIBRATE_TIME_HPET);
3720 +       if (remain > (tsc_endlow >> 1))
3721 +               result++; /* rounding the result */
3722 +
3723 +       ASM_DIV64_REG(tsc_hpet_quotient, remain, tsc_endlow, 0,
3724 +                       CALIBRATE_CNT_HPET);
3725 +       if (remain > (tsc_endlow >> 1))
3726 +               tsc_hpet_quotient++; /* rounding the result */
3727 +
3728 +       return result;
3729 +bad_calibration:
3730 +       /*
3731 +        * the CPU was so fast/slow that the quotient wouldn't fit in
3732 +        * 32 bits..
3733 +        */
3734 +       return 0;
3735 +}
3736 +
3737 +static int __init init_hpet(char* override)
3738 +{
3739 +       unsigned long result, remain;
3740 +
3741 +       /* check clock override */
3742 +       if (override[0] && strncmp(override,"hpet",4))
3743 +               return -ENODEV;
3744 +
3745 +       if (!is_hpet_enabled())
3746 +               return -ENODEV;
3747 +
3748 +       printk("Using HPET for gettimeofday\n");
3749 +       if (cpu_has_tsc) {
3750 +               unsigned long tsc_quotient = calibrate_tsc();
3751 +               if (tsc_quotient) {
3752 +                       /* report CPU clock rate in Hz.
3753 +                        * The formula is (10^6 * 2^32) / (2^32 * 1 / (clocks/us)) =
3754 +                        * clock/second. Our precision is about 100 ppm.
3755 +                        */
3756 +                       {       unsigned long eax=0, edx=1000;
3757 +                               ASM_DIV64_REG(cpu_khz, edx, tsc_quotient,
3758 +                                               eax, edx);
3759 +                               printk("Detected %lu.%03lu MHz processor.\n",
3760 +                                       cpu_khz / 1000, cpu_khz % 1000);
3761 +                       }
3762 +                       set_cyc2ns_scale(cpu_khz/1000);
3763 +               }
3764 +       }
3765 +
3766 +       /*
3767 +        * Math to calculate hpet to usec multiplier
3768 +        * Look for the comments at get_offset_hpet()
3769 +        */
3770 +       ASM_DIV64_REG(result, remain, hpet_tick, 0, KERNEL_TICK_USEC);
3771 +       if (remain > (hpet_tick >> 1))
3772 +               result++; /* rounding the result */
3773 +       hpet_usec_quotient = result;
3774 +
3775 +       return 0;
3776 +}
3777 +
3778 +/************************************************************/
3779 +
3780 +/* tsc timer_opts struct */
3781 +struct timer_opts timer_hpet = {
3782 +       .init =                 init_hpet,
3783 +       .mark_offset =          mark_offset_hpet,
3784 +       .get_offset =           get_offset_hpet,
3785 +       .monotonic_clock =      monotonic_clock_hpet,
3786 +       .delay =                delay_hpet,
3787 +};
3788 diff -Nru a/arch/i386/kernel/timers/timer_tsc.c b/arch/i386/kernel/timers/timer_tsc.c
3789 --- a/arch/i386/kernel/timers/timer_tsc.c       Mon Aug 18 06:40:02 2003
3790 +++ b/arch/i386/kernel/timers/timer_tsc.c       Sun Aug 31 16:15:21 2003
3791 @@ -19,9 +19,18 @@
3792  #include "io_ports.h"
3793  #include "mach_timer.h"
3794  
3795 +#include <asm/hpet.h>
3796 +
3797 +#ifdef CONFIG_HPET_TIMER
3798 +static unsigned long hpet_usec_quotient;
3799 +static unsigned long hpet_last;
3800 +struct timer_opts timer_tsc;
3801 +#endif
3802 +
3803  int tsc_disable __initdata = 0;
3804  
3805  extern spinlock_t i8253_lock;
3806 +extern volatile unsigned long jiffies;
3807  
3808  static int use_tsc;
3809  /* Number of usecs that the last interrupt was delayed */
3810 @@ -232,7 +241,7 @@
3811  
3812  #define CALIBRATE_TIME (5 * 1000020/HZ)
3813  
3814 -unsigned long __init calibrate_tsc(void)
3815 +static unsigned long __init calibrate_tsc(void)
3816  {
3817         mach_prepare_counter();
3818  
3819 @@ -282,6 +291,107 @@
3820         return 0;
3821  }
3822  
3823 +#ifdef CONFIG_HPET_TIMER
3824 +static void mark_offset_tsc_hpet(void)
3825 +{
3826 +       unsigned long long this_offset, last_offset;
3827 +       unsigned long offset, temp, hpet_current;
3828 +
3829 +       write_lock(&monotonic_lock);
3830 +       last_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
3831 +       /*
3832 +        * It is important that these two operations happen almost at
3833 +        * the same time. We do the RDTSC stuff first, since it's
3834 +        * faster. To avoid any inconsistencies, we need interrupts
3835 +        * disabled locally.
3836 +        */
3837 +       /*
3838 +        * Interrupts are just disabled locally since the timer irq
3839 +        * has the SA_INTERRUPT flag set. -arca
3840 +        */
3841 +       /* read Pentium cycle counter */
3842 +
3843 +       hpet_current = hpet_readl(HPET_COUNTER);
3844 +       rdtsc(last_tsc_low, last_tsc_high);
3845 +
3846 +       /* lost tick compensation */
3847 +       offset = hpet_readl(HPET_T0_CMP) - hpet_tick;
3848 +       if (unlikely(((offset - hpet_last) > hpet_tick) && (hpet_last != 0))) {
3849 +               int lost_ticks = (offset - hpet_last) / hpet_tick;
3850 +               jiffies += lost_ticks;
3851 +       }
3852 +       hpet_last = hpet_current;
3853 +
3854 +       /* update the monotonic base value */
3855 +       this_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
3856 +       monotonic_base += cycles_2_ns(this_offset - last_offset);
3857 +       write_unlock(&monotonic_lock);
3858 +
3859 +       /* calculate delay_at_last_interrupt */
3860 +       /*
3861 +        * Time offset = (hpet delta) * ( usecs per HPET clock )
3862 +        *             = (hpet delta) * ( usecs per tick / HPET clocks per tick)
3863 +        *             = (hpet delta) * ( hpet_usec_quotient ) / (2^32)
3864 +        * Where,
3865 +        * hpet_usec_quotient = (2^32 * usecs per tick)/HPET clocks per tick
3866 +        */
3867 +       delay_at_last_interrupt = hpet_current - offset;
3868 +       ASM_MUL64_REG(temp, delay_at_last_interrupt,
3869 +                       hpet_usec_quotient, delay_at_last_interrupt);
3870 +}
3871 +
3872 +/* ------ Calibrate the TSC based on HPET timer -------
3873 + * Return 2^32 * (1 / (TSC clocks per usec)) for do_fast_gettimeoffset().
3874 + * calibrate_tsc() calibrates the processor TSC by comparing
3875 + * it to the HPET timer of known frequency.
3876 + * Too much 64-bit arithmetic here to do this cleanly in C
3877 + */
3878 +
3879 +#define CALIBRATE_CNT_HPET     (5 * hpet_tick)
3880 +#define CALIBRATE_TIME_HPET    (5 * KERNEL_TICK_USEC)
3881 +
3882 +unsigned long __init calibrate_tsc_hpet(void)
3883 +{
3884 +       unsigned long tsc_startlow, tsc_starthigh;
3885 +       unsigned long tsc_endlow, tsc_endhigh;
3886 +       unsigned long hpet_start, hpet_end;
3887 +       unsigned long result, remain;
3888 +
3889 +       hpet_start = hpet_readl(HPET_COUNTER);
3890 +       rdtsc(tsc_startlow, tsc_starthigh);
3891 +       do {
3892 +               hpet_end = hpet_readl(HPET_COUNTER);
3893 +       } while ((hpet_end - hpet_start) < CALIBRATE_CNT_HPET);
3894 +       rdtsc(tsc_endlow, tsc_endhigh);
3895 +
3896 +       /* 64-bit subtract - gcc just messes up with long longs */
3897 +       __asm__("subl %2,%0\n\t"
3898 +               "sbbl %3,%1"
3899 +               :"=a" (tsc_endlow), "=d" (tsc_endhigh)
3900 +               :"g" (tsc_startlow), "g" (tsc_starthigh),
3901 +                "0" (tsc_endlow), "1" (tsc_endhigh));
3902 +
3903 +       /* Error: ECPUTOOFAST */
3904 +       if (tsc_endhigh)
3905 +               goto bad_calibration;
3906 +
3907 +       /* Error: ECPUTOOSLOW */
3908 +       if (tsc_endlow <= CALIBRATE_TIME_HPET)
3909 +               goto bad_calibration;
3910 +
3911 +       ASM_DIV64_REG(result, remain, tsc_endlow, 0, CALIBRATE_TIME_HPET);
3912 +       if (remain > (tsc_endlow >> 1))
3913 +               result++; /* rounding the result */
3914 +
3915 +       return result;
3916 +bad_calibration:
3917 +       /*
3918 +        * the CPU was so fast/slow that the quotient wouldn't fit in
3919 +        * 32 bits..
3920 +        */
3921 +       return 0;
3922 +}
3923 +#endif
3924  
3925  #ifdef CONFIG_CPU_FREQ
3926  static unsigned int  ref_freq = 0;
3927 @@ -333,8 +443,16 @@
3928  {
3929  
3930         /* check clock override */
3931 -       if (override[0] && strncmp(override,"tsc",3))
3932 +       if (override[0] && strncmp(override,"tsc",3)) {
3933 +#ifdef CONFIG_HPET_TIMER
3934 +               if (is_hpet_enabled()) {
3935 +                       printk(KERN_ERR "Warning: clock= override failed. Defaulting to tsc\n");
3936 +               } else
3937 +#endif
3938 +               {
3939                         return -ENODEV;
3940 +               }
3941 +       }
3942  
3943         /*
3944          * If we have APM enabled or the CPU clock speed is variable
3945 @@ -368,7 +486,29 @@
3946         count2 = LATCH; /* initialize counter for mark_offset_tsc() */
3947  
3948         if (cpu_has_tsc) {
3949 -               unsigned long tsc_quotient = calibrate_tsc();
3950 +               unsigned long tsc_quotient;
3951 +#ifdef CONFIG_HPET_TIMER
3952 +               if (is_hpet_enabled()){
3953 +                       unsigned long result, remain;
3954 +                       printk("Using TSC for gettimeofday\n");
3955 +                       tsc_quotient = calibrate_tsc_hpet();
3956 +                       timer_tsc.mark_offset = &mark_offset_tsc_hpet;
3957 +                       /*
3958 +                        * Math to calculate hpet to usec multiplier
3959 +                        * Look for the comments at get_offset_tsc_hpet()
3960 +                        */
3961 +                       ASM_DIV64_REG(result, remain, hpet_tick,
3962 +                                       0, KERNEL_TICK_USEC);
3963 +                       if (remain > (hpet_tick >> 1))
3964 +                               result++; /* rounding the result */
3965 +
3966 +                       hpet_usec_quotient = result;
3967 +               } else
3968 +#endif
3969 +               {
3970 +                       tsc_quotient = calibrate_tsc();
3971 +               }
3972 +
3973                 if (tsc_quotient) {
3974                         fast_gettimeoffset_quotient = tsc_quotient;
3975                         use_tsc = 1;
3976 diff -Nru a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
3977 --- a/arch/i386/kernel/traps.c  Thu Jun 26 12:11:29 2003
3978 +++ b/arch/i386/kernel/traps.c  Tue Sep  2 00:37:21 2003
3979 @@ -745,7 +745,8 @@
3980   * Careful.. There are problems with IBM-designed IRQ13 behaviour.
3981   * Don't touch unless you *really* know how it works.
3982   *
3983 - * Must be called with kernel preemption disabled.
3984 + * Must be called with kernel preemption disabled (in this case,
3985 + * local interrupts are disabled at the call-site in entry.S).
3986   */
3987  asmlinkage void math_state_restore(struct pt_regs regs)
3988  {
3989 diff -Nru a/arch/i386/mach-visws/mpparse.c b/arch/i386/mach-visws/mpparse.c
3990 --- a/arch/i386/mach-visws/mpparse.c    Mon Aug 18 19:46:23 2003
3991 +++ b/arch/i386/mach-visws/mpparse.c    Sun Aug 31 16:14:17 2003
3992 @@ -38,7 +38,7 @@
3993  void __init MP_processor_info (struct mpc_config_processor *m)
3994  {
3995         int ver, logical_apicid;
3996 -       cpumask_t apic_cpus;
3997 +       physid_mask_t apic_cpus;
3998         
3999         if (!(m->mpc_cpuflag & CPU_ENABLED))
4000                 return;
4001 diff -Nru a/arch/i386/mach-voyager/voyager_smp.c b/arch/i386/mach-voyager/voyager_smp.c
4002 --- a/arch/i386/mach-voyager/voyager_smp.c      Mon Aug 18 19:46:23 2003
4003 +++ b/arch/i386/mach-voyager/voyager_smp.c      Sun Aug 31 16:14:42 2003
4004 @@ -130,7 +130,7 @@
4005  {
4006         int cpu;
4007  
4008 -       for_each_cpu(cpu, mk_cpumask_const(cpu_online_map)) {
4009 +       for_each_cpu(cpu, cpu_online_map) {
4010                 if(cpuset & (1<<cpu)) {
4011  #ifdef VOYAGER_DEBUG
4012                         if(!cpu_isset(cpu, cpu_online_map))
4013 @@ -874,10 +874,10 @@
4014  asmlinkage void 
4015  smp_invalidate_interrupt(void)
4016  {
4017 -       __u8 cpu = get_cpu();
4018 +       __u8 cpu = smp_processor_id();
4019  
4020 -       if (!(smp_invalidate_needed & (1UL << cpu)))
4021 -               goto out;
4022 +       if (!test_bit(cpu, &smp_invalidate_needed))
4023 +               return;
4024         /* This will flood messages.  Don't uncomment unless you see
4025          * Problems with cross cpu invalidation
4026         VDEBUG(("VOYAGER SMP: CPU%d received INVALIDATE_CPI\n",
4027 @@ -893,9 +893,9 @@
4028                 } else
4029                         leave_mm(cpu);
4030         }
4031 -       smp_invalidate_needed |= 1UL << cpu;
4032 - out:
4033 -       put_cpu_no_resched();
4034 +       smp_mb__before_clear_bit();
4035 +       clear_bit(cpu, &smp_invalidate_needed);
4036 +       smp_mb__after_clear_bit();
4037  }
4038  
4039  /* All the new flush operations for 2.4 */
4040 @@ -929,6 +929,7 @@
4041         send_CPI(cpumask, VIC_INVALIDATE_CPI);
4042  
4043         while (smp_invalidate_needed) {
4044 +               mb();
4045                 if(--stuck == 0) {
4046                         printk("***WARNING*** Stuck doing invalidate CPI (CPU%d)\n", smp_processor_id());
4047                         break;
4048 @@ -1464,7 +1465,7 @@
4049         cpuset &= 0xff;         /* only first 8 CPUs vaild for VIC CPI */
4050         if(cpuset == 0)
4051                 return;
4052 -       for_each_cpu(cpu, mk_cpumask_const(cpu_online_map)) {
4053 +       for_each_cpu(cpu, cpu_online_map) {
4054                 if(cpuset & (1<<cpu))
4055                         set_bit(cpi, &vic_cpi_mailbox[cpu]);
4056         }
4057 @@ -1578,7 +1579,7 @@
4058         VDEBUG(("VOYAGER: enable_vic_irq(%d) CPU%d affinity 0x%lx\n",
4059                 irq, cpu, cpu_irq_affinity[cpu]));
4060         spin_lock_irqsave(&vic_irq_lock, flags);
4061 -       for_each_cpu(real_cpu, mk_cpumask_const(cpu_online_map)) {
4062 +       for_each_cpu(real_cpu, cpu_online_map) {
4063                 if(!(voyager_extended_vic_processors & (1<<real_cpu)))
4064                         continue;
4065                 if(!(cpu_irq_affinity[real_cpu] & mask)) {
4066 @@ -1723,7 +1724,7 @@
4067  
4068                         printk("VOYAGER SMP: CPU%d lost interrupt %d\n",
4069                                cpu, irq);
4070 -                       for_each_cpu(real_cpu, mk_cpumask_const(mask)) {
4071 +                       for_each_cpu(real_cpu, mask) {
4072  
4073                                 outb(VIC_CPU_MASQUERADE_ENABLE | real_cpu,
4074                                      VIC_PROCESSOR_ID);
4075 @@ -1808,7 +1809,7 @@
4076                  * bus) */
4077                 return;
4078  
4079 -       for_each_cpu(cpu, mk_cpumask_const(cpu_online_map)) {
4080 +       for_each_cpu(cpu, cpu_online_map) {
4081                 unsigned long cpu_mask = 1 << cpu;
4082                 
4083                 if(cpu_mask & real_mask) {
4084 @@ -1874,7 +1875,7 @@
4085         int old_cpu = smp_processor_id(), cpu;
4086  
4087         /* dump the interrupt masks of each processor */
4088 -       for_each_cpu(cpu, mk_cpumask_const(cpu_online_map)) {
4089 +       for_each_cpu(cpu, cpu_online_map) {
4090                 __u16 imr, isr, irr;
4091                 unsigned long flags;
4092  
4093 diff -Nru a/arch/i386/oprofile/nmi_int.c b/arch/i386/oprofile/nmi_int.c
4094 --- a/arch/i386/oprofile/nmi_int.c      Thu Jul 17 17:21:06 2003
4095 +++ b/arch/i386/oprofile/nmi_int.c      Fri Aug 29 09:02:20 2003
4096 @@ -364,10 +364,21 @@
4097         switch (vendor) {
4098                 case X86_VENDOR_AMD:
4099                         /* Needs to be at least an Athlon (or hammer in 32bit mode) */
4100 -                       if (family < 6)
4101 +
4102 +                       switch (family) {
4103 +                       default:
4104                                 return -ENODEV;
4105 -                       model = &op_athlon_spec;
4106 -                       nmi_ops.cpu_type = "i386/athlon";
4107 +                       case 6:
4108 +                               model = &op_athlon_spec;
4109 +                               nmi_ops.cpu_type = "i386/athlon";
4110 +                               break;
4111 +#if defined(CONFIG_X86_64)
4112 +                       case 0xf:
4113 +                               model = &op_athlon_spec;
4114 +                               nmi_ops.cpu_type = "x86-64/hammer";
4115 +                               break;
4116 +#endif /* CONFIG_X86_64 */
4117 +                       }
4118                         break;
4119   
4120  #if !defined(CONFIG_X86_64)
4121 diff -Nru a/arch/i386/pci/common.c b/arch/i386/pci/common.c
4122 --- a/arch/i386/pci/common.c    Mon Jun 23 12:31:05 2003
4123 +++ b/arch/i386/pci/common.c    Mon Sep  1 17:58:12 2003
4124 @@ -152,7 +152,7 @@
4125         pci_cache_line_size = 32 >> 2;
4126         if (c->x86 >= 6 && c->x86_vendor == X86_VENDOR_AMD)
4127                 pci_cache_line_size = 64 >> 2;  /* K7 & K8 */
4128 -       else if (c->x86 > 6)
4129 +       else if (c->x86 > 6 && c->x86_vendor == X86_VENDOR_INTEL)
4130                 pci_cache_line_size = 128 >> 2; /* P4 */
4131  
4132         pcibios_resource_survey();
4133 diff -Nru a/arch/ia64/Kconfig b/arch/ia64/Kconfig
4134 --- a/arch/ia64/Kconfig Fri Aug  8 10:02:34 2003
4135 +++ b/arch/ia64/Kconfig Sun Aug 31 16:14:22 2003
4136 @@ -234,8 +234,8 @@
4137  endchoice
4138  
4139  config DISCONTIGMEM
4140 -       bool "Discontiguous memory support" if (IA64_DIG && NUMA)
4141 -       default y if IA64_SGI_SN2 || IA64_GENERIC
4142 +       bool "Discontiguous memory support" if (IA64_DIG || IA64_SGI_SN2 || IA64_GENERIC) && NUMA
4143 +       default y if (IA64_SGI_SN2 || IA64_GENERIC) && NUMA
4144         help
4145           Say Y to support efficient handling of discontiguous physical memory,
4146           for architectures which are either NUMA (Non-Uniform Memory Access)
4147 @@ -296,29 +296,6 @@
4148         help
4149           If you are compiling a kernel that will run under SGI's IA-64
4150           simulator (Medusa) then say Y, otherwise say N.
4151 -
4152 -# On IA-64, we always want an ELF /proc/kcore.
4153 -config KCORE_ELF
4154 -       bool
4155 -       default y
4156 -       ---help---
4157 -         If you enabled support for /proc file system then the file
4158 -         /proc/kcore will contain the kernel core image. This can be used
4159 -         in gdb:
4160 -
4161 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
4162 -
4163 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
4164 -         /proc/kcore appear in ELF core format as defined by the Executable
4165 -         and Linking Format specification. Selecting A.OUT will choose the
4166 -         old "a.out" format which may be necessary for some old versions
4167 -         of binutils or on some architectures.
4168 -
4169 -         This is especially useful if you have compiled the kernel with the
4170 -         "-g" option to preserve debugging information. It is mainly used
4171 -         for examining kernel data structures on the live kernel so if you
4172 -         don't understand what this means or are not a kernel hacker, just
4173 -         leave it at its default value ELF.
4174  
4175  config FORCE_MAX_ZONEORDER
4176         int
4177 diff -Nru a/arch/ia64/Makefile b/arch/ia64/Makefile
4178 --- a/arch/ia64/Makefile        Tue Aug 19 23:13:39 2003
4179 +++ b/arch/ia64/Makefile        Sat Aug 23 10:28:23 2003
4180 @@ -70,6 +70,8 @@
4181  
4182  .PHONY: boot compressed check
4183  
4184 +all: compressed
4185 +
4186  compressed: vmlinux.gz
4187  
4188  vmlinux.gz: vmlinux
4189 @@ -100,6 +102,6 @@
4190  
4191  
4192  define archhelp
4193 -  echo '  compressed   - Build compressed kernel image'
4194 +  echo '* compressed   - Build compressed kernel image'
4195    echo '  boot         - Build vmlinux and bootloader for Ski simulator'
4196  endef
4197 diff -Nru a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
4198 --- a/arch/ia64/hp/common/sba_iommu.c   Sun Jul 27 12:01:33 2003
4199 +++ b/arch/ia64/hp/common/sba_iommu.c   Sun Aug 31 16:14:08 2003
4200 @@ -1935,10 +1935,10 @@
4201  }
4202  
4203  static struct acpi_driver acpi_sba_ioc_driver = {
4204 -       name:           "IOC IOMMU Driver",
4205 -       ids:            "HWP0001,HWP0004",
4206 -       ops: {
4207 -               add:    acpi_sba_ioc_add,
4208 +       .name           = "IOC IOMMU Driver",
4209 +       .ids            = "HWP0001,HWP0004",
4210 +       .ops            = {
4211 +               .add    = acpi_sba_ioc_add,
4212         },
4213  };
4214  
4215 diff -Nru a/arch/ia64/ia32/ia32_ioctl.c b/arch/ia64/ia32/ia32_ioctl.c
4216 --- a/arch/ia64/ia32/ia32_ioctl.c       Thu Aug  7 17:00:00 2003
4217 +++ b/arch/ia64/ia32/ia32_ioctl.c       Sun Aug 31 16:14:44 2003
4218 @@ -70,7 +70,7 @@
4219  #define IOCTL_TABLE_START \
4220         struct ioctl_trans ioctl_start[] = {
4221  #define IOCTL_TABLE_END \
4222 -       }; struct ioctl_trans ioctl_end[0];
4223 +       };
4224  
4225  IOCTL_TABLE_START
4226  HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32, vfat_ioctl32)
4227 @@ -79,3 +79,5 @@
4228  #include "compat_ioctl.c"
4229  #include <linux/compat_ioctl.h>
4230  IOCTL_TABLE_END
4231 +
4232 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
4233 diff -Nru a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
4234 --- a/arch/ia64/ia32/sys_ia32.c Tue Aug 19 23:13:39 2003
4235 +++ b/arch/ia64/ia32/sys_ia32.c Mon Aug 25 14:45:43 2003
4236 @@ -76,7 +76,6 @@
4237  
4238  #define OFFSET4K(a)            ((a) & 0xfff)
4239  #define PAGE_START(addr)       ((addr) & PAGE_MASK)
4240 -#define PAGE_OFF(addr)         ((addr) & ~PAGE_MASK)
4241  
4242  #define high2lowuid(uid) ((uid) > 65535 ? 65534 : (uid))
4243  #define high2lowgid(gid) ((gid) > 65535 ? 65534 : (gid))
4244 @@ -170,9 +169,9 @@
4245                 current->thread.map_base  = old_map_base;
4246                 current->thread.task_size = old_task_size;
4247                 set_fs(USER_DS);        /* establish new task-size as the address-limit */
4248 -         out:
4249 -               kfree(av);
4250         }
4251 +  out:
4252 +       kfree(av);
4253         return r;
4254  }
4255  
4256 @@ -271,11 +270,11 @@
4257  
4258         if (old_prot) {
4259                 /* copy back the old page contents.  */
4260 -               if (PAGE_OFF(start))
4261 -                       copy_to_user((void *) PAGE_START(start), page, PAGE_OFF(start));
4262 -               if (PAGE_OFF(end))
4263 -                       copy_to_user((void *) end, page + PAGE_OFF(end),
4264 -                                    PAGE_SIZE - PAGE_OFF(end));
4265 +               if (offset_in_page(start))
4266 +                       copy_to_user((void *) PAGE_START(start), page, offset_in_page(start));
4267 +               if (offset_in_page(end))
4268 +                       copy_to_user((void *) end, page + offset_in_page(end),
4269 +                                    PAGE_SIZE - offset_in_page(end));
4270         }
4271  
4272         if (!(flags & MAP_ANONYMOUS)) {
4273 @@ -330,7 +329,7 @@
4274                                        "%s(%d): emulate_mmap() can't share tail (end=0x%lx)\n",
4275                                        current->comm, current->pid, end);
4276                         ret = mmap_subpage(file, max(start, PAGE_START(end)), end, prot, flags,
4277 -                                          (off + len) - PAGE_OFF(end));
4278 +                                          (off + len) - offset_in_page(end));
4279                         if (IS_ERR((void *) ret))
4280                                 return ret;
4281                         pend -= PAGE_SIZE;
4282 @@ -347,14 +346,14 @@
4283                 tmp = arch_get_unmapped_area(file, pstart - fudge, pend - pstart, 0, flags);
4284                 if (tmp != pstart) {
4285                         pstart = tmp;
4286 -                       start = pstart + PAGE_OFF(off); /* make start congruent with off */
4287 +                       start = pstart + offset_in_page(off);   /* make start congruent with off */
4288                         end = start + len;
4289                         pend = PAGE_ALIGN(end);
4290                 }
4291         }
4292  
4293         poff = off + (pstart - start);  /* note: (pstart - start) may be negative */
4294 -       is_congruent = (flags & MAP_ANONYMOUS) || (PAGE_OFF(poff) == 0);
4295 +       is_congruent = (flags & MAP_ANONYMOUS) || (offset_in_page(poff) == 0);
4296  
4297         if ((flags & MAP_SHARED) && !is_congruent)
4298                 printk(KERN_INFO "%s(%d): emulate_mmap() can't share contents of incongruent mmap "
4299 @@ -588,7 +587,7 @@
4300  
4301         down(&ia32_mmap_sem);
4302         {
4303 -               if (PAGE_OFF(start)) {
4304 +               if (offset_in_page(start)) {
4305                         /* start address is 4KB aligned but not page aligned. */
4306                         retval = mprotect_subpage(PAGE_START(start), prot);
4307                         if (retval < 0)
4308 @@ -599,7 +598,7 @@
4309                                 goto out;       /* retval is already zero... */
4310                 }
4311  
4312 -               if (PAGE_OFF(end)) {
4313 +               if (offset_in_page(end)) {
4314                         /* end address is 4KB aligned but not page aligned. */
4315                         retval = mprotect_subpage(PAGE_START(end), prot);
4316                         if (retval < 0)
4317 diff -Nru a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
4318 --- a/arch/ia64/kernel/acpi.c   Wed Aug  6 12:37:03 2003
4319 +++ b/arch/ia64/kernel/acpi.c   Tue Aug 26 15:09:18 2003
4320 @@ -130,7 +130,7 @@
4321         int vector = -1;
4322  
4323         if (int_type < ACPI_MAX_PLATFORM_INTERRUPTS) {
4324 -               /* correctable platform error interrupt */
4325 +               /* corrected platform error interrupt */
4326                 vector = platform_intr_list[int_type];
4327         } else
4328                 printk(KERN_ERR "acpi_request_vector(): invalid interrupt type\n");
4329 diff -Nru a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
4330 --- a/arch/ia64/kernel/entry.S  Sat Aug 16 17:16:48 2003
4331 +++ b/arch/ia64/kernel/entry.S  Mon Aug 25 14:47:33 2003
4332 @@ -1473,7 +1473,7 @@
4333         data8 sys_clock_nanosleep
4334         data8 sys_fstatfs64
4335         data8 sys_statfs64
4336 -       data8 ia64_ni_syscall
4337 +       data8 sys_fadvise64_64
4338         data8 ia64_ni_syscall                   // 1260
4339         data8 ia64_ni_syscall
4340         data8 ia64_ni_syscall
4341 diff -Nru a/arch/ia64/kernel/fsys.S b/arch/ia64/kernel/fsys.S
4342 --- a/arch/ia64/kernel/fsys.S   Thu Jul 10 18:16:32 2003
4343 +++ b/arch/ia64/kernel/fsys.S   Mon Aug 25 14:47:33 2003
4344 @@ -678,9 +678,9 @@
4345         data8 0                         // clock_gettime
4346         data8 0                         // clock_getres         // 1255
4347         data8 0                         // clock_nanosleep
4348 -       data8 0
4349 -       data8 0
4350 -       data8 0
4351 +       data8 0                         // fstatfs64
4352 +       data8 0                         // statfs64
4353 +       data8 0                         // fadvise64_64
4354         data8 0                                                 // 1260
4355         data8 0
4356         data8 0
4357 diff -Nru a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
4358 --- a/arch/ia64/kernel/mca.c    Tue Aug 19 23:13:39 2003
4359 +++ b/arch/ia64/kernel/mca.c    Tue Aug 26 13:42:37 2003
4360 @@ -1145,7 +1145,7 @@
4361  
4362         ia64_mca_cmc_int_handler(cpe_irq, arg, ptregs);
4363  
4364 -       for (++cpuid ; !cpu_online(cpuid) && cpuid < NR_CPUS ; cpuid++);
4365 +       for (++cpuid ; cpuid < NR_CPUS && !cpu_online(cpuid) ; cpuid++);
4366  
4367         if (cpuid < NR_CPUS) {
4368                 platform_send_ipi(cpuid, IA64_CMCP_VECTOR, IA64_IPI_DM_INT, 0);
4369 @@ -1225,7 +1225,7 @@
4370  
4371         ia64_mca_cpe_int_handler(cpe_irq, arg, ptregs);
4372  
4373 -       for (++cpuid ; !cpu_online(cpuid) && cpuid < NR_CPUS ; cpuid++);
4374 +       for (++cpuid ; cpuid < NR_CPUS && !cpu_online(cpuid) ; cpuid++);
4375  
4376         if (cpuid < NR_CPUS) {
4377                 platform_send_ipi(cpuid, IA64_CPEP_VECTOR, IA64_IPI_DM_INT, 0);
4378 diff -Nru a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
4379 --- a/arch/ia64/kernel/perfmon.c        Thu Aug 21 15:45:04 2003
4380 +++ b/arch/ia64/kernel/perfmon.c        Sun Aug 31 16:14:08 2003
4381 @@ -2109,7 +2109,7 @@
4382         return 1;
4383  }
4384  static struct dentry_operations pfmfs_dentry_operations = {
4385 -       d_delete:       pfmfs_delete_dentry,
4386 +       .d_delete       = pfmfs_delete_dentry,
4387  };
4388  
4389  
4390 diff -Nru a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
4391 --- a/arch/ia64/kernel/smpboot.c        Mon Aug 18 19:46:23 2003
4392 +++ b/arch/ia64/kernel/smpboot.c        Fri Aug 22 15:20:52 2003
4393 @@ -560,7 +560,7 @@
4394                 if (cpu_online(cpu))
4395                         bogosum += cpu_data(cpu)->loops_per_jiffy;
4396  
4397 -       printk(KERN_INFO "Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
4398 +       printk(KERN_INFO "Total of %lu processors activated (%lu.%02lu BogoMIPS).\n",
4399                num_online_cpus(), bogosum/(500000/HZ), (bogosum/(5000/HZ))%100);
4400  }
4401  
4402 diff -Nru a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
4403 --- a/arch/ia64/kernel/sys_ia64.c       Wed Jul  9 09:56:58 2003
4404 +++ b/arch/ia64/kernel/sys_ia64.c       Mon Aug 25 14:45:43 2003
4405 @@ -242,7 +242,7 @@
4406  asmlinkage unsigned long
4407  sys_mmap (unsigned long addr, unsigned long len, int prot, int flags, int fd, long off)
4408  {
4409 -       if ((off & ~PAGE_MASK) != 0)
4410 +       if (offset_in_page(off) != 0)
4411                 return -EINVAL;
4412  
4413         addr = do_mmap2(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
4414 diff -Nru a/arch/ia64/lib/Makefile b/arch/ia64/lib/Makefile
4415 --- a/arch/ia64/lib/Makefile    Fri Jun 20 12:48:24 2003
4416 +++ b/arch/ia64/lib/Makefile    Mon Aug 25 09:56:27 2003
4417 @@ -14,9 +14,6 @@
4418  lib-$(CONFIG_PERFMON)  += carta_random.o
4419  lib-$(CONFIG_MD_RAID5) += xor.o
4420  
4421 -IGNORE_FLAGS_OBJS =    __divsi3.o __udivsi3.o __modsi3.o __umodsi3.o \
4422 -                       __divdi3.o __udivdi3.o __moddi3.o __umoddi3.o
4423 -
4424  AFLAGS___divdi3.o      =
4425  AFLAGS___udivdi3.o     = -DUNSIGNED
4426  AFLAGS___moddi3.o      =            -DMODULO
4427 @@ -27,26 +24,26 @@
4428  AFLAGS___modsi3.o      =            -DMODULO
4429  AFLAGS___umodsi3.o     = -DUNSIGNED -DMODULO
4430  
4431 -$(obj)/__divdi3.o: $(src)/idiv64.S
4432 -       $(cmd_as_o_S)
4433 +$(obj)/__divdi3.o: $(src)/idiv64.S FORCE
4434 +       $(call if_changed_dep,as_o_S)
4435  
4436 -$(obj)/__udivdi3.o: $(src)/idiv64.S
4437 -       $(cmd_as_o_S)
4438 +$(obj)/__udivdi3.o: $(src)/idiv64.S FORCE
4439 +       $(call if_changed_dep,as_o_S)
4440  
4441 -$(obj)/__moddi3.o: $(src)/idiv64.S
4442 -       $(cmd_as_o_S)
4443 +$(obj)/__moddi3.o: $(src)/idiv64.S FORCE
4444 +       $(call if_changed_dep,as_o_S)
4445  
4446 -$(obj)/__umoddi3.o: $(src)/idiv64.S
4447 -       $(cmd_as_o_S)
4448 +$(obj)/__umoddi3.o: $(src)/idiv64.S FORCE
4449 +       $(call if_changed_dep,as_o_S)
4450  
4451 -$(obj)/__divsi3.o: $(src)/idiv32.S
4452 -       $(cmd_as_o_S)
4453 +$(obj)/__divsi3.o: $(src)/idiv32.S FORCE
4454 +       $(call if_changed_dep,as_o_S)
4455  
4456 -$(obj)/__udivsi3.o: $(src)/idiv32.S
4457 -       $(cmd_as_o_S)
4458 +$(obj)/__udivsi3.o: $(src)/idiv32.S FORCE
4459 +       $(call if_changed_dep,as_o_S)
4460  
4461 -$(obj)/__modsi3.o: $(src)/idiv32.S
4462 -       $(cmd_as_o_S)
4463 +$(obj)/__modsi3.o: $(src)/idiv32.S FORCE
4464 +       $(call if_changed_dep,as_o_S)
4465  
4466 -$(obj)/__umodsi3.o: $(src)/idiv32.S
4467 -       $(cmd_as_o_S)
4468 +$(obj)/__umodsi3.o: $(src)/idiv32.S FORCE
4469 +       $(call if_changed_dep,as_o_S)
4470 diff -Nru a/arch/ia64/mm/numa.c b/arch/ia64/mm/numa.c
4471 --- a/arch/ia64/mm/numa.c       Mon Sep 30 06:38:28 2002
4472 +++ b/arch/ia64/mm/numa.c       Thu Aug 21 05:02:28 2003
4473 @@ -42,5 +42,5 @@
4474                     paddr < node_memblk[i].start_paddr + node_memblk[i].size)
4475                         break;
4476  
4477 -       return (i < num_memblks) ? node_memblk[i].nid : -1;
4478 +       return (i < num_memblks) ? node_memblk[i].nid : (num_memblks ? -1 : 0);
4479  }
4480 diff -Nru a/arch/ia64/sn/io/drivers/ioconfig_bus.c b/arch/ia64/sn/io/drivers/ioconfig_bus.c
4481 --- a/arch/ia64/sn/io/drivers/ioconfig_bus.c    Mon May 19 05:42:35 2003
4482 +++ b/arch/ia64/sn/io/drivers/ioconfig_bus.c    Sun Aug 31 16:14:08 2003
4483 @@ -346,9 +346,9 @@
4484  }
4485  
4486  struct file_operations ioconfig_bus_fops = {
4487 -       ioctl:ioconfig_bus_ioctl,
4488 -       open:ioconfig_bus_open,         /* open */
4489 -       release:ioconfig_bus_close      /* release */
4490 +       .ioctl = ioconfig_bus_ioctl,
4491 +       .open = ioconfig_bus_open,              /* open */
4492 +       .release = ioconfig_bus_close   /* release */
4493  };
4494  
4495  
4496 diff -Nru a/arch/ia64/sn/io/sn2/shub.c b/arch/ia64/sn/io/sn2/shub.c
4497 --- a/arch/ia64/sn/io/sn2/shub.c        Mon Aug  4 10:02:37 2003
4498 +++ b/arch/ia64/sn/io/sn2/shub.c        Sun Aug 31 16:14:08 2003
4499 @@ -243,7 +243,7 @@
4500  }
4501  
4502  struct file_operations shub_mon_fops = {
4503 -               ioctl:          shubstats_ioctl,
4504 +               .ioctl          = shubstats_ioctl,
4505  };
4506  
4507  /*
4508 diff -Nru a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c
4509 --- a/arch/ia64/sn/kernel/setup.c       Sat Aug 16 16:26:35 2003
4510 +++ b/arch/ia64/sn/kernel/setup.c       Sun Aug 31 16:14:08 2003
4511 @@ -117,14 +117,14 @@
4512   * VGA color display.
4513   */
4514  struct screen_info sn_screen_info = {
4515 -       orig_x:                  0,
4516 -       orig_y:                  0,
4517 -       orig_video_mode:         3,
4518 -       orig_video_cols:        80,
4519 -       orig_video_ega_bx:       3,
4520 -       orig_video_lines:       25,
4521 -       orig_video_isVGA:        1,
4522 -       orig_video_points:      16
4523 +       .orig_x                 = 0,
4524 +       .orig_y                 = 0,
4525 +       .orig_video_mode        = 3,
4526 +       .orig_video_cols        = 80,
4527 +       .orig_video_ega_bx      = 3,
4528 +       .orig_video_lines       = 25,
4529 +       .orig_video_isVGA       = 1,
4530 +       .orig_video_points      = 16
4531  };
4532  
4533  /*
4534 diff -Nru a/arch/m68k/Kconfig b/arch/m68k/Kconfig
4535 --- a/arch/m68k/Kconfig Sat Aug  2 14:26:16 2003
4536 +++ b/arch/m68k/Kconfig Sun Aug 31 16:14:22 2003
4537 @@ -342,40 +342,6 @@
4538  
4539  menu "General setup"
4540  
4541 -choice
4542 -       prompt "Kernel core (/proc/kcore) format"
4543 -       depends on PROC_FS
4544 -       default KCORE_ELF
4545 -
4546 -config KCORE_ELF
4547 -       bool "ELF"
4548 -       ---help---
4549 -         If you enabled support for /proc file system then the file
4550 -         /proc/kcore will contain the kernel core image. This can be used
4551 -         in gdb:
4552 -
4553 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
4554 -
4555 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
4556 -         /proc/kcore appear in ELF core format as defined by the Executable
4557 -         and Linking Format specification. Selecting A.OUT will choose the
4558 -         old "a.out" format which may be necessary for some old versions
4559 -         of binutils or on some architectures.
4560 -
4561 -         This is especially useful if you have compiled the kernel with the
4562 -         "-g" option to preserve debugging information. It is mainly used
4563 -         for examining kernel data structures on the live kernel so if you
4564 -         don't understand what this means or are not a kernel hacker, just
4565 -         leave it at its default value ELF.
4566 -
4567 -config KCORE_AOUT
4568 -       bool "A.OUT"
4569 -       help
4570 -         Not necessary unless you're using a very out-of-date binutils
4571 -         version.  You probably want KCORE_ELF.
4572 -
4573 -endchoice
4574 -
4575  source "fs/Kconfig.binfmt"
4576  
4577  config ZORRO
4578 diff -Nru a/arch/m68k/kernel/vmlinux-std.lds b/arch/m68k/kernel/vmlinux-std.lds
4579 --- /dev/null   Wed Dec 31 16:00:00 1969
4580 +++ b/arch/m68k/kernel/vmlinux-std.lds  Sun Jun 15 03:46:43 2003
4581 @@ -0,0 +1,97 @@
4582 +/* ld script to make m68k Linux kernel */
4583 +
4584 +#include <asm-generic/vmlinux.lds.h>
4585 +
4586 +OUTPUT_FORMAT("elf32-m68k", "elf32-m68k", "elf32-m68k")
4587 +OUTPUT_ARCH(m68k)
4588 +ENTRY(_start)
4589 +jiffies = jiffies_64 + 4;
4590 +SECTIONS
4591 +{
4592 +  . = 0x1000;
4593 +  _text = .;                   /* Text and read-only data */
4594 +  .text : {
4595 +       *(.text)
4596 +       *(.fixup)
4597 +       *(.gnu.warning)
4598 +       } = 0x4e75
4599 +
4600 +  . = ALIGN(16);               /* Exception table */
4601 +  __start___ex_table = .;
4602 +  __ex_table : { *(__ex_table) }
4603 +  __stop___ex_table = .;
4604 +
4605 +  RODATA
4606 +
4607 +  _etext = .;                  /* End of text section */
4608 +
4609 +  .data : {                    /* Data */
4610 +       *(.data)
4611 +       CONSTRUCTORS
4612 +       }
4613 +
4614 +  .bss : { *(.bss) }           /* BSS */
4615 +
4616 +  . = ALIGN(16);
4617 +  .data.cacheline_aligned : { *(.data.cacheline_aligned) }
4618 +
4619 +  _edata = .;                  /* End of data section */
4620 +
4621 +  /* will be freed after init */
4622 +  . = ALIGN(4096);             /* Init code and data */
4623 +  __init_begin = .;
4624 +  .init.text : { 
4625 +       _sinittext = .;
4626 +       *(.init.text)
4627 +       _einittext = .;
4628 +  }
4629 +  .init.data : { *(.init.data) }
4630 +  . = ALIGN(16);
4631 +  __setup_start = .;
4632 +  .init.setup : { *(.init.setup) }
4633 +  __setup_end = .;
4634 +  __start___param = .;
4635 +  __param : { *(__param) }
4636 +  __stop___param = .;
4637 +  __initcall_start = .;
4638 +  .initcall.init : {
4639 +       *(.initcall1.init) 
4640 +       *(.initcall2.init) 
4641 +       *(.initcall3.init) 
4642 +       *(.initcall4.init) 
4643 +       *(.initcall5.init) 
4644 +       *(.initcall6.init) 
4645 +       *(.initcall7.init)
4646 +  }
4647 +  __initcall_end = .;
4648 +  __con_initcall_start = .;
4649 +  .con_initcall.init : { *(.con_initcall.init) }
4650 +  __con_initcall_end = .;
4651 +  SECURITY_INIT
4652 +  . = ALIGN(8192);
4653 +  __initramfs_start = .;
4654 +  .init.ramfs : { *(.init.ramfs) }
4655 +  __initramfs_end = .;
4656 +  . = ALIGN(8192);
4657 +  __init_end = .;
4658 +
4659 +  .data.init_task : { *(.data.init_task) }     /* The initial task and kernel stack */
4660 +
4661 +  _end = . ;
4662 +
4663 +  /* Sections to be discarded */
4664 +  /DISCARD/ : {
4665 +       *(.exit.text)
4666 +       *(.exit.data)
4667 +       *(.exitcall.exit)
4668 +       }
4669 +
4670 +  /* Stabs debugging sections.  */
4671 +  .stab 0 : { *(.stab) }
4672 +  .stabstr 0 : { *(.stabstr) }
4673 +  .stab.excl 0 : { *(.stab.excl) }
4674 +  .stab.exclstr 0 : { *(.stab.exclstr) }
4675 +  .stab.index 0 : { *(.stab.index) }
4676 +  .stab.indexstr 0 : { *(.stab.indexstr) }
4677 +  .comment 0 : { *(.comment) }
4678 +}
4679 diff -Nru a/arch/m68k/kernel/vmlinux-sun3.lds b/arch/m68k/kernel/vmlinux-sun3.lds
4680 --- /dev/null   Wed Dec 31 16:00:00 1969
4681 +++ b/arch/m68k/kernel/vmlinux-sun3.lds Sun Jun 15 03:46:43 2003
4682 @@ -0,0 +1,97 @@
4683 +/* ld script to make m68k Linux kernel */
4684 +
4685 +#include <asm-generic/vmlinux.lds.h>
4686 +
4687 +OUTPUT_FORMAT("elf32-m68k", "elf32-m68k", "elf32-m68k")
4688 +OUTPUT_ARCH(m68k)
4689 +ENTRY(_start)
4690 +jiffies = jiffies_64 + 4;
4691 +SECTIONS
4692 +{
4693 +  . = 0xE004000;
4694 +  _text = .;                   /* Text and read-only data */
4695 +  .text : {
4696 +       *(.head)
4697 +       *(.text)
4698 +       *(.fixup)
4699 +       *(.gnu.warning)
4700 +       } = 0x4e75
4701 +       RODATA
4702 +
4703 +  _etext = .;                  /* End of text section */
4704 +
4705 +  .data : {                    /* Data */
4706 +       *(.data)
4707 +       CONSTRUCTORS
4708 +       . = ALIGN(16);          /* Exception table */
4709 +       __start___ex_table = .;
4710 +       *(__ex_table) 
4711 +       __stop___ex_table = .;
4712 +       }
4713 +  /* End of data goes *here* so that freeing init code works properly. */
4714 +  _edata = .;
4715 +
4716 +  /* will be freed after init */
4717 +  . = ALIGN(8192);     /* Init code and data */
4718 +__init_begin = .;
4719 +       .init.text : { 
4720 +               _sinittext = .;
4721 +               *(.init.text)
4722 +               _einittext = .;
4723 +       }
4724 +       .init.data : { *(.init.data) }
4725 +       . = ALIGN(16);
4726 +       __setup_start = .;
4727 +       .init.setup : { *(.init.setup) }
4728 +       __setup_end = .;
4729 +       __start___param = .;
4730 +       __param : { *(__param) }
4731 +       __stop___param = .;
4732 +       __initcall_start = .;
4733 +       .initcall.init : {
4734 +               *(.initcall1.init) 
4735 +               *(.initcall2.init) 
4736 +               *(.initcall3.init) 
4737 +               *(.initcall4.init) 
4738 +               *(.initcall5.init) 
4739 +               *(.initcall6.init) 
4740 +               *(.initcall7.init)
4741 +       }
4742 +       __initcall_end = .;
4743 +       __con_initcall_start = .;
4744 +       .con_initcall.init : { *(.con_initcall.init) }
4745 +       __con_initcall_end = .;
4746 +       SECURITY_INIT
4747 +       . = ALIGN(8192);
4748 +       __initramfs_start = .;
4749 +       .init.ramfs : { *(.init.ramfs) }
4750 +       __initramfs_end = .;
4751 +       . = ALIGN(8192);
4752 +       __init_end = .;
4753 +       .init.task : { *(init_task) }
4754 +       
4755 +
4756 +  .bss : { *(.bss) }           /* BSS */
4757 +
4758 +  _end = . ;
4759 +
4760 +  /* Sections to be discarded */
4761 +  /DISCARD/ : {
4762 +       *(.exit.text)
4763 +       *(.exit.data)
4764 +       *(.exitcall.exit)
4765 +       }
4766 +
4767 +  .crap : {
4768 +       /* Stabs debugging sections.  */
4769 +       *(.stab)
4770 +       *(.stabstr)
4771 +       *(.stab.excl)
4772 +       *(.stab.exclstr)
4773 +       *(.stab.index)
4774 +       *(.stab.indexstr)
4775 +       *(.comment)
4776 +       *(.note)
4777 +  }
4778 +
4779 +}
4780 diff -Nru a/arch/m68k/vmlinux-std.lds b/arch/m68k/vmlinux-std.lds
4781 --- a/arch/m68k/vmlinux-std.lds Wed Jun 11 17:40:05 2003
4782 +++ /dev/null   Wed Dec 31 16:00:00 1969
4783 @@ -1,97 +0,0 @@
4784 -/* ld script to make m68k Linux kernel */
4785 -
4786 -#include <asm-generic/vmlinux.lds.h>
4787 -
4788 -OUTPUT_FORMAT("elf32-m68k", "elf32-m68k", "elf32-m68k")
4789 -OUTPUT_ARCH(m68k)
4790 -ENTRY(_start)
4791 -jiffies = jiffies_64 + 4;
4792 -SECTIONS
4793 -{
4794 -  . = 0x1000;
4795 -  _text = .;                   /* Text and read-only data */
4796 -  .text : {
4797 -       *(.text)
4798 -       *(.fixup)
4799 -       *(.gnu.warning)
4800 -       } = 0x4e75
4801 -
4802 -  . = ALIGN(16);               /* Exception table */
4803 -  __start___ex_table = .;
4804 -  __ex_table : { *(__ex_table) }
4805 -  __stop___ex_table = .;
4806 -
4807 -  RODATA
4808 -
4809 -  _etext = .;                  /* End of text section */
4810 -
4811 -  .data : {                    /* Data */
4812 -       *(.data)
4813 -       CONSTRUCTORS
4814 -       }
4815 -
4816 -  .bss : { *(.bss) }           /* BSS */
4817 -
4818 -  . = ALIGN(16);
4819 -  .data.cacheline_aligned : { *(.data.cacheline_aligned) }
4820 -
4821 -  _edata = .;                  /* End of data section */
4822 -
4823 -  /* will be freed after init */
4824 -  . = ALIGN(4096);             /* Init code and data */
4825 -  __init_begin = .;
4826 -  .init.text : { 
4827 -       _sinittext = .;
4828 -       *(.init.text)
4829 -       _einittext = .;
4830 -  }
4831 -  .init.data : { *(.init.data) }
4832 -  . = ALIGN(16);
4833 -  __setup_start = .;
4834 -  .init.setup : { *(.init.setup) }
4835 -  __setup_end = .;
4836 -  __start___param = .;
4837 -  __param : { *(__param) }
4838 -  __stop___param = .;
4839 -  __initcall_start = .;
4840 -  .initcall.init : {
4841 -       *(.initcall1.init) 
4842 -       *(.initcall2.init) 
4843 -       *(.initcall3.init) 
4844 -       *(.initcall4.init) 
4845 -       *(.initcall5.init) 
4846 -       *(.initcall6.init) 
4847 -       *(.initcall7.init)
4848 -  }
4849 -  __initcall_end = .;
4850 -  __con_initcall_start = .;
4851 -  .con_initcall.init : { *(.con_initcall.init) }
4852 -  __con_initcall_end = .;
4853 -  SECURITY_INIT
4854 -  . = ALIGN(8192);
4855 -  __initramfs_start = .;
4856 -  .init.ramfs : { *(.init.ramfs) }
4857 -  __initramfs_end = .;
4858 -  . = ALIGN(8192);
4859 -  __init_end = .;
4860 -
4861 -  .data.init_task : { *(.data.init_task) }     /* The initial task and kernel stack */
4862 -
4863 -  _end = . ;
4864 -
4865 -  /* Sections to be discarded */
4866 -  /DISCARD/ : {
4867 -       *(.exit.text)
4868 -       *(.exit.data)
4869 -       *(.exitcall.exit)
4870 -       }
4871 -
4872 -  /* Stabs debugging sections.  */
4873 -  .stab 0 : { *(.stab) }
4874 -  .stabstr 0 : { *(.stabstr) }
4875 -  .stab.excl 0 : { *(.stab.excl) }
4876 -  .stab.exclstr 0 : { *(.stab.exclstr) }
4877 -  .stab.index 0 : { *(.stab.index) }
4878 -  .stab.indexstr 0 : { *(.stab.indexstr) }
4879 -  .comment 0 : { *(.comment) }
4880 -}
4881 diff -Nru a/arch/m68k/vmlinux-sun3.lds b/arch/m68k/vmlinux-sun3.lds
4882 --- a/arch/m68k/vmlinux-sun3.lds        Wed Jun 11 17:40:05 2003
4883 +++ /dev/null   Wed Dec 31 16:00:00 1969
4884 @@ -1,97 +0,0 @@
4885 -/* ld script to make m68k Linux kernel */
4886 -
4887 -#include <asm-generic/vmlinux.lds.h>
4888 -
4889 -OUTPUT_FORMAT("elf32-m68k", "elf32-m68k", "elf32-m68k")
4890 -OUTPUT_ARCH(m68k)
4891 -ENTRY(_start)
4892 -jiffies = jiffies_64 + 4;
4893 -SECTIONS
4894 -{
4895 -  . = 0xE004000;
4896 -  _text = .;                   /* Text and read-only data */
4897 -  .text : {
4898 -       *(.head)
4899 -       *(.text)
4900 -       *(.fixup)
4901 -       *(.gnu.warning)
4902 -       } = 0x4e75
4903 -       RODATA
4904 -
4905 -  _etext = .;                  /* End of text section */
4906 -
4907 -  .data : {                    /* Data */
4908 -       *(.data)
4909 -       CONSTRUCTORS
4910 -       . = ALIGN(16);          /* Exception table */
4911 -       __start___ex_table = .;
4912 -       *(__ex_table) 
4913 -       __stop___ex_table = .;
4914 -       }
4915 -  /* End of data goes *here* so that freeing init code works properly. */
4916 -  _edata = .;
4917 -
4918 -  /* will be freed after init */
4919 -  . = ALIGN(8192);     /* Init code and data */
4920 -__init_begin = .;
4921 -       .init.text : { 
4922 -               _sinittext = .;
4923 -               *(.init.text)
4924 -               _einittext = .;
4925 -       }
4926 -       .init.data : { *(.init.data) }
4927 -       . = ALIGN(16);
4928 -       __setup_start = .;
4929 -       .init.setup : { *(.init.setup) }
4930 -       __setup_end = .;
4931 -       __start___param = .;
4932 -       __param : { *(__param) }
4933 -       __stop___param = .;
4934 -       __initcall_start = .;
4935 -       .initcall.init : {
4936 -               *(.initcall1.init) 
4937 -               *(.initcall2.init) 
4938 -               *(.initcall3.init) 
4939 -               *(.initcall4.init) 
4940 -               *(.initcall5.init) 
4941 -               *(.initcall6.init) 
4942 -               *(.initcall7.init)
4943 -       }
4944 -       __initcall_end = .;
4945 -       __con_initcall_start = .;
4946 -       .con_initcall.init : { *(.con_initcall.init) }
4947 -       __con_initcall_end = .;
4948 -       SECURITY_INIT
4949 -       . = ALIGN(8192);
4950 -       __initramfs_start = .;
4951 -       .init.ramfs : { *(.init.ramfs) }
4952 -       __initramfs_end = .;
4953 -       . = ALIGN(8192);
4954 -       __init_end = .;
4955 -       .init.task : { *(init_task) }
4956 -       
4957 -
4958 -  .bss : { *(.bss) }           /* BSS */
4959 -
4960 -  _end = . ;
4961 -
4962 -  /* Sections to be discarded */
4963 -  /DISCARD/ : {
4964 -       *(.exit.text)
4965 -       *(.exit.data)
4966 -       *(.exitcall.exit)
4967 -       }
4968 -
4969 -  .crap : {
4970 -       /* Stabs debugging sections.  */
4971 -       *(.stab)
4972 -       *(.stabstr)
4973 -       *(.stab.excl)
4974 -       *(.stab.exclstr)
4975 -       *(.stab.index)
4976 -       *(.stab.indexstr)
4977 -       *(.comment)
4978 -       *(.note)
4979 -  }
4980 -
4981 -}
4982 diff -Nru a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig
4983 --- a/arch/m68knommu/Kconfig    Sat Aug  2 14:26:16 2003
4984 +++ b/arch/m68knommu/Kconfig    Sun Aug 31 16:14:22 2003
4985 @@ -490,14 +490,6 @@
4986  
4987  menu "Executable file formats"
4988  
4989 -config KCORE_AOUT
4990 -       bool
4991 -       default y
4992 -
4993 -config KCORE_ELF
4994 -       bool
4995 -       default y
4996 -
4997  source "fs/Kconfig.binfmt"
4998  
4999  endmenu
5000 diff -Nru a/arch/m68knommu/platform/5206/config.c b/arch/m68knommu/platform/5206/config.c
5001 --- a/arch/m68knommu/platform/5206/config.c     Tue May 27 20:13:12 2003
5002 +++ b/arch/m68knommu/platform/5206/config.c     Sat Aug 23 06:07:40 2003
5003 @@ -14,6 +14,7 @@
5004  #include <linux/sched.h>
5005  #include <linux/param.h>
5006  #include <linux/init.h>
5007 +#include <linux/interrupt.h>
5008  #include <asm/irq.h>
5009  #include <asm/dma.h>
5010  #include <asm/traps.h>
5011 @@ -26,7 +27,7 @@
5012  /***************************************************************************/
5013  
5014  void coldfire_tick(void);
5015 -void coldfire_timer_init(void (*handler)(int, void *, struct pt_regs *));
5016 +void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
5017  unsigned long coldfire_timer_offset(void);
5018  void coldfire_trap_init(void);
5019  void coldfire_reset(void);
5020 diff -Nru a/arch/m68knommu/platform/5206e/config.c b/arch/m68knommu/platform/5206e/config.c
5021 --- a/arch/m68knommu/platform/5206e/config.c    Tue May 27 20:13:12 2003
5022 +++ b/arch/m68knommu/platform/5206e/config.c    Sat Aug 23 06:07:40 2003
5023 @@ -12,6 +12,7 @@
5024  #include <linux/kernel.h>
5025  #include <linux/sched.h>
5026  #include <linux/param.h>
5027 +#include <linux/interrupt.h>
5028  #include <asm/irq.h>
5029  #include <asm/dma.h>
5030  #include <asm/traps.h>
5031 @@ -26,7 +27,7 @@
5032  /***************************************************************************/
5033  
5034  void coldfire_tick(void);
5035 -void coldfire_timer_init(void (*handler)(int, void *, struct pt_regs *));
5036 +void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
5037  unsigned long coldfire_timer_offset(void);
5038  void coldfire_trap_init(void);
5039  void coldfire_reset(void);
5040 diff -Nru a/arch/m68knommu/platform/5249/config.c b/arch/m68knommu/platform/5249/config.c
5041 --- a/arch/m68knommu/platform/5249/config.c     Tue Jun 17 06:35:38 2003
5042 +++ b/arch/m68knommu/platform/5249/config.c     Sat Aug 23 06:07:40 2003
5043 @@ -26,7 +26,7 @@
5044  /***************************************************************************/
5045  
5046  void coldfire_tick(void);
5047 -void coldfire_timer_init(void (*handler)(int, void *, struct pt_regs *));
5048 +void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
5049  unsigned long coldfire_timer_offset(void);
5050  void coldfire_trap_init(void);
5051  void coldfire_reset(void);
5052 diff -Nru a/arch/m68knommu/platform/5272/config.c b/arch/m68knommu/platform/5272/config.c
5053 --- a/arch/m68knommu/platform/5272/config.c     Tue Jun 17 06:35:38 2003
5054 +++ b/arch/m68knommu/platform/5272/config.c     Sat Aug 23 06:07:40 2003
5055 @@ -14,6 +14,7 @@
5056  #include <linux/sched.h>
5057  #include <linux/param.h>
5058  #include <linux/init.h>
5059 +#include <linux/interrupt.h>
5060  #include <asm/irq.h>
5061  #include <asm/dma.h>
5062  #include <asm/traps.h>
5063 @@ -27,7 +28,7 @@
5064  /***************************************************************************/
5065  
5066  void coldfire_tick(void);
5067 -void coldfire_timer_init(void (*handler)(int, void *, struct pt_regs *));
5068 +void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
5069  unsigned long coldfire_timer_offset(void);
5070  void coldfire_trap_init(void);
5071  void coldfire_reset(void);
5072 diff -Nru a/arch/mips/Kconfig b/arch/mips/Kconfig
5073 --- a/arch/mips/Kconfig Mon Jul 28 04:57:50 2003
5074 +++ b/arch/mips/Kconfig Sun Aug 31 16:14:22 2003
5075 @@ -1126,31 +1126,6 @@
5076  
5077  menu "Executable file formats"
5078  
5079 -config KCORE_ELF
5080 -       bool
5081 -       default y
5082 -       ---help---
5083 -         If you enabled support for /proc file system then the file
5084 -         /proc/kcore will contain the kernel core image. This can be used
5085 -         in gdb:
5086 -
5087 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
5088 -
5089 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
5090 -         /proc/kcore appear in ELF core format as defined by the Executable
5091 -         and Linking Format specification. Selecting A.OUT will choose the
5092 -         old "a.out" format which may be necessary for some old versions
5093 -         of binutils or on some architectures.
5094 -
5095 -         This is especially useful if you have compiled the kernel with the
5096 -         "-g" option to preserve debugging information. It is mainly used
5097 -         for examining kernel data structures on the live kernel so if you
5098 -         don't understand what this means or are not a kernel hacker, just
5099 -         leave it at its default value ELF.
5100 -
5101 -config KCORE_AOUT
5102 -       bool
5103 -
5104  source "fs/Kconfig.binfmt"
5105  
5106  config TRAD_SIGNALS
5107 diff -Nru a/arch/mips/au1000/common/dma.c b/arch/mips/au1000/common/dma.c
5108 --- a/arch/mips/au1000/common/dma.c     Mon Jun 23 12:12:26 2003
5109 +++ b/arch/mips/au1000/common/dma.c     Sun Aug 31 16:14:08 2003
5110 @@ -62,14 +62,14 @@
5111  spinlock_t au1000_dma_spin_lock = SPIN_LOCK_UNLOCKED;
5112  
5113  struct dma_chan au1000_dma_table[NUM_AU1000_DMA_CHANNELS] = {
5114 -      {dev_id:-1,},
5115 -      {dev_id:-1,},
5116 -      {dev_id:-1,},
5117 -      {dev_id:-1,},
5118 -      {dev_id:-1,},
5119 -      {dev_id:-1,},
5120 -      {dev_id:-1,},
5121 -      {dev_id:-1,}
5122 +      {.dev_id = -1,},
5123 +      {.dev_id = -1,},
5124 +      {.dev_id = -1,},
5125 +      {.dev_id = -1,},
5126 +      {.dev_id = -1,},
5127 +      {.dev_id = -1,},
5128 +      {.dev_id = -1,},
5129 +      {.dev_id = -1,}
5130  };
5131  
5132  // Device FIFO addresses and default DMA modes
5133 diff -Nru a/arch/mips/kernel/ioctl32.c b/arch/mips/kernel/ioctl32.c
5134 --- a/arch/mips/kernel/ioctl32.c        Mon Jul 28 04:57:50 2003
5135 +++ b/arch/mips/kernel/ioctl32.c        Sun Aug 31 16:14:44 2003
5136 @@ -810,8 +810,7 @@
5137  #define IOCTL_TABLE_START \
5138         struct ioctl_trans ioctl_start[] = {
5139  #define IOCTL_TABLE_END \
5140 -       }; struct ioctl_trans ioctl_end[0];
5141 -
5142 +       };
5143  
5144  IOCTL_TABLE_START
5145  #include <linux/compat_ioctl.h>
5146 @@ -1205,6 +1204,8 @@
5147  COMPATIBLE_IOCTL(RTC_WKALM_SET)
5148  COMPATIBLE_IOCTL(RTC_WKALM_RD)
5149  IOCTL_TABLE_END
5150 +
5151 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
5152  
5153  #define NR_IOCTL_TRANS         (sizeof(ioctl_translations) /   \
5154                                  sizeof(ioctl_translations[0]))
5155 diff -Nru a/arch/mips/sibyte/cfe/console.c b/arch/mips/sibyte/cfe/console.c
5156 --- a/arch/mips/sibyte/cfe/console.c    Mon Jul 28 04:57:50 2003
5157 +++ b/arch/mips/sibyte/cfe/console.c    Sun Aug 31 16:14:08 2003
5158 @@ -9,7 +9,6 @@
5159  #include "cfe_error.h"
5160  
5161  extern int cfe_cons_handle;
5162 -static kdev_t cfe_consdev;
5163  
5164  static void cfe_console_write(struct console *cons, const char *str,
5165                        unsigned int count)
5166 @@ -57,15 +56,12 @@
5167  #ifdef CONFIG_SIBYTE_SB1250_DUART
5168                 if (!strcmp(consdev, "uart0")) {
5169                         setleds("u0cn");
5170 -//                     cfe_consdev = MKDEV(TTY_MAJOR, SB1250_DUART_MINOR_BASE + 0);
5171                 } else if (!strcmp(consdev, "uart1")) {
5172                         setleds("u1cn");
5173 -//                     cfe_consdev = MKDEV(TTY_MAJOR, SB1250_DUART_MINOR_BASE + 1);
5174  #endif
5175  #ifdef CONFIG_VGA_CONSOLE
5176                 } else if (!strcmp(consdev, "pcconsole0")) {
5177                         setleds("pccn");
5178 -//                     cfe_consdev = MKDEV(TTY_MAJOR, 0);
5179  #endif
5180                 } else
5181                         return -ENODEV;
5182 @@ -74,12 +70,12 @@
5183  }
5184  
5185  static struct console sb1250_cfe_cons = {
5186 -       name:           "cfe",
5187 -       write:          cfe_console_write,
5188 -       device:         cfe_console_device,
5189 -       setup:          cfe_console_setup,
5190 -       flags:          CON_PRINTBUFFER,
5191 -       index:          -1,
5192 +       .name           = "cfe",
5193 +       .write          = cfe_console_write,
5194 +       .device         = cfe_console_device,
5195 +       .setup          = cfe_console_setup,
5196 +       .flags          = CON_PRINTBUFFER,
5197 +       .index          = -1,
5198  };
5199  
5200  static int __init sb1250_cfe_console_init(void)
5201 diff -Nru a/arch/mips/sibyte/sb1250/bcm1250_tbprof.c b/arch/mips/sibyte/sb1250/bcm1250_tbprof.c
5202 --- a/arch/mips/sibyte/sb1250/bcm1250_tbprof.c  Mon Jul 28 04:57:50 2003
5203 +++ b/arch/mips/sibyte/sb1250/bcm1250_tbprof.c  Tue Aug 26 09:25:40 2003
5204 @@ -253,7 +253,7 @@
5205  {
5206         int minor;
5207  
5208 -       minor = minor(inode->i_rdev);
5209 +       minor = iminor(inode);
5210         if (minor != 0) {
5211                 return -ENODEV;
5212         }
5213 @@ -278,7 +278,7 @@
5214  {
5215         int minor;
5216  
5217 -       minor = minor(inode->i_rdev);
5218 +       minor = iminor(inode);
5219         if (minor != 0 || !sbp.open) {
5220                 return -ENODEV;
5221         }
5222 diff -Nru a/arch/mips/tx4927/common/tx4927_irq.c b/arch/mips/tx4927/common/tx4927_irq.c
5223 --- a/arch/mips/tx4927/common/tx4927_irq.c      Mon Apr 14 20:10:10 2003
5224 +++ b/arch/mips/tx4927/common/tx4927_irq.c      Sun Aug 31 16:14:08 2003
5225 @@ -149,26 +149,26 @@
5226  
5227  #define TX4927_CP0_NAME "TX4927-CP0"
5228  static struct hw_interrupt_type tx4927_irq_cp0_type = {
5229 -       typename:       TX4927_CP0_NAME,
5230 -       startup:        tx4927_irq_cp0_startup,
5231 -       shutdown:       tx4927_irq_cp0_shutdown,
5232 -       enable:         tx4927_irq_cp0_enable,
5233 -       disable:        tx4927_irq_cp0_disable,
5234 -       ack:            tx4927_irq_cp0_mask_and_ack,
5235 -       end:            tx4927_irq_cp0_end,
5236 -       set_affinity:   NULL
5237 +       .typename       = TX4927_CP0_NAME,
5238 +       .startup        = tx4927_irq_cp0_startup,
5239 +       .shutdown       = tx4927_irq_cp0_shutdown,
5240 +       .enable         = tx4927_irq_cp0_enable,
5241 +       .disable        = tx4927_irq_cp0_disable,
5242 +       .ack            = tx4927_irq_cp0_mask_and_ack,
5243 +       .end            = tx4927_irq_cp0_end,
5244 +       .set_affinity   = NULL
5245  };
5246  
5247  #define TX4927_PIC_NAME "TX4927-PIC"
5248  static struct hw_interrupt_type tx4927_irq_pic_type = {
5249 -       typename:       TX4927_PIC_NAME,
5250 -       startup:        tx4927_irq_pic_startup,
5251 -       shutdown:       tx4927_irq_pic_shutdown,
5252 -       enable:         tx4927_irq_pic_enable,
5253 -       disable:        tx4927_irq_pic_disable,
5254 -       ack:            tx4927_irq_pic_mask_and_ack,
5255 -       end:            tx4927_irq_pic_end,
5256 -       set_affinity:   NULL
5257 +       .typename       = TX4927_PIC_NAME,
5258 +       .startup        = tx4927_irq_pic_startup,
5259 +       .shutdown       = tx4927_irq_pic_shutdown,
5260 +       .enable         = tx4927_irq_pic_enable,
5261 +       .disable        = tx4927_irq_pic_disable,
5262 +       .ack            = tx4927_irq_pic_mask_and_ack,
5263 +       .end            = tx4927_irq_pic_end,
5264 +       .set_affinity   = NULL
5265  };
5266  
5267  #define TX4927_PIC_ACTION(s) { no_action, 0, 0, s, NULL, NULL }
5268 diff -Nru a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
5269 --- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c  Thu Jul  3 15:17:43 2003
5270 +++ b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c  Sun Aug 31 16:14:08 2003
5271 @@ -255,14 +255,14 @@
5272  
5273  #define TOSHIBA_RBTX4927_IOC_NAME "RBTX4927-IOC"
5274  static struct hw_interrupt_type toshiba_rbtx4927_irq_ioc_type = {
5275 -       typename:TOSHIBA_RBTX4927_IOC_NAME,
5276 -       startup:toshiba_rbtx4927_irq_ioc_startup,
5277 -       shutdown:toshiba_rbtx4927_irq_ioc_shutdown,
5278 -       enable:toshiba_rbtx4927_irq_ioc_enable,
5279 -       disable:toshiba_rbtx4927_irq_ioc_disable,
5280 -       ack:toshiba_rbtx4927_irq_ioc_mask_and_ack,
5281 -       end:toshiba_rbtx4927_irq_ioc_end,
5282 -       set_affinity:NULL
5283 +       .typename = TOSHIBA_RBTX4927_IOC_NAME,
5284 +       .startup = toshiba_rbtx4927_irq_ioc_startup,
5285 +       .shutdown = toshiba_rbtx4927_irq_ioc_shutdown,
5286 +       .enable = toshiba_rbtx4927_irq_ioc_enable,
5287 +       .disable = toshiba_rbtx4927_irq_ioc_disable,
5288 +       .ack = toshiba_rbtx4927_irq_ioc_mask_and_ack,
5289 +       .end = toshiba_rbtx4927_irq_ioc_end,
5290 +       .set_affinity = NULL
5291  };
5292  #define TOSHIBA_RBTX4927_IOC_INTR_ENAB 0xbc002000
5293  #define TOSHIBA_RBTX4927_IOC_INTR_STAT 0xbc002006
5294 @@ -271,14 +271,14 @@
5295  #ifdef CONFIG_TOSHIBA_FPCIB0
5296  #define TOSHIBA_RBTX4927_ISA_NAME "RBTX4927-ISA"
5297  static struct hw_interrupt_type toshiba_rbtx4927_irq_isa_type = {
5298 -       typename:TOSHIBA_RBTX4927_ISA_NAME,
5299 -       startup:toshiba_rbtx4927_irq_isa_startup,
5300 -       shutdown:toshiba_rbtx4927_irq_isa_shutdown,
5301 -       enable:toshiba_rbtx4927_irq_isa_enable,
5302 -       disable:toshiba_rbtx4927_irq_isa_disable,
5303 -       ack:toshiba_rbtx4927_irq_isa_mask_and_ack,
5304 -       end:toshiba_rbtx4927_irq_isa_end,
5305 -       set_affinity:NULL
5306 +       .typename = TOSHIBA_RBTX4927_ISA_NAME,
5307 +       .startup = toshiba_rbtx4927_irq_isa_startup,
5308 +       .shutdown = toshiba_rbtx4927_irq_isa_shutdown,
5309 +       .enable = toshiba_rbtx4927_irq_isa_enable,
5310 +       .disable = toshiba_rbtx4927_irq_isa_disable,
5311 +       .ack = toshiba_rbtx4927_irq_isa_mask_and_ack,
5312 +       .end = toshiba_rbtx4927_irq_isa_end,
5313 +       .set_affinity = NULL
5314  };
5315  #endif
5316  
5317 diff -Nru a/arch/mips/vr41xx/common/vrc4173.c b/arch/mips/vr41xx/common/vrc4173.c
5318 --- a/arch/mips/vr41xx/common/vrc4173.c Thu Jul 31 08:59:17 2003
5319 +++ b/arch/mips/vr41xx/common/vrc4173.c Sun Aug 31 16:14:08 2003
5320 @@ -250,10 +250,10 @@
5321  }
5322  
5323  static struct pci_driver vrc4173_driver = {
5324 -       name:           "NEC VRC4173",
5325 -       probe:          vrc4173_probe,
5326 -       remove:         NULL,
5327 -       id_table:       vrc4173_table,
5328 +       .name           = "NEC VRC4173",
5329 +       .probe          = vrc4173_probe,
5330 +       .remove         = NULL,
5331 +       .id_table       = vrc4173_table,
5332  };
5333  
5334  static int __devinit vrc4173_init(void)
5335 diff -Nru a/arch/parisc/Kconfig b/arch/parisc/Kconfig
5336 --- a/arch/parisc/Kconfig       Sat Aug  2 14:26:16 2003
5337 +++ b/arch/parisc/Kconfig       Sun Aug 31 16:14:22 2003
5338 @@ -161,11 +161,6 @@
5339  
5340  menu "Executable file formats"
5341  
5342 -config KCORE_ELF
5343 -       bool
5344 -       depends on PROC_FS
5345 -       default y
5346 -
5347  source "fs/Kconfig.binfmt"
5348  
5349  endmenu
5350 diff -Nru a/arch/parisc/kernel/ioctl32.c b/arch/parisc/kernel/ioctl32.c
5351 --- a/arch/parisc/kernel/ioctl32.c      Fri May  2 10:22:56 2003
5352 +++ b/arch/parisc/kernel/ioctl32.c      Sun Aug 31 16:14:44 2003
5353 @@ -1426,7 +1426,7 @@
5354                 return -EINVAL;
5355                         
5356         tty = (struct tty_struct *)file->private_data;
5357 -       if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
5358 +       if (tty_paranoia_check(tty, inode, "tty_ioctl"))
5359                 return -EINVAL;
5360                                                         
5361         if (tty->driver->ioctl != vt_ioctl)
5362 @@ -2458,7 +2458,7 @@
5363  #define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL(cmd, sys_ioctl) 
5364  
5365  #define IOCTL_TABLE_START  struct ioctl_trans ioctl_start[] = {
5366 -#define IOCTL_TABLE_END    }; struct ioctl_trans ioctl_end[0];
5367 +#define IOCTL_TABLE_END    };
5368  
5369  IOCTL_TABLE_START
5370  #include <linux/compat_ioctl.h>
5371 @@ -2631,3 +2631,4 @@
5372  #endif /* DRM */
5373  IOCTL_TABLE_END
5374  
5375 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
5376 diff -Nru a/arch/ppc/8260_io/uart.c b/arch/ppc/8260_io/uart.c
5377 --- a/arch/ppc/8260_io/uart.c   Wed Jun 11 12:32:53 2003
5378 +++ b/arch/ppc/8260_io/uart.c   Tue Aug 26 09:25:39 2003
5379 @@ -50,6 +50,10 @@
5380  #include <asm/cpm_8260.h>
5381  #include <asm/irq.h>
5382  
5383 +#ifdef CONFIG_MAGIC_SYSRQ
5384 +#include <linux/sysrq.h>
5385 +#endif
5386 +
5387  #ifdef CONFIG_SERIAL_CONSOLE
5388  #include <linux/console.h>
5389  
5390 @@ -77,6 +81,14 @@
5391  static struct tty_driver *serial_driver;
5392  static int serial_console_setup(struct console *co, char *options);
5393  
5394 +static void serial_console_write(struct console *c, const char *s,
5395 +                                               unsigned count);
5396 +static kdev_t serial_console_device(struct console *c);
5397 +
5398 +#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
5399 +static unsigned long break_pressed; /* break, really ... */
5400 +#endif
5401 +
5402  /*
5403   * Serial driver configuration section.  Here are the various options:
5404   */
5405 @@ -208,6 +220,15 @@
5406         cbd_t                   *tx_cur;
5407  } ser_info_t;
5408  
5409 +static struct console sercons = {
5410 +       .name =         "ttyS",
5411 +       .write =        serial_console_write,
5412 +       .device =       serial_console_device,
5413 +       .setup =        serial_console_setup,
5414 +       .flags =        CON_PRINTBUFFER,
5415 +       .index =        CONFIG_SERIAL_CONSOLE_PORT,
5416 +};
5417 +
5418  static void change_speed(ser_info_t *info);
5419  static void rs_8xx_wait_until_sent(struct tty_struct *tty, int timeout);
5420  
5421 @@ -328,7 +349,7 @@
5422         schedule_work(&info->tqueue);
5423  }
5424  
5425 -static _INLINE_ void receive_chars(ser_info_t *info)
5426 +static _INLINE_ void receive_chars(ser_info_t *info, struct pt_regs *regs)
5427  {
5428         struct tty_struct *tty = info->tty;
5429         unsigned char ch, *cp;
5430 @@ -450,6 +471,19 @@
5431                                         }
5432                                 }
5433                         }
5434 +
5435 +#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
5436 +                       if (break_pressed && info->line == sercons.index) {
5437 +                               if (ch != 0 && time_before(jiffies,
5438 +                                                       break_pressed + HZ*5)) {
5439 +                                       handle_sysrq(ch, regs, NULL, NULL);
5440 +                                       break_pressed = 0;
5441 +                                       goto ignore_char;
5442 +                               } else
5443 +                                       break_pressed = 0;
5444 +                       }
5445 +#endif
5446 +                       
5447                         if (tty->flip.count >= TTY_FLIPBUF_SIZE)
5448                                 break;
5449  
5450 @@ -458,6 +492,10 @@
5451                         tty->flip.count++;
5452                 }
5453  
5454 +#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
5455 +       ignore_char:
5456 +#endif
5457 +
5458                 /* This BD is ready to be used again.  Clear status.
5459                  * Get next BD.
5460                  */
5461 @@ -475,7 +513,36 @@
5462         schedule_delayed_work(&tty->flip.work, 1);
5463  }
5464  
5465 -static _INLINE_ void transmit_chars(ser_info_t *info)
5466 +static _INLINE_ void receive_break(ser_info_t *info, struct pt_regs *regs)
5467 +{
5468 +       struct tty_struct *tty = info->tty;
5469 +
5470 +       info->state->icount.brk++;
5471 +
5472 +#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
5473 +       if (info->line == sercons.index) {
5474 +               if (!break_pressed) {
5475 +                       break_pressed = jiffies;
5476 +                       return;
5477 +               } else
5478 +                       break_pressed = 0;
5479 +       }
5480 +#endif
5481 +
5482 +       /* Check to see if there is room in the tty buffer for
5483 +        * the break.  If not, we exit now, losing the break.  FIXME
5484 +        */
5485 +       if ((tty->flip.count + 1) >= TTY_FLIPBUF_SIZE)
5486 +               return;
5487 +       *(tty->flip.flag_buf_ptr++) = TTY_BREAK;
5488 +       *(tty->flip.char_buf_ptr++) = 0;
5489 +       tty->flip.count++;
5490 +
5491 +       queue_task(&tty->flip.tqueue, &tq_timer);
5492 +}
5493 +
5494 +
5495 +static _INLINE_ void transmit_chars(ser_info_t *info, struct pt_regs *regs)
5496  {
5497         
5498         if (info->flags & TX_WAKEUP) {
5499 @@ -575,19 +642,23 @@
5500         if ((idx = info->state->smc_scc_num) < SCC_NUM_BASE) {
5501                 smcp = &immr->im_smc[idx];
5502                 events = smcp->smc_smce;
5503 +               if (events & SMCM_BRKE)
5504 +                       receive_break(info, regs);
5505                 if (events & SMCM_RX)
5506 -                       receive_chars(info);
5507 +                       receive_chars(info, regs);
5508                 if (events & SMCM_TX)
5509 -                       transmit_chars(info);
5510 +                       transmit_chars(info, regs);
5511                 smcp->smc_smce = events;
5512         }
5513         else {
5514                 sccp = &immr->im_scc[idx - SCC_IDX_BASE];
5515                 events = sccp->scc_scce;
5516 +               if (events & SMCM_BRKE)
5517 +                       receive_break(info, regs);
5518                 if (events & SCCM_RX)
5519 -                       receive_chars(info);
5520 +                       receive_chars(info, regs);
5521                 if (events & SCCM_TX)
5522 -                       transmit_chars(info);
5523 +                       transmit_chars(info, regs);
5524                 sccp->scc_scce = events;
5525         }
5526         
5527 @@ -2207,7 +2278,7 @@
5528  static void serial_console_write(struct console *c, const char *s,
5529                                 unsigned count)
5530  {
5531 -#if defined(CONFIG_KGDB) && !defined(CONFIG_USE_SERIAL2_KGDB)
5532 +#if defined(CONFIG_KGDB_CONSOLE) && !defined(CONFIG_USE_SERIAL2_KGDB)
5533         /* Try to let stub handle output. Returns true if it did. */ 
5534         if (kgdb_output_string(s, count))
5535                 return;
5536 @@ -2391,21 +2462,11 @@
5537  }
5538  #endif
5539  
5540 -static kdev_t serial_console_device(struct console *c)
5541 +static struct tty_driver *serial_console_device(struct console *c, int *index)
5542  {
5543         *index = c->index;
5544         return serial_driver;
5545  }
5546 -
5547 -
5548 -static struct console sercons = {
5549 -       .name =         "ttyS",
5550 -       .write =        serial_console_write,
5551 -       .device =       serial_console_device,
5552 -       .setup =        serial_console_setup,
5553 -       .flags =        CON_PRINTBUFFER,
5554 -       .index =        CONFIG_SERIAL_CONSOLE_PORT,
5555 -};
5556  
5557  /*
5558   *     Register console.
5559 diff -Nru a/arch/ppc/8xx_io/cs4218_tdm.c b/arch/ppc/8xx_io/cs4218_tdm.c
5560 --- a/arch/ppc/8xx_io/cs4218_tdm.c      Tue Jul 15 10:01:29 2003
5561 +++ b/arch/ppc/8xx_io/cs4218_tdm.c      Tue Aug 26 09:25:40 2003
5562 @@ -2106,11 +2106,11 @@
5563          */
5564         cs4218_ctl_write(cs4218_control);
5565  
5566 -       sound.minDev = MINOR(inode->i_rdev) & 0x0f;
5567 +       sound.minDev = iminor(inode) & 0x0f;
5568         sound.soft = sound.dsp;
5569         sound.hard = sound.dsp;
5570         sound_init();
5571 -       if ((MINOR(inode->i_rdev) & 0x0f) == SND_DEV_AUDIO) {
5572 +       if ((iminor(inode) & 0x0f) == SND_DEV_AUDIO) {
5573                 sound_set_speed(8000);
5574                 sound_set_stereo(0);
5575                 sound_set_format(AFMT_MU_LAW);
5576 diff -Nru a/arch/ppc/8xx_io/uart.c b/arch/ppc/8xx_io/uart.c
5577 --- a/arch/ppc/8xx_io/uart.c    Wed Jun 11 12:32:54 2003
5578 +++ b/arch/ppc/8xx_io/uart.c    Thu Aug 21 15:10:37 2003
5579 @@ -1068,7 +1068,7 @@
5580         volatile cbd_t *bdp;
5581         unsigned char   *cp;
5582  
5583 -#ifdef CONFIG_KGDB
5584 +#ifdef CONFIG_KGDB_CONSOLE
5585          /* Try to let stub handle output. Returns true if it did. */ 
5586          if (kgdb_output_string(buf, count))
5587              return ret;
5588 @@ -2271,7 +2271,7 @@
5589  static void serial_console_write(struct console *c, const char *s,
5590                                 unsigned count)
5591  {
5592 -#ifdef CONFIG_KGDB
5593 +#ifdef CONFIG_KGDB_CONSOLE
5594         /* Try to let stub handle output. Returns true if it did. */ 
5595         if (kgdb_output_string(s, count))
5596                 return;
5597 diff -Nru a/arch/ppc/Kconfig b/arch/ppc/Kconfig
5598 --- a/arch/ppc/Kconfig  Mon Aug  4 16:10:57 2003
5599 +++ b/arch/ppc/Kconfig  Sun Aug 31 16:14:22 2003
5600 @@ -795,22 +795,6 @@
5601         bool "PCI for Permedia2"
5602         depends on !4xx && !8xx && APUS
5603  
5604 -# only elf supported, a.out is not -- Cort
5605 -config KCORE_ELF
5606 -       bool
5607 -       depends on PROC_FS
5608 -       default y
5609 -       help
5610 -         If you enabled support for /proc file system then the file
5611 -         /proc/kcore will contain the kernel core image in ELF format. This
5612 -         can be used in gdb:
5613 -
5614 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
5615 -
5616 -         This is especially useful if you have compiled the kernel with the
5617 -         "-g" option to preserve debugging information. It is mainly used
5618 -         for examining kernel data structures on the live kernel.
5619 -
5620  config KERNEL_ELF
5621         bool
5622         default y
5623 @@ -1277,16 +1261,11 @@
5624           floppy controller, say Y here. Most commonly found in PowerMacs.
5625  
5626  config MAC_SERIAL
5627 -       tristate "Support for PowerMac serial ports"
5628 +       tristate "Support for PowerMac serial ports (OBSOLETE DRIVER)"
5629         depends on PPC_PMAC
5630         help
5631 -         If you have Macintosh style serial ports (8 pin mini-DIN), say Y
5632 -         here. If you also have regular serial ports and enable the driver
5633 -         for them, you can't currently use the serial console feature.
5634 -
5635 -config SERIAL_CONSOLE
5636 -       bool "Support for console on serial port"
5637 -       depends on PPC_PMAC && MAC_SERIAL=y
5638 +         This driver is obsolete. Use CONFIG_SERIAL_PMACZILOG in
5639 +         "Character devices --> Serial drivers --> PowerMac z85c30" option.
5640  
5641  config ADB
5642         bool "Apple Desktop Bus (ADB) support"
5643 @@ -1426,20 +1405,12 @@
5644  config KGDB
5645         bool "Include kgdb kernel debugger"
5646         depends on DEBUG_KERNEL
5647 +       select DEBUG_INFO
5648         help
5649           Include in-kernel hooks for kgdb, the Linux kernel source level
5650           debugger.  See <http://kgdb.sourceforge.net/> for more information.
5651           Unless you are intending to debug the kernel, say N here.
5652  
5653 -config DEBUG_INFO
5654 -       bool "Compile the kernel with debug info"
5655 -       depends on DEBUG_KERNEL
5656 -       help
5657 -          If you say Y here the resulting kernel image will include
5658 -         debugging info resulting in a larger kernel image.
5659 -         Say Y here only if you plan to use gdb to debug the kernel.
5660 -         If you don't debug the kernel, you can say N.
5661 -         
5662  choice
5663         prompt "Serial Port"
5664         depends on KGDB
5665 @@ -1459,6 +1430,14 @@
5666  
5667  endchoice
5668  
5669 +config KGDB_CONSOLE
5670 +       bool "Enable serial console thru kgdb port"
5671 +       depends on KGDB && 8xx || 8260
5672 +       help
5673 +         If you enable this, all serial console messages will be sent
5674 +         over the gdb stub.
5675 +         If unsure, say N.
5676 +
5677  config XMON
5678         bool "Include xmon kernel debugger"
5679         depends on DEBUG_KERNEL
5680 @@ -1474,18 +1453,16 @@
5681           Unless you are intending to debug the kernel with one of these
5682           machines, say N here.
5683  
5684 -config MORE_COMPILE_OPTIONS
5685 -       bool "Add any additional compile options"
5686 -       depends on DEBUG_KERNEL && (KGDB || XMON || BDI_SWITCH)
5687 -       help
5688 -         If you want to add additional CFLAGS to the kernel build, such as -g
5689 -         for KGDB or the BDI2000, enable this option and then enter what you
5690 -         would like to add in the next question.
5691 -
5692 -config COMPILE_OPTIONS
5693 -       string "Additional compile arguments"
5694 -       depends on MORE_COMPILE_OPTIONS
5695 -       default "-g -ggdb"
5696 +config DEBUG_INFO
5697 +       bool "Compile the kernel with debug info"
5698 +       depends on DEBUG_KERNEL
5699 +       default y if BDI_SWITCH || XMON
5700 +       help
5701 +          If you say Y here the resulting kernel image will include
5702 +         debugging info resulting in a larger kernel image.
5703 +         Say Y here only if you plan to use some sort of debugger to
5704 +         debug the kernel.
5705 +         If you don't debug the kernel, you can say N.
5706  
5707  config BOOTX_TEXT
5708         bool "Support for early boot text console (BootX or OpenFirmware only)"
5709 diff -Nru a/arch/ppc/Makefile b/arch/ppc/Makefile
5710 --- a/arch/ppc/Makefile Sun Jul 27 15:52:30 2003
5711 +++ b/arch/ppc/Makefile Thu Aug 21 15:10:37 2003
5712 @@ -22,9 +22,6 @@
5713  
5714  cflags-$(CONFIG_4xx)           += -Wa,-m405
5715  cflags-$(CONFIG_PPC64BRIDGE)   += -Wa,-mppc64bridge
5716 -# Use sed to remove the quotes.
5717 -cflags-$(CONFIG_MORE_COMPILE_OPTIONS) += \
5718 -       $(shell echo $(CONFIG_COMPILE_OPTIONS) | sed -e 's/"//g')
5719  
5720  CFLAGS += $(cflags-y)
5721  
5722 diff -Nru a/arch/ppc/boot/common/ns16550.c b/arch/ppc/boot/common/ns16550.c
5723 --- a/arch/ppc/boot/common/ns16550.c    Sat Jun 28 11:06:53 2003
5724 +++ b/arch/ppc/boot/common/ns16550.c    Wed Aug 20 10:24:16 2003
5725 @@ -60,7 +60,7 @@
5726         else {
5727                 /* Input clock. */
5728                 outb(com_port + (UART_DLL << shift),
5729 -                    (BASE_BAUD / SERIAL_BAUD));
5730 +                    (BASE_BAUD / SERIAL_BAUD) & 0xFF);
5731                 outb(com_port + (UART_DLM << shift),
5732                      (BASE_BAUD / SERIAL_BAUD) >> 8);
5733                 /* 8 data, 1 stop, no parity */
5734 diff -Nru a/arch/ppc/boot/common/util.S b/arch/ppc/boot/common/util.S
5735 --- a/arch/ppc/boot/common/util.S       Tue Feb 25 11:37:43 2003
5736 +++ b/arch/ppc/boot/common/util.S       Thu Aug 21 10:17:00 2003
5737 @@ -160,9 +160,22 @@
5738         blr
5739  
5740  
5741 +/* udelay (on non-601 processors) needs to know the period of the
5742 + * timebase in nanoseconds.  This used to be hardcoded to be 60ns
5743 + * (period of 66MHz/4).  Now a variable is used that is initialized to
5744 + * 60 for backward compatibility, but it can be overridden as necessary
5745 + * with code something like this:
5746 + *    extern unsigned long timebase_period_ns;
5747 + *    timebase_period_ns = 1000000000 / bd->bi_tbfreq;
5748 + */
5749 +       .data
5750 +       .globl timebase_period_ns
5751 +timebase_period_ns:
5752 +       .long   60
5753 +
5754 +       .text
5755  /*
5756   * Delay for a number of microseconds
5757 - * -- Use the BUS timer (assumes 66MHz)
5758   */
5759         .globl  udelay
5760  udelay:
5761 @@ -180,8 +193,13 @@
5762  
5763  .udelay_not_601:
5764         mulli   r4,r3,1000      /* nanoseconds */
5765 -       addi    r4,r4,59
5766 -       li      r5,60
5767 +       /*  Change r4 to be the number of ticks using:  
5768 +        *      (nanoseconds + (timebase_period_ns - 1 )) / timebase_period_ns
5769 +        *  timebase_period_ns defaults to 60 (16.6MHz) */
5770 +       lis     r5,timebase_period_ns@h
5771 +       lwz     r5,timebase_period_ns@l(r5)
5772 +       addi    r4,r4,r5
5773 +       addi    r4,r4,-1
5774         divw    r4,r4,r5        /* BUS ticks */
5775  1:     mftbu   r5
5776         mftb    r6
5777 diff -Nru a/arch/ppc/boot/include/of1275.h b/arch/ppc/boot/include/of1275.h
5778 --- a/arch/ppc/boot/include/of1275.h    Mon Sep 16 21:58:06 2002
5779 +++ b/arch/ppc/boot/include/of1275.h    Mon Aug 25 05:13:38 2003
5780 @@ -20,6 +20,7 @@
5781  /* function declarations */
5782  
5783  void * claim(unsigned int virt, unsigned int size, unsigned int align);
5784 +int    map(unsigned int phys, unsigned int virt, unsigned int size);
5785  void   enter(void);
5786  void   exit(void);
5787  phandle        finddevice(const char *name);
5788 diff -Nru a/arch/ppc/boot/ld.script b/arch/ppc/boot/ld.script
5789 --- a/arch/ppc/boot/ld.script   Thu May 29 04:06:53 2003
5790 +++ b/arch/ppc/boot/ld.script   Mon Aug 25 05:13:38 2003
5791 @@ -66,7 +66,7 @@
5792    _edata  =  .;
5793    PROVIDE (edata = .);
5794  
5795 -  . = ALIGN(8);
5796 +  . = ALIGN(4096);
5797    __bss_start = .;
5798    .bss       :
5799    {
5800 diff -Nru a/arch/ppc/boot/of1275/Makefile b/arch/ppc/boot/of1275/Makefile
5801 --- a/arch/ppc/boot/of1275/Makefile     Sun Jun  8 01:12:49 2003
5802 +++ b/arch/ppc/boot/of1275/Makefile     Mon Aug 25 09:36:40 2003
5803 @@ -3,4 +3,4 @@
5804  #
5805  
5806  lib-y := claim.o enter.o exit.o finddevice.o getprop.o ofinit.o        \
5807 -        ofstdio.o read.o release.o write.o
5808 +        ofstdio.o read.o release.o write.o map.o
5809 diff -Nru a/arch/ppc/boot/of1275/map.c b/arch/ppc/boot/of1275/map.c
5810 --- /dev/null   Wed Dec 31 16:00:00 1969
5811 +++ b/arch/ppc/boot/of1275/map.c        Mon Aug 25 09:36:40 2003
5812 @@ -0,0 +1,50 @@
5813
5814 +/*
5815 + * Copyright (C) Paul Mackerras 1997.
5816 + * Copyright (C) Leigh Brown 2002.
5817 + *
5818 + * This program is free software; you can redistribute it and/or
5819 + * modify it under the terms of the GNU General Public License
5820 + * as published by the Free Software Foundation; either version
5821 + * 2 of the License, or (at your option) any later version.
5822 + */
5823 +
5824 +#include "of1275.h"
5825 +#include "nonstdio.h"
5826 +
5827 +extern ihandle of_prom_mmu;
5828 +
5829 +int
5830 +map(unsigned int phys, unsigned int virt, unsigned int size)
5831 +{
5832 +    struct prom_args {
5833 +       char *service;
5834 +       int nargs;
5835 +       int nret;
5836 +       char *method;
5837 +       ihandle mmu_ihandle;    
5838 +       int misc;
5839 +       unsigned int phys;
5840 +       unsigned int virt;
5841 +       unsigned int size;
5842 +       int ret0;
5843 +       int ret1;
5844 +    } args;
5845 +
5846 +    if (of_prom_mmu == 0) {
5847 +       printf("map() called, no MMU found\n");
5848 +       return -1;
5849 +    }
5850 +    args.service = "call-method";
5851 +    args.nargs = 6;
5852 +    args.nret = 2;
5853 +    args.method = "map";
5854 +    args.mmu_ihandle = of_prom_mmu;
5855 +    args.misc = -1;
5856 +    args.phys = phys;
5857 +    args.virt = virt;
5858 +    args.size = size;
5859 +    (*of_prom_entry)(&args);
5860 +
5861 +    return (int)args.ret0;
5862 +}
5863 diff -Nru a/arch/ppc/boot/of1275/ofinit.c b/arch/ppc/boot/of1275/ofinit.c
5864 --- a/arch/ppc/boot/of1275/ofinit.c     Mon Sep 16 22:18:13 2002
5865 +++ b/arch/ppc/boot/of1275/ofinit.c     Mon Aug 25 05:13:38 2003
5866 @@ -11,9 +11,17 @@
5867  #include "of1275.h"
5868  
5869  prom_entry of_prom_entry;
5870 +ihandle of_prom_mmu;
5871  
5872  void
5873  ofinit(prom_entry prom_ptr)
5874  {
5875 +    phandle chosen;
5876 +
5877      of_prom_entry = prom_ptr;
5878 +   
5879 +    if ((chosen = finddevice("/chosen")) == OF_INVALID_HANDLE)
5880 +       return;
5881 +    if (getprop(chosen, "mmu", &of_prom_mmu, sizeof(ihandle)) != 4)
5882 +       return;
5883  }
5884 diff -Nru a/arch/ppc/boot/openfirmware/Makefile b/arch/ppc/boot/openfirmware/Makefile
5885 --- a/arch/ppc/boot/openfirmware/Makefile       Wed Jul 23 08:39:58 2003
5886 +++ b/arch/ppc/boot/openfirmware/Makefile       Mon Aug 25 05:13:38 2003
5887 @@ -22,7 +22,7 @@
5888  images := $(boot)/images
5889  
5890  OBJCOPY_ARGS   := -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment
5891 -COFF_LD_ARGS   := -T $(boot)/ld.script -e _start -Ttext 0x00700000 -Bstatic
5892 +COFF_LD_ARGS   := -T $(boot)/ld.script -e _start -Ttext 0x00500000 -Bstatic
5893  CHRP_LD_ARGS   := -T $(boot)/ld.script -e _start -Ttext 0x00800000
5894  NEWWORLD_LD_ARGS:= -T $(boot)/ld.script -e _start -Ttext 0x01000000
5895  
5896 diff -Nru a/arch/ppc/boot/openfirmware/coffmain.c b/arch/ppc/boot/openfirmware/coffmain.c
5897 --- a/arch/ppc/boot/openfirmware/coffmain.c     Thu Nov  7 03:31:11 2002
5898 +++ b/arch/ppc/boot/openfirmware/coffmain.c     Mon Aug 25 05:13:38 2003
5899 @@ -32,16 +32,16 @@
5900  char *begin_avail, *end_avail;
5901  char *avail_high;
5902  
5903 -#define RAM_START      0
5904 -#define RAM_END                (RAM_START + 0x800000)  /* only 8M mapped with BATs */
5905 -
5906 -#define PROG_START     RAM_START
5907 -#define PROG_SIZE      0x00700000
5908 -
5909  #define SCRATCH_SIZE   (128 << 10)
5910  
5911  static char heap[SCRATCH_SIZE];
5912  
5913 +static unsigned long ram_start = 0;
5914 +static unsigned long ram_end = 0x1000000;
5915 +static unsigned long prog_start = 0x800000;
5916 +static unsigned long prog_size = 0x800000;
5917 +
5918 +
5919  typedef void (*kernel_start_t)(int, int, void *);
5920  
5921  void boot(int a1, int a2, void *prom)
5922 @@ -52,32 +52,34 @@
5923      unsigned initrd_start, initrd_size;
5924      
5925      printf("coffboot starting: loaded at 0x%p\n", &_start);
5926 -    setup_bats(RAM_START);
5927 +    setup_bats(ram_start);
5928  
5929      initrd_size = (char *)(&__ramdisk_end) - (char *)(&__ramdisk_begin);
5930      if (initrd_size) {
5931 -       initrd_start = (RAM_END - initrd_size) & ~0xFFF;
5932 +       initrd_start = (ram_end - initrd_size) & ~0xFFF;
5933         a1 = initrd_start;
5934         a2 = initrd_size;
5935 -       claim(initrd_start, RAM_END - initrd_start, 0);
5936 +       claim(initrd_start, ram_end - initrd_start, 0);
5937         printf("initial ramdisk moving 0x%x <- 0x%p (%x bytes)\n\r",
5938                initrd_start, (char *)(&__ramdisk_begin), initrd_size);
5939         memcpy((char *)initrd_start, (char *)(&__ramdisk_begin), initrd_size);
5940 +       prog_size = initrd_start - prog_start;
5941      } else
5942         a2 = 0xdeadbeef;
5943  
5944      im = (char *)(&__image_begin);
5945      len = (char *)(&__image_end) - (char *)(&__image_begin);
5946 -    /* claim 4MB starting at 0 */
5947 -    claim(0, PROG_SIZE, 0);
5948 -    dst = (void *) RAM_START;
5949 +    /* claim 4MB starting at PROG_START */
5950 +    claim(prog_start, prog_size, 0);
5951 +    map(prog_start, prog_start, prog_size);
5952 +    dst = (void *) prog_start;
5953      if (im[0] == 0x1f && im[1] == 0x8b) {
5954         /* set up scratch space */
5955         begin_avail = avail_high = avail_ram = heap;
5956         end_avail = heap + sizeof(heap);
5957         printf("heap at 0x%p\n", avail_ram);
5958         printf("gunzipping (0x%p <- 0x%p:0x%p)...", dst, im, im+len);
5959 -       gunzip(dst, PROG_SIZE, im, &len);
5960 +       gunzip(dst, prog_size, im, &len);
5961         printf("done %u bytes\n", len);
5962         printf("%u bytes of heap consumed, max in use %u\n",
5963                avail_high - begin_avail, heap_max);
5964 @@ -87,9 +89,9 @@
5965  
5966      flush_cache(dst, len);
5967      make_bi_recs(((unsigned long) dst + len), "coffboot", _MACH_Pmac,
5968 -                   (PROG_START + PROG_SIZE));
5969 +                   (prog_start + prog_size));
5970  
5971 -    sa = (unsigned long)PROG_START;
5972 +    sa = (unsigned long)prog_start;
5973      printf("start address = 0x%x\n", sa);
5974  
5975      (*(kernel_start_t)sa)(a1, a2, prom);
5976 diff -Nru a/arch/ppc/boot/openfirmware/misc.S b/arch/ppc/boot/openfirmware/misc.S
5977 --- a/arch/ppc/boot/openfirmware/misc.S Mon Sep 16 21:54:12 2002
5978 +++ b/arch/ppc/boot/openfirmware/misc.S Mon Aug 25 05:13:38 2003
5979 @@ -9,7 +9,7 @@
5980         .text
5981  
5982  /*
5983 - * Use the BAT3 registers to map the 1st 8MB of RAM to
5984 + * Use the BAT2 & 3 registers to map the 1st 16MB of RAM to
5985   * the address given as the 1st argument.
5986   */
5987         .globl  setup_bats
5988 @@ -22,6 +22,10 @@
5989         mtibatl 3,0                     /* invalidate BAT first */
5990         ori     3,3,4                   /* set up BAT registers for 601 */
5991         li      4,0x7f
5992 +       mtibatu 2,3
5993 +       mtibatl 2,4
5994 +       oris    3,3,0x80
5995 +       oris    4,4,0x80
5996         mtibatu 3,3
5997         mtibatl 3,4
5998         b       5f
5999 @@ -29,6 +33,12 @@
6000         mtibatu 3,0
6001         ori     3,3,0xff                /* set up BAT registers for 604 */
6002         li      4,2
6003 +       mtdbatl 2,4
6004 +       mtdbatu 2,3
6005 +       mtibatl 2,4
6006 +       mtibatu 2,3
6007 +       oris    3,3,0x80
6008 +       oris    4,4,0x80
6009         mtdbatl 3,4
6010         mtdbatu 3,3
6011         mtibatl 3,4
6012 diff -Nru a/arch/ppc/boot/simple/Makefile b/arch/ppc/boot/simple/Makefile
6013 --- a/arch/ppc/boot/simple/Makefile     Tue Jul  1 17:01:18 2003
6014 +++ b/arch/ppc/boot/simple/Makefile     Mon Aug 18 09:44:01 2003
6015 @@ -22,7 +22,6 @@
6016  # get_mem_size(), which is memory controller dependent.  Add in the correct
6017  # XXX_memory.o file for this to work, as well as editing the $(MISC) file.
6018  
6019 -boot: zImage
6020  
6021  boot                           := arch/ppc/boot
6022  common                         := $(boot)/common
6023 @@ -32,86 +31,90 @@
6024  
6025  # Normally, we use the 'misc.c' file for decompress_kernel and
6026  # whatnot.  Sometimes we need to override this however.
6027 -MISC                           := misc.o
6028 -ifeq ($(CONFIG_IBM_OPENBIOS),y)
6029 -ZIMAGE                         := zImage-TREE
6030 -ZIMAGEINITRD                   := zImage.initrd-TREE
6031 -END                            := treeboot
6032 -TFTPIMAGE                      := /tftpboot/zImage.$(END)
6033 -MISC                           := misc-embedded.o
6034 -endif
6035 -ifeq ($(CONFIG_EMBEDDEDBOOT),y)
6036 -TFTPIMAGE                      := /tftpboot/zImage.embedded
6037 -MISC                           := misc-embedded.o
6038 -endif
6039 -ifeq ($(CONFIG_EBONY),y)
6040 -ZIMAGE                         := zImage-TREE
6041 -ZIMAGEINITRD                   := zImage.initrd-TREE
6042 -END                            := ebony
6043 -ENTRYPOINT                     := 0x01000000
6044 -TFTPIMAGE                      := /tftpboot/zImage.$(END)
6045 -endif
6046 -ifeq ($(CONFIG_EV64260),y)
6047 -EXTRA                          := misc-ev64260.o
6048 -TFTPIMAGE                      := /tftpboot/zImage.ev64260
6049 -endif
6050 -ifeq ($(CONFIG_GEMINI),y)
6051 -ZIMAGE                         := zImage-STRIPELF
6052 -ZIMAGEINITRD                   := zImage.initrd-STRIPELF
6053 -END                            := gemini
6054 -TFTPIMAGE                      := /tftpboot/zImage.$(END)
6055 -endif
6056 -ifeq ($(CONFIG_K2),y)
6057 -EXTRA                          := legacy.o
6058 -TFTPIMAGE                      := /tftpboot/zImage.k2
6059 -endif
6060 -# kbuild-2.4 'feature', only one of these will ever by 'y' at a time.
6061 +misc-y := misc.o
6062 +
6063 +#
6064 +# See arch/ppc/kconfig and arch/ppc/platforms/Kconfig
6065 +# for definition of what platform each config option refer to.
6066 +#----------------------------------------------------------------------------
6067 +      zimage-$(CONFIG_IBM_OPENBIOS)    := zImage-TREE
6068 +zimageinitrd-$(CONFIG_IBM_OPENBIOS)    := zImage.initrd-TREE
6069 +         end-$(CONFIG_IBM_OPENBIOS)    := treeboot
6070 +   tftpimage-$(CONFIG_IBM_OPENBIOS)    := /tftpboot/zImage.$(end-y)
6071 +        misc-$(CONFIG_IBM_OPENBIOS)    := misc-embedded.o
6072 +
6073 +   tftpimage-$(CONFIG_EMBEDDEDBOOT)    :=  /tftpboot/zImage.embedded
6074 +        misc-$(CONFIG_EMBEDDEDBOOT)    := misc-embedded.o
6075 +
6076 +      zimage-$(CONFIG_EBONY)           := zImage-TREE
6077 +zimageinitrd-$(CONFIG_EBONY)           := zImage.initrd-TREE
6078 +     extra.o-$(CONFIG_EBONY)           := direct.o
6079 +         end-$(CONFIG_EBONY)           := ebony
6080 +  entrypoint-$(CONFIG_EBONY)           := 0x01000000
6081 +   tftpimage-$(CONFIG_EBONY)           := /tftpboot/zImage.$(end-y)
6082 +
6083 +     extra.o-$(CONFIG_EV64260)         := direct.o misc-ev64260.o
6084 +   tftpimage-$(CONFIG_EV64260)         := /tftpboot/zImage.ev64260
6085 +
6086 +      zimage-$(CONFIG_GEMINI)          := zImage-STRIPELF
6087 +zimageinitrd-$(CONFIG_GEMINI)          := zImage.initrd-STRIPELF
6088 +         end-$(CONFIG_GEMINI)          := gemini
6089 +   tftpimage-$(CONFIG_GEMINI)          := /tftpboot/zImage.$(end-y)
6090 +
6091 +     extra.o-$(CONFIG_K2)              := legacy.o
6092 +   tftpimage-$(CONFIG_K2)              := /tftpboot/zImage.k2
6093 +
6094 +# kconfig 'feature', only one of these will ever by 'y' at a time.
6095  # The rest will be unset.
6096 -ifeq ($(CONFIG_MCPN765)$(CONFIG_MVME5100)$(CONFIG_PRPMC750)$(CONFIG_PRPMC800)$(CONFIG_LOPEC)$(CONFIG_PPLUS),y)
6097 -ZIMAGE                         := zImage-PPLUS
6098 -ZIMAGEINITRD                   := zImage.initrd-PPLUS
6099 -TFTPIMAGE                      := /tftpboot/zImage.pplus
6100 -ZNETBOOT                       := zImage.pplus
6101 -ZNETBOOTRD                     := zImage.initrd.pplus
6102 -endif
6103 -ifeq ($(CONFIG_PPLUS),y)
6104 -EXTRA                          := legacy.o
6105 -endif
6106 -ifeq ($(CONFIG_PCORE)$(CONFIG_POWERPMC250),y)
6107 -ZIMAGE                         := zImage-STRIPELF
6108 -ZIMAGEINITRD                   := zImage.initrd-STRIPELF
6109 -EXTRA                          := chrpmap.o
6110 -END                            := pcore
6111 -TFTPIMAGE                      := /tftpboot/zImage.$(END)
6112 -endif
6113 -ifeq ($(CONFIG_SANDPOINT),y)
6114 -TFTPIMAGE                      := /tftpboot/zImage.sandpoint
6115 -endif
6116 -ifeq ($(CONFIG_SPRUCE),y)
6117 -ZIMAGE                         := zImage-TREE
6118 -ZIMAGEINITRD                   := zImage.initrd-TREE
6119 -END                            := spruce
6120 -ENTRYPOINT                     := 0x00800000
6121 -MISC                           := misc-spruce.o
6122 -TFTPIMAGE                      := /tftpboot/zImage.$(END)
6123 -endif
6124 -ifeq ($(CONFIG_SMP),y)
6125 -TFTPIMAGE                      += .smp
6126 -endif
6127 -ifeq ($(CONFIG_REDWOOD_4),y)
6128 +multi := $(CONFIG_MCPN765)$(CONFIG_MVME5100)$(CONFIG_PRPMC750) \
6129 +$(CONFIG_PRPMC800)$(CONFIG_LOPEC)$(CONFIG_PPLUS)
6130 +      zimage-$(multi)                  := zImage-PPLUS
6131 +zimageinitrd-$(multi)                  := zImage.initrd-PPLUS
6132 +   tftpimage-$(multi)                  := /tftpboot/zImage.pplus
6133 +    znetboot-$(multi)                  := zImage.pplus
6134 +  znetbootrd-$(multi)                  := zImage.initrd.pplus
6135 +
6136 +# Overrides previous assingment
6137 +     extra.o-$(CONFIG_PPLUS)           := legacy.o
6138 +
6139 +      zimage-$(CONFIG_PCORE)           := zImage-STRIPELF
6140 +zimageinitrd-$(CONFIG_PCORE)           := zImage.initrd-STRIPELF
6141 +     extra.o-$(CONFIG_PCORE)           := chrpmap.o
6142 +         end-$(CONFIG_PCORE)           := pcore
6143 +   tftpimage-$(CONFIG_PCORE)           := /tftpboot/zImage.$(end-y)
6144 +
6145 +      zimage-$(CONFIG_POWERPMC250)     := zImage-STRIPELF
6146 +zimageinitrd-$(CONFIG_POWERPMC250)     := zImage.initrd-STRIPELF
6147 +     extra.o-$(CONFIG_POWERPMC250)     := chrpmap.o
6148 +         end-$(CONFIG_POWERPMC250)     := pcore
6149 +   tftpimage-$(CONFIG_POWERPMC250)     := /tftpboot/zImage.$(end-y)
6150 +
6151 +   tftpimage-$(CONFIG_SANDPOINT)       := /tftpboot/zImage.sandpoint
6152 +
6153 +      zimage-$(CONFIG_SPRUCE)          := zImage-TREE
6154 +zimageinitrd-$(CONFIG_SPRUCE)          := zImage.initrd-TREE
6155 +         end-$(CONFIG_SPRUCE)          := spruce
6156 +  entrypoint-$(CONFIG_SPRUCE)          := 0x00800000
6157 +        misc-$(CONFIG_SPRUCE)          := misc-spruce.o
6158 +   tftpimage-$(CONFIG_SPRUCE)          := /tftpboot/zImage.$(end-y)
6159 +
6160 +
6161 +# tftp image is prefixed with .smp if compiled for SMP
6162 +tftpimage-$(CONFIG_SMP)        += .smp
6163 +
6164  # This is a treeboot that needs init functions until the
6165  # boot rom is sorted out (i.e. this is short lived)
6166 -EXTRA_AFLAGS                   := -Wa,-m405
6167 -EXTRA                          := rw4/rw4_init.o rw4/rw4_init_brd.o
6168 -endif
6169 +extra-aflags-$(CONFIG_REDWOOD_4)       := -Wa,-m405
6170 +extra.o-$(CONFIG_REDWOOD_4)            := rw4/rw4_init.o rw4/rw4_init_brd.o
6171 +EXTRA_AFLAGS := $(extra-aflags-y)
6172  
6173  # Linker args.  This specifies where the image will be run at.
6174 -LD_ARGS                                = -T $(boot)/ld.script \
6175 -                                       -Ttext $(CONFIG_BOOT_LOAD) -Bstatic
6176 +LD_ARGS                                := -T $(boot)/ld.script \
6177 +                                  -Ttext $(CONFIG_BOOT_LOAD) -Bstatic
6178  OBJCOPY_ARGS                   := -O elf32-powerpc
6179  
6180  # head.o and relocate.o must be at the start.
6181 -boot-y                         := head.o relocate.o $(EXTRA) $(MISC) 
6182 +boot-y                         := head.o relocate.o $(extra.o-y) $(misc-y) 
6183  boot-$(CONFIG_40x)             += embed_config.o
6184  boot-$(CONFIG_8xx)             += embed_config.o
6185  boot-$(CONFIG_8260)            += embed_config.o
6186 @@ -160,40 +163,40 @@
6187                 -R .stabstr -R .sysmap
6188  
6189  # Sort-of dummy rules, that let us format the image we want.
6190 -zImage: $(images)/$(ZIMAGE) $(obj)/zvmlinux
6191 +zImage: $(images)/$(zimage-y) $(obj)/zvmlinux
6192         cp -f $(obj)/zvmlinux $(images)/zImage.elf
6193         rm -f $(obj)/zvmlinux
6194  
6195 -zImage.initrd: $(images)/$(ZIMAGEINITRD) $(obj)/zvmlinux.initrd
6196 +zImage.initrd: $(images)/$(zimageinitrd-y) $(obj)/zvmlinux.initrd
6197         cp -f $(obj)/zvmlinux.initrd $(images)/zImage.initrd.elf
6198         rm -f $(obj)/zvmlinux.initrd
6199  
6200  znetboot: zImage
6201  ifneq ($(ZNETBOOT),)
6202 -       cp $(images)/$(ZNETBOOT) $(TFTPIMAGE)
6203 +       cp $(images)/$(ZNETBOOT) $(tftpimage-y)
6204  else
6205 -       cp $(images)/zImage.* $(TFTPIMAGE)
6206 +       cp $(images)/zImage.* $(tftpimage-y)
6207  endif
6208  
6209  znetboot.initrd: zImage.initrd
6210 -ifneq ($(ZNETBOOTRD),)
6211 -       cp $(images)/$(ZNETBOOTRD) $(TFTPIMAGE)
6212 +ifneq ($(znetbootrd-y),)
6213 +       cp $(images)/$(znetbootrd-y) $(tftpimage-y)
6214  else
6215 -       cp $(images)/zImage.* $(TFTPIMAGE)
6216 +       cp $(images)/zImage.* $(tftpimage-y)
6217  endif
6218  
6219  $(images)/zImage-STRIPELF: $(obj)/zvmlinux
6220 -       dd if=$(obj)/zvmlinux of=$(images)/zImage.$(END) skip=64 bs=1k
6221 +       dd if=$(obj)/zvmlinux of=$(images)/zImage.$(end-y) skip=64 bs=1k
6222  
6223  $(images)/zImage.initrd-STRIPELF: $(obj)/zvmlinux.initrd
6224 -       dd if=$(obj)/zvmlinux.initrd of=$(images)/zImage.initrd.$(END) \
6225 +       dd if=$(obj)/zvmlinux.initrd of=$(images)/zImage.initrd.$(end-y) \
6226                 skip=64 bs=1k
6227  
6228  $(images)/zImage-TREE: $(obj)/zvmlinux $(MKTREE)
6229 -       $(MKTREE) $(obj)/zvmlinux $(images)/zImage.$(END) $(ENTRYPOINT)
6230 +       $(MKTREE) $(obj)/zvmlinux $(images)/zImage.$(end-y) $(ENTRYPOINT)
6231  
6232  $(images)/zImage.initrd-TREE: $(obj)/zvmlinux.initrd $(MKTREE)
6233 -       $(MKTREE) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(END) \
6234 +       $(MKTREE) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(end-y) \
6235                 $(ENTRYPOINT)
6236  
6237  $(images)/zImage-PPLUS: $(obj)/zvmlinux $(MKPREP) $(MKBUGBOOT)
6238 diff -Nru a/arch/ppc/boot/simple/embed_config.c b/arch/ppc/boot/simple/embed_config.c
6239 --- a/arch/ppc/boot/simple/embed_config.c       Sat Mar 22 17:18:48 2003
6240 +++ b/arch/ppc/boot/simple/embed_config.c       Thu Aug 21 10:17:00 2003
6241 @@ -20,6 +20,7 @@
6242  #ifdef CONFIG_40x
6243  #include <asm/io.h>
6244  #endif
6245 +extern unsigned long timebase_period_ns;
6246  
6247  /* For those boards that don't provide one.
6248  */
6249 @@ -768,6 +769,7 @@
6250  #if defined(CONFIG_REDWOOD_5) || defined (CONFIG_REDWOOD_6)
6251         bd->bi_tbfreq = 27 * 1000 * 1000;
6252  #endif
6253 +       timebase_period_ns = 1000000000 / bd->bi_tbfreq;
6254  }
6255  #endif /* CONFIG_BEECH */
6256  #endif /* CONFIG_IBM_OPENBIOS */
6257 diff -Nru a/arch/ppc/boot/simple/misc-embedded.c b/arch/ppc/boot/simple/misc-embedded.c
6258 --- a/arch/ppc/boot/simple/misc-embedded.c      Thu Jun  5 18:06:12 2003
6259 +++ b/arch/ppc/boot/simple/misc-embedded.c      Wed Aug 20 15:44:31 2003
6260 @@ -75,7 +75,7 @@
6261  extern void embed_config(bd_t **bp);
6262  
6263  unsigned long
6264 -decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, bd_t *bp)
6265 +load_kernel(unsigned long load_addr, int num_words, unsigned long cksum, bd_t *bp)
6266  {
6267         char *cp, ch;
6268         int timer = 0, zimage_size;
6269 diff -Nru a/arch/ppc/boot/simple/misc-spruce.c b/arch/ppc/boot/simple/misc-spruce.c
6270 --- a/arch/ppc/boot/simple/misc-spruce.c        Tue Feb 11 15:48:52 2003
6271 +++ b/arch/ppc/boot/simple/misc-spruce.c        Wed Aug 20 15:44:31 2003
6272 @@ -147,7 +147,7 @@
6273  #define MEM_B2EA       0x60
6274  
6275  unsigned long
6276 -decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum)
6277 +load_kernel(unsigned long load_addr, int num_words, unsigned long cksum)
6278  {
6279         int timer = 0;
6280         char *cp, ch;
6281 diff -Nru a/arch/ppc/boot/simple/misc.c b/arch/ppc/boot/simple/misc.c
6282 --- a/arch/ppc/boot/simple/misc.c       Tue Feb 11 15:48:52 2003
6283 +++ b/arch/ppc/boot/simple/misc.c       Wed Aug 20 15:44:31 2003
6284 @@ -252,3 +252,10 @@
6285  
6286         return (struct bi_record *)rec_loc;
6287  }
6288 +
6289 +/* Allow decompress_kernel to be hooked into.  This is the default. */
6290 +void * __attribute__ ((weak))
6291 +load_kernel(unsigned long load_addr, int num_words, unsigned long cksum)
6292 +{
6293 +               return decompress_kernel(load_addr, num_words, cksum);
6294 +}
6295 diff -Nru a/arch/ppc/boot/simple/relocate.S b/arch/ppc/boot/simple/relocate.S
6296 --- a/arch/ppc/boot/simple/relocate.S   Tue Feb 11 15:48:52 2003
6297 +++ b/arch/ppc/boot/simple/relocate.S   Wed Aug 20 15:44:31 2003
6298 @@ -183,7 +183,7 @@
6299         mr      r4,r7           /* Program length */
6300         mr      r5,r6           /* Checksum */
6301         mr      r6,r11          /* Residual data */
6302 -       bl      decompress_kernel
6303 +       bl      load_kernel
6304  
6305         /*
6306          * Make sure the kernel knows we don't have things set in
6307 diff -Nru a/arch/ppc/boot/utils/mktree.c b/arch/ppc/boot/utils/mktree.c
6308 --- a/arch/ppc/boot/utils/mktree.c      Sun Sep 15 21:51:58 2002
6309 +++ b/arch/ppc/boot/utils/mktree.c      Thu Aug 21 15:00:42 2003
6310 @@ -86,7 +86,7 @@
6311         }
6312  
6313         cksum = 0;
6314 -       cp = (uint *)&bt;
6315 +       cp = (void *)&bt;
6316         for (i=0; i<sizeof(bt)/sizeof(uint); i++)
6317                 cksum += *cp++;
6318         
6319 diff -Nru a/arch/ppc/configs/common_defconfig b/arch/ppc/configs/common_defconfig
6320 --- a/arch/ppc/configs/common_defconfig Sat Aug  2 13:06:57 2003
6321 +++ b/arch/ppc/configs/common_defconfig Sat Aug 23 02:33:38 2003
6322 @@ -9,6 +9,7 @@
6323  # Code maturity level options
6324  #
6325  CONFIG_EXPERIMENTAL=y
6326 +# CONFIG_BROKEN is not set
6327  
6328  #
6329  # General setup
6330 @@ -18,9 +19,15 @@
6331  # CONFIG_BSD_PROCESS_ACCT is not set
6332  CONFIG_SYSCTL=y
6333  CONFIG_LOG_BUF_SHIFT=14
6334 +CONFIG_IKCONFIG=y
6335 +CONFIG_IKCONFIG_PROC=y
6336  # CONFIG_EMBEDDED is not set
6337 +CONFIG_KALLSYMS=y
6338  CONFIG_FUTEX=y
6339  CONFIG_EPOLL=y
6340 +CONFIG_IOSCHED_NOOP=y
6341 +CONFIG_IOSCHED_AS=y
6342 +CONFIG_IOSCHED_DEADLINE=y
6343  
6344  #
6345  # Loadable module support
6346 @@ -86,8 +93,8 @@
6347  CONFIG_PCI=y
6348  CONFIG_PCI_DOMAINS=y
6349  CONFIG_KCORE_ELF=y
6350 -CONFIG_BINFMT_ELF=y
6351  CONFIG_KERNEL_ELF=y
6352 +CONFIG_BINFMT_ELF=y
6353  CONFIG_BINFMT_MISC=m
6354  CONFIG_PCI_LEGACY_PROC=y
6355  CONFIG_PCI_NAMES=y
6356 @@ -126,6 +133,11 @@
6357  CONFIG_BOOT_LOAD=0x00800000
6358  
6359  #
6360 +# Generic Driver Options
6361 +#
6362 +# CONFIG_FW_LOADER is not set
6363 +
6364 +#
6365  # Memory Technology Devices (MTD)
6366  #
6367  # CONFIG_MTD is not set
6368 @@ -144,10 +156,12 @@
6369  # CONFIG_BLK_DEV_DAC960 is not set
6370  # CONFIG_BLK_DEV_UMEM is not set
6371  CONFIG_BLK_DEV_LOOP=y
6372 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
6373  # CONFIG_BLK_DEV_NBD is not set
6374  CONFIG_BLK_DEV_RAM=y
6375  CONFIG_BLK_DEV_RAM_SIZE=4096
6376  CONFIG_BLK_DEV_INITRD=y
6377 +CONFIG_LBD=y
6378  
6379  #
6380  # Multi-device support (RAID and LVM)
6381 @@ -155,40 +169,38 @@
6382  # CONFIG_MD is not set
6383  
6384  #
6385 -# ATA/IDE/MFM/RLL support
6386 +# ATA/ATAPI/MFM/RLL support
6387  #
6388  CONFIG_IDE=y
6389 -
6390 -#
6391 -# IDE, ATA and ATAPI Block devices
6392 -#
6393  CONFIG_BLK_DEV_IDE=y
6394  
6395  #
6396  # Please see Documentation/ide.txt for help/info on IDE drives
6397  #
6398 -# CONFIG_BLK_DEV_HD is not set
6399  CONFIG_BLK_DEV_IDEDISK=y
6400  # CONFIG_IDEDISK_MULTI_MODE is not set
6401  # CONFIG_IDEDISK_STROKE is not set
6402  CONFIG_BLK_DEV_IDECD=y
6403 +# CONFIG_BLK_DEV_IDETAPE is not set
6404  CONFIG_BLK_DEV_IDEFLOPPY=y
6405  CONFIG_BLK_DEV_IDESCSI=y
6406  # CONFIG_IDE_TASK_IOCTL is not set
6407 +# CONFIG_IDE_TASKFILE_IO is not set
6408  
6409  #
6410  # IDE chipset support/bugfixes
6411  #
6412  CONFIG_BLK_DEV_IDEPCI=y
6413 -CONFIG_BLK_DEV_GENERIC=y
6414  CONFIG_IDEPCI_SHARE_IRQ=y
6415 +# CONFIG_BLK_DEV_OFFBOARD is not set
6416 +CONFIG_BLK_DEV_GENERIC=y
6417 +# CONFIG_BLK_DEV_OPTI621 is not set
6418 +CONFIG_BLK_DEV_SL82C105=y
6419  CONFIG_BLK_DEV_IDEDMA_PCI=y
6420  # CONFIG_BLK_DEV_IDE_TCQ is not set
6421 -# CONFIG_BLK_DEV_OFFBOARD is not set
6422  # CONFIG_BLK_DEV_IDEDMA_FORCED is not set
6423  CONFIG_IDEDMA_PCI_AUTO=y
6424  # CONFIG_IDEDMA_ONLYDISK is not set
6425 -CONFIG_BLK_DEV_IDEDMA=y
6426  # CONFIG_IDEDMA_PCI_WIP is not set
6427  CONFIG_BLK_DEV_ADMA=y
6428  # CONFIG_BLK_DEV_AEC62XX is not set
6429 @@ -198,12 +210,12 @@
6430  # CONFIG_BLK_DEV_TRIFLEX is not set
6431  # CONFIG_BLK_DEV_CY82C693 is not set
6432  # CONFIG_BLK_DEV_CS5520 is not set
6433 +# CONFIG_BLK_DEV_CS5530 is not set
6434  # CONFIG_BLK_DEV_HPT34X is not set
6435  # CONFIG_BLK_DEV_HPT366 is not set
6436  # CONFIG_BLK_DEV_SC1200 is not set
6437  # CONFIG_BLK_DEV_PIIX is not set
6438  # CONFIG_BLK_DEV_NS87415 is not set
6439 -# CONFIG_BLK_DEV_OPTI621 is not set
6440  # CONFIG_BLK_DEV_PDC202XX_OLD is not set
6441  CONFIG_BLK_DEV_PDC202XX_NEW=y
6442  # CONFIG_PDC202XX_FORCE is not set
6443 @@ -212,15 +224,17 @@
6444  # CONFIG_BLK_DEV_SLC90E66 is not set
6445  # CONFIG_BLK_DEV_TRM290 is not set
6446  # CONFIG_BLK_DEV_VIA82CXXX is not set
6447 -CONFIG_BLK_DEV_SL82C105=y
6448  CONFIG_BLK_DEV_IDE_PMAC=y
6449  CONFIG_BLK_DEV_IDEDMA_PMAC=y
6450  CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO=y
6451 -CONFIG_IDEDMA_AUTO=y
6452 +CONFIG_BLK_DEV_IDEDMA=y
6453  # CONFIG_IDEDMA_IVB is not set
6454 +CONFIG_IDEDMA_AUTO=y
6455 +# CONFIG_DMA_NONPCI is not set
6456 +# CONFIG_BLK_DEV_HD is not set
6457  
6458  #
6459 -# SCSI support
6460 +# SCSI device support
6461  #
6462  CONFIG_SCSI=y
6463  
6464 @@ -260,8 +274,6 @@
6465  # CONFIG_SCSI_AIC79XX is not set
6466  # CONFIG_SCSI_DPT_I2O is not set
6467  CONFIG_SCSI_ADVANSYS=m
6468 -# CONFIG_SCSI_IN2000 is not set
6469 -# CONFIG_SCSI_AM53C974 is not set
6470  # CONFIG_SCSI_MEGARAID is not set
6471  # CONFIG_SCSI_BUSLOGIC is not set
6472  # CONFIG_SCSI_CPQFCTS is not set
6473 @@ -270,11 +282,8 @@
6474  # CONFIG_SCSI_EATA_PIO is not set
6475  # CONFIG_SCSI_FUTURE_DOMAIN is not set
6476  # CONFIG_SCSI_GDTH is not set
6477 -# CONFIG_SCSI_GENERIC_NCR5380 is not set
6478 -# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
6479  # CONFIG_SCSI_INITIO is not set
6480  # CONFIG_SCSI_INIA100 is not set
6481 -# CONFIG_SCSI_NCR53C7xx is not set
6482  CONFIG_SCSI_SYM53C8XX_2=y
6483  CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0
6484  CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
6485 @@ -287,7 +296,6 @@
6486  # CONFIG_SCSI_QLOGIC_1280 is not set
6487  # CONFIG_SCSI_DC395x is not set
6488  # CONFIG_SCSI_DC390T is not set
6489 -# CONFIG_SCSI_U14_34F is not set
6490  # CONFIG_SCSI_NSP32 is not set
6491  # CONFIG_SCSI_DEBUG is not set
6492  CONFIG_SCSI_MESH=y
6493 @@ -321,8 +329,6 @@
6494  CONFIG_PACKET=y
6495  # CONFIG_PACKET_MMAP is not set
6496  # CONFIG_NETLINK_DEV is not set
6497 -CONFIG_NETFILTER=y
6498 -# CONFIG_NETFILTER_DEBUG is not set
6499  CONFIG_UNIX=y
6500  # CONFIG_NET_KEY is not set
6501  CONFIG_INET=y
6502 @@ -340,6 +346,16 @@
6503  # CONFIG_INET_IPCOMP is not set
6504  
6505  #
6506 +# IP: Virtual Server Configuration
6507 +#
6508 +# CONFIG_IP_VS is not set
6509 +# CONFIG_IPV6 is not set
6510 +# CONFIG_DECNET is not set
6511 +# CONFIG_BRIDGE is not set
6512 +CONFIG_NETFILTER=y
6513 +# CONFIG_NETFILTER_DEBUG is not set
6514 +
6515 +#
6516  # IP: Netfilter Configuration
6517  #
6518  CONFIG_IP_NF_CONNTRACK=m
6519 @@ -355,6 +371,7 @@
6520  CONFIG_IP_NF_MATCH_MARK=m
6521  CONFIG_IP_NF_MATCH_MULTIPORT=m
6522  CONFIG_IP_NF_MATCH_TOS=m
6523 +CONFIG_IP_NF_MATCH_RECENT=m
6524  CONFIG_IP_NF_MATCH_ECN=m
6525  CONFIG_IP_NF_MATCH_DSCP=m
6526  CONFIG_IP_NF_MATCH_AH_ESP=m
6527 @@ -386,8 +403,6 @@
6528  # CONFIG_IP_NF_ARPTABLES is not set
6529  CONFIG_IP_NF_COMPAT_IPCHAINS=m
6530  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
6531 -# CONFIG_IPV6 is not set
6532 -# CONFIG_XFRM_USER is not set
6533  
6534  #
6535  # SCTP Configuration (EXPERIMENTAL)
6536 @@ -397,8 +412,6 @@
6537  # CONFIG_ATM is not set
6538  # CONFIG_VLAN_8021Q is not set
6539  # CONFIG_LLC is not set
6540 -# CONFIG_DECNET is not set
6541 -# CONFIG_BRIDGE is not set
6542  # CONFIG_X25 is not set
6543  # CONFIG_LAPB is not set
6544  # CONFIG_NET_DIVERT is not set
6545 @@ -482,6 +495,7 @@
6546  # CONFIG_HAMACHI is not set
6547  # CONFIG_YELLOWFIN is not set
6548  # CONFIG_R8169 is not set
6549 +# CONFIG_SIS190 is not set
6550  # CONFIG_SK98LIN is not set
6551  # CONFIG_TIGON3 is not set
6552  
6553 @@ -553,7 +567,7 @@
6554  # Graphics support
6555  #
6556  CONFIG_FB=y
6557 -CONFIG_FB_CIRRUS=y
6558 +# CONFIG_FB_CIRRUS is not set
6559  # CONFIG_FB_PM2 is not set
6560  # CONFIG_FB_CYBER2000 is not set
6561  CONFIG_FB_OF=y
6562 @@ -606,11 +620,6 @@
6563  CONFIG_LOGO_LINUX_CLUT224=y
6564  
6565  #
6566 -# Old CD-ROM drivers (not SCSI, not IDE)
6567 -#
6568 -# CONFIG_CD_NO_IDESCSI is not set
6569 -
6570 -#
6571  # Input device support
6572  #
6573  CONFIG_INPUT=y
6574 @@ -636,6 +645,7 @@
6575  CONFIG_SERIO_I8042=y
6576  # CONFIG_SERIO_SERPORT is not set
6577  # CONFIG_SERIO_CT82C710 is not set
6578 +# CONFIG_SERIO_PCIPS2 is not set
6579  
6580  #
6581  # Input Device Drivers
6582 @@ -703,10 +713,12 @@
6583  #
6584  # I2C Hardware Sensors Mainboard support
6585  #
6586 +# CONFIG_I2C_ALI1535 is not set
6587  # CONFIG_I2C_ALI15X3 is not set
6588  # CONFIG_I2C_AMD756 is not set
6589  # CONFIG_I2C_AMD8111 is not set
6590  # CONFIG_I2C_I801 is not set
6591 +# CONFIG_I2C_NFORCE2 is not set
6592  # CONFIG_I2C_PIIX4 is not set
6593  # CONFIG_I2C_SIS96X is not set
6594  # CONFIG_I2C_VIAPRO is not set
6595 @@ -718,6 +730,7 @@
6596  # CONFIG_SENSORS_IT87 is not set
6597  # CONFIG_SENSORS_LM75 is not set
6598  # CONFIG_SENSORS_LM85 is not set
6599 +# CONFIG_SENSORS_LM78 is not set
6600  # CONFIG_SENSORS_VIA686A is not set
6601  # CONFIG_SENSORS_W83781D is not set
6602  # CONFIG_I2C_SENSOR is not set
6603 @@ -913,13 +926,70 @@
6604  # Sound
6605  #
6606  CONFIG_SOUND=m
6607 -CONFIG_DMASOUND_AWACS=m
6608 -CONFIG_DMASOUND=m
6609 +# CONFIG_DMASOUND_AWACS is not set
6610  
6611  #
6612  # Advanced Linux Sound Architecture
6613  #
6614 -# CONFIG_SND is not set
6615 +CONFIG_SND=m
6616 +CONFIG_SND_SEQUENCER=m
6617 +# CONFIG_SND_SEQ_DUMMY is not set
6618 +CONFIG_SND_OSSEMUL=y
6619 +CONFIG_SND_MIXER_OSS=m
6620 +CONFIG_SND_PCM_OSS=m
6621 +CONFIG_SND_SEQUENCER_OSS=y
6622 +# CONFIG_SND_VERBOSE_PRINTK is not set
6623 +# CONFIG_SND_DEBUG is not set
6624 +
6625 +#
6626 +# Generic devices
6627 +#
6628 +# CONFIG_SND_DUMMY is not set
6629 +# CONFIG_SND_VIRMIDI is not set
6630 +# CONFIG_SND_MTPAV is not set
6631 +# CONFIG_SND_SERIAL_U16550 is not set
6632 +# CONFIG_SND_MPU401 is not set
6633 +
6634 +#
6635 +# PCI devices
6636 +#
6637 +# CONFIG_SND_ALI5451 is not set
6638 +# CONFIG_SND_AZT3328 is not set
6639 +# CONFIG_SND_CS46XX is not set
6640 +# CONFIG_SND_CS4281 is not set
6641 +# CONFIG_SND_EMU10K1 is not set
6642 +# CONFIG_SND_KORG1212 is not set
6643 +# CONFIG_SND_NM256 is not set
6644 +# CONFIG_SND_RME32 is not set
6645 +# CONFIG_SND_RME96 is not set
6646 +# CONFIG_SND_RME9652 is not set
6647 +# CONFIG_SND_HDSP is not set
6648 +# CONFIG_SND_TRIDENT is not set
6649 +# CONFIG_SND_YMFPCI is not set
6650 +# CONFIG_SND_ALS4000 is not set
6651 +# CONFIG_SND_CMIPCI is not set
6652 +# CONFIG_SND_ENS1370 is not set
6653 +# CONFIG_SND_ENS1371 is not set
6654 +# CONFIG_SND_ES1938 is not set
6655 +# CONFIG_SND_ES1968 is not set
6656 +# CONFIG_SND_MAESTRO3 is not set
6657 +# CONFIG_SND_FM801 is not set
6658 +# CONFIG_SND_ICE1712 is not set
6659 +# CONFIG_SND_ICE1724 is not set
6660 +# CONFIG_SND_INTEL8X0 is not set
6661 +# CONFIG_SND_SONICVIBES is not set
6662 +# CONFIG_SND_VIA82XX is not set
6663 +# CONFIG_SND_VX222 is not set
6664 +
6665 +#
6666 +# ALSA PowerMac devices
6667 +#
6668 +CONFIG_SND_POWERMAC=m
6669 +
6670 +#
6671 +# ALSA USB devices
6672 +#
6673 +CONFIG_SND_USB_AUDIO=m
6674  
6675  #
6676  # Open Sound System
6677 @@ -998,6 +1068,7 @@
6678  #
6679  # USB Network adaptors
6680  #
6681 +# CONFIG_USB_AX8817X is not set
6682  # CONFIG_USB_CATC is not set
6683  # CONFIG_USB_KAWETH is not set
6684  # CONFIG_USB_PEGASUS is not set
6685 @@ -1074,7 +1145,6 @@
6686  # Kernel hacking
6687  #
6688  # CONFIG_DEBUG_KERNEL is not set
6689 -CONFIG_KALLSYMS=y
6690  CONFIG_BOOTX_TEXT=y
6691  
6692  #
6693 diff -Nru a/arch/ppc/configs/ibmchrp_defconfig b/arch/ppc/configs/ibmchrp_defconfig
6694 --- a/arch/ppc/configs/ibmchrp_defconfig        Tue Jul  1 17:01:18 2003
6695 +++ b/arch/ppc/configs/ibmchrp_defconfig        Sat Aug 23 02:33:38 2003
6696 @@ -9,6 +9,7 @@
6697  # Code maturity level options
6698  #
6699  CONFIG_EXPERIMENTAL=y
6700 +# CONFIG_BROKEN is not set
6701  
6702  #
6703  # General setup
6704 @@ -18,9 +19,15 @@
6705  # CONFIG_BSD_PROCESS_ACCT is not set
6706  CONFIG_SYSCTL=y
6707  CONFIG_LOG_BUF_SHIFT=14
6708 +CONFIG_IKCONFIG=y
6709 +CONFIG_IKCONFIG_PROC=y
6710  # CONFIG_EMBEDDED is not set
6711 +CONFIG_KALLSYMS=y
6712  CONFIG_FUTEX=y
6713  CONFIG_EPOLL=y
6714 +CONFIG_IOSCHED_NOOP=y
6715 +CONFIG_IOSCHED_AS=y
6716 +CONFIG_IOSCHED_DEADLINE=y
6717  
6718  #
6719  # Loadable module support
6720 @@ -83,8 +90,8 @@
6721  CONFIG_PCI=y
6722  CONFIG_PCI_DOMAINS=y
6723  CONFIG_KCORE_ELF=y
6724 -CONFIG_BINFMT_ELF=y
6725  CONFIG_KERNEL_ELF=y
6726 +CONFIG_BINFMT_ELF=y
6727  CONFIG_BINFMT_MISC=y
6728  CONFIG_PCI_LEGACY_PROC=y
6729  CONFIG_PCI_NAMES=y
6730 @@ -116,6 +123,10 @@
6731  CONFIG_BOOT_LOAD=0x00800000
6732  
6733  #
6734 +# Generic Driver Options
6735 +#
6736 +
6737 +#
6738  # Memory Technology Devices (MTD)
6739  #
6740  # CONFIG_MTD is not set
6741 @@ -134,10 +145,12 @@
6742  # CONFIG_BLK_DEV_DAC960 is not set
6743  # CONFIG_BLK_DEV_UMEM is not set
6744  CONFIG_BLK_DEV_LOOP=y
6745 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
6746  # CONFIG_BLK_DEV_NBD is not set
6747  CONFIG_BLK_DEV_RAM=y
6748  CONFIG_BLK_DEV_RAM_SIZE=4096
6749  CONFIG_BLK_DEV_INITRD=y
6750 +CONFIG_LBD=y
6751  
6752  #
6753  # Multi-device support (RAID and LVM)
6754 @@ -145,12 +158,12 @@
6755  # CONFIG_MD is not set
6756  
6757  #
6758 -# ATA/IDE/MFM/RLL support
6759 +# ATA/ATAPI/MFM/RLL support
6760  #
6761  # CONFIG_IDE is not set
6762  
6763  #
6764 -# SCSI support
6765 +# SCSI device support
6766  #
6767  CONFIG_SCSI=y
6768  
6769 @@ -183,8 +196,6 @@
6770  # CONFIG_SCSI_AIC79XX is not set
6771  # CONFIG_SCSI_DPT_I2O is not set
6772  # CONFIG_SCSI_ADVANSYS is not set
6773 -# CONFIG_SCSI_IN2000 is not set
6774 -# CONFIG_SCSI_AM53C974 is not set
6775  # CONFIG_SCSI_MEGARAID is not set
6776  # CONFIG_SCSI_BUSLOGIC is not set
6777  # CONFIG_SCSI_CPQFCTS is not set
6778 @@ -193,11 +204,8 @@
6779  # CONFIG_SCSI_EATA_PIO is not set
6780  # CONFIG_SCSI_FUTURE_DOMAIN is not set
6781  # CONFIG_SCSI_GDTH is not set
6782 -# CONFIG_SCSI_GENERIC_NCR5380 is not set
6783 -# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
6784  # CONFIG_SCSI_INITIO is not set
6785  # CONFIG_SCSI_INIA100 is not set
6786 -# CONFIG_SCSI_NCR53C7xx is not set
6787  CONFIG_SCSI_SYM53C8XX_2=y
6788  CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0
6789  CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
6790 @@ -210,7 +218,6 @@
6791  # CONFIG_SCSI_QLOGIC_1280 is not set
6792  # CONFIG_SCSI_DC395x is not set
6793  # CONFIG_SCSI_DC390T is not set
6794 -# CONFIG_SCSI_U14_34F is not set
6795  # CONFIG_SCSI_NSP32 is not set
6796  # CONFIG_SCSI_DEBUG is not set
6797  # CONFIG_SCSI_MESH is not set
6798 @@ -242,8 +249,6 @@
6799  CONFIG_PACKET=y
6800  # CONFIG_PACKET_MMAP is not set
6801  # CONFIG_NETLINK_DEV is not set
6802 -CONFIG_NETFILTER=y
6803 -# CONFIG_NETFILTER_DEBUG is not set
6804  CONFIG_UNIX=y
6805  # CONFIG_NET_KEY is not set
6806  CONFIG_INET=y
6807 @@ -261,6 +266,16 @@
6808  # CONFIG_INET_IPCOMP is not set
6809  
6810  #
6811 +# IP: Virtual Server Configuration
6812 +#
6813 +# CONFIG_IP_VS is not set
6814 +# CONFIG_IPV6 is not set
6815 +# CONFIG_DECNET is not set
6816 +# CONFIG_BRIDGE is not set
6817 +CONFIG_NETFILTER=y
6818 +# CONFIG_NETFILTER_DEBUG is not set
6819 +
6820 +#
6821  # IP: Netfilter Configuration
6822  #
6823  CONFIG_IP_NF_CONNTRACK=m
6824 @@ -276,6 +291,7 @@
6825  CONFIG_IP_NF_MATCH_MARK=m
6826  CONFIG_IP_NF_MATCH_MULTIPORT=m
6827  CONFIG_IP_NF_MATCH_TOS=m
6828 +CONFIG_IP_NF_MATCH_RECENT=m
6829  CONFIG_IP_NF_MATCH_ECN=m
6830  CONFIG_IP_NF_MATCH_DSCP=m
6831  CONFIG_IP_NF_MATCH_AH_ESP=m
6832 @@ -306,10 +322,9 @@
6833  CONFIG_IP_NF_TARGET_TCPMSS=m
6834  CONFIG_IP_NF_ARPTABLES=m
6835  CONFIG_IP_NF_ARPFILTER=m
6836 +CONFIG_IP_NF_ARP_MANGLE=m
6837  CONFIG_IP_NF_COMPAT_IPCHAINS=m
6838  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
6839 -# CONFIG_IPV6 is not set
6840 -# CONFIG_XFRM_USER is not set
6841  
6842  #
6843  # SCTP Configuration (EXPERIMENTAL)
6844 @@ -319,8 +334,6 @@
6845  # CONFIG_ATM is not set
6846  # CONFIG_VLAN_8021Q is not set
6847  # CONFIG_LLC is not set
6848 -# CONFIG_DECNET is not set
6849 -# CONFIG_BRIDGE is not set
6850  # CONFIG_X25 is not set
6851  # CONFIG_LAPB is not set
6852  # CONFIG_NET_DIVERT is not set
6853 @@ -396,6 +409,7 @@
6854  # CONFIG_HAMACHI is not set
6855  # CONFIG_YELLOWFIN is not set
6856  # CONFIG_R8169 is not set
6857 +# CONFIG_SIS190 is not set
6858  # CONFIG_SK98LIN is not set
6859  # CONFIG_TIGON3 is not set
6860  
6861 @@ -495,11 +509,6 @@
6862  CONFIG_LOGO_LINUX_CLUT224=y
6863  
6864  #
6865 -# Old CD-ROM drivers (not SCSI, not IDE)
6866 -#
6867 -# CONFIG_CD_NO_IDESCSI is not set
6868 -
6869 -#
6870  # Input device support
6871  #
6872  CONFIG_INPUT=y
6873 @@ -525,6 +534,7 @@
6874  CONFIG_SERIO_I8042=y
6875  CONFIG_SERIO_SERPORT=y
6876  # CONFIG_SERIO_CT82C710 is not set
6877 +# CONFIG_SERIO_PCIPS2 is not set
6878  
6879  #
6880  # Input Device Drivers
6881 @@ -791,7 +801,6 @@
6882  # Kernel hacking
6883  #
6884  # CONFIG_DEBUG_KERNEL is not set
6885 -CONFIG_KALLSYMS=y
6886  # CONFIG_BOOTX_TEXT is not set
6887  
6888  #
6889 diff -Nru a/arch/ppc/configs/mcpn765_defconfig b/arch/ppc/configs/mcpn765_defconfig
6890 --- a/arch/ppc/configs/mcpn765_defconfig        Tue Jul  1 17:01:18 2003
6891 +++ b/arch/ppc/configs/mcpn765_defconfig        Mon Jul 21 09:05:22 2003
6892 @@ -19,6 +19,7 @@
6893  CONFIG_SYSCTL=y
6894  CONFIG_LOG_BUF_SHIFT=14
6895  # CONFIG_EMBEDDED is not set
6896 +CONFIG_KALLSYMS=y
6897  CONFIG_FUTEX=y
6898  CONFIG_EPOLL=y
6899  
6900 @@ -74,8 +75,8 @@
6901  CONFIG_PCI=y
6902  CONFIG_PCI_DOMAINS=y
6903  CONFIG_KCORE_ELF=y
6904 -CONFIG_BINFMT_ELF=y
6905  CONFIG_KERNEL_ELF=y
6906 +CONFIG_BINFMT_ELF=y
6907  # CONFIG_BINFMT_MISC is not set
6908  # CONFIG_PCI_LEGACY_PROC is not set
6909  # CONFIG_PCI_NAMES is not set
6910 @@ -104,6 +105,11 @@
6911  CONFIG_BOOT_LOAD=0x00800000
6912  
6913  #
6914 +# Generic Driver Options
6915 +#
6916 +# CONFIG_FW_LOADER is not set
6917 +
6918 +#
6919  # Memory Technology Devices (MTD)
6920  #
6921  # CONFIG_MTD is not set
6922 @@ -122,10 +128,12 @@
6923  # CONFIG_BLK_DEV_DAC960 is not set
6924  # CONFIG_BLK_DEV_UMEM is not set
6925  CONFIG_BLK_DEV_LOOP=y
6926 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
6927  # CONFIG_BLK_DEV_NBD is not set
6928  CONFIG_BLK_DEV_RAM=y
6929  CONFIG_BLK_DEV_RAM_SIZE=4096
6930  CONFIG_BLK_DEV_INITRD=y
6931 +# CONFIG_LBD is not set
6932  
6933  #
6934  # Multi-device support (RAID and LVM)
6935 @@ -133,12 +141,12 @@
6936  # CONFIG_MD is not set
6937  
6938  #
6939 -# ATA/IDE/MFM/RLL support
6940 +# ATA/ATAPI/MFM/RLL support
6941  #
6942  # CONFIG_IDE is not set
6943  
6944  #
6945 -# SCSI support
6946 +# SCSI device support
6947  #
6948  # CONFIG_SCSI is not set
6949  
6950 @@ -320,11 +328,6 @@
6951  # CONFIG_FB is not set
6952  
6953  #
6954 -# Old CD-ROM drivers (not SCSI, not IDE)
6955 -#
6956 -# CONFIG_CD_NO_IDESCSI is not set
6957 -
6958 -#
6959  # Input device support
6960  #
6961  # CONFIG_INPUT is not set
6962 @@ -526,7 +529,6 @@
6963  # Kernel hacking
6964  #
6965  # CONFIG_DEBUG_KERNEL is not set
6966 -# CONFIG_KALLSYMS is not set
6967  # CONFIG_SERIAL_TEXT_DEBUG is not set
6968  
6969  #
6970 diff -Nru a/arch/ppc/configs/pmac_defconfig b/arch/ppc/configs/pmac_defconfig
6971 --- a/arch/ppc/configs/pmac_defconfig   Sat Aug  2 13:06:57 2003
6972 +++ b/arch/ppc/configs/pmac_defconfig   Sat Aug 23 02:33:38 2003
6973 @@ -9,6 +9,7 @@
6974  # Code maturity level options
6975  #
6976  CONFIG_EXPERIMENTAL=y
6977 +# CONFIG_BROKEN is not set
6978  
6979  #
6980  # General setup
6981 @@ -18,9 +19,15 @@
6982  # CONFIG_BSD_PROCESS_ACCT is not set
6983  CONFIG_SYSCTL=y
6984  CONFIG_LOG_BUF_SHIFT=14
6985 +CONFIG_IKCONFIG=y
6986 +CONFIG_IKCONFIG_PROC=y
6987  # CONFIG_EMBEDDED is not set
6988 +CONFIG_KALLSYMS=y
6989  CONFIG_FUTEX=y
6990  CONFIG_EPOLL=y
6991 +CONFIG_IOSCHED_NOOP=y
6992 +CONFIG_IOSCHED_AS=y
6993 +CONFIG_IOSCHED_DEADLINE=y
6994  
6995  #
6996  # Loadable module support
6997 @@ -79,6 +86,7 @@
6998  # CONFIG_TAU_INT is not set
6999  # CONFIG_TAU_AVERAGE is not set
7000  CONFIG_CPU_FREQ=y
7001 +CONFIG_CPU_FREQ_TABLE=y
7002  CONFIG_CPU_FREQ_PROC_INTF=y
7003  CONFIG_CPU_FREQ_24_API=y
7004  CONFIG_CPU_FREQ_PMAC=y
7005 @@ -90,8 +98,8 @@
7006  CONFIG_PCI=y
7007  CONFIG_PCI_DOMAINS=y
7008  CONFIG_KCORE_ELF=y
7009 -CONFIG_BINFMT_ELF=y
7010  CONFIG_KERNEL_ELF=y
7011 +CONFIG_BINFMT_ELF=y
7012  CONFIG_BINFMT_MISC=m
7013  CONFIG_PCI_LEGACY_PROC=y
7014  CONFIG_PCI_NAMES=y
7015 @@ -101,9 +109,9 @@
7016  # PCMCIA/CardBus support
7017  #
7018  CONFIG_PCMCIA=m
7019 +CONFIG_YENTA=m
7020  CONFIG_CARDBUS=y
7021  CONFIG_I82092=m
7022 -CONFIG_I82365=m
7023  CONFIG_TCIC=m
7024  
7025  #
7026 @@ -131,6 +139,11 @@
7027  CONFIG_BOOT_LOAD=0x00800000
7028  
7029  #
7030 +# Generic Driver Options
7031 +#
7032 +# CONFIG_FW_LOADER is not set
7033 +
7034 +#
7035  # Memory Technology Devices (MTD)
7036  #
7037  # CONFIG_MTD is not set
7038 @@ -149,10 +162,12 @@
7039  # CONFIG_BLK_DEV_DAC960 is not set
7040  # CONFIG_BLK_DEV_UMEM is not set
7041  CONFIG_BLK_DEV_LOOP=y
7042 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
7043  # CONFIG_BLK_DEV_NBD is not set
7044  CONFIG_BLK_DEV_RAM=y
7045  CONFIG_BLK_DEV_RAM_SIZE=4096
7046  CONFIG_BLK_DEV_INITRD=y
7047 +CONFIG_LBD=y
7048  
7049  #
7050  # Multi-device support (RAID and LVM)
7051 @@ -160,41 +175,39 @@
7052  # CONFIG_MD is not set
7053  
7054  #
7055 -# ATA/IDE/MFM/RLL support
7056 +# ATA/ATAPI/MFM/RLL support
7057  #
7058  CONFIG_IDE=y
7059 -
7060 -#
7061 -# IDE, ATA and ATAPI Block devices
7062 -#
7063  CONFIG_BLK_DEV_IDE=y
7064  
7065  #
7066  # Please see Documentation/ide.txt for help/info on IDE drives
7067  #
7068 -# CONFIG_BLK_DEV_HD is not set
7069  CONFIG_BLK_DEV_IDEDISK=y
7070  # CONFIG_IDEDISK_MULTI_MODE is not set
7071  # CONFIG_IDEDISK_STROKE is not set
7072  CONFIG_BLK_DEV_IDECS=m
7073  CONFIG_BLK_DEV_IDECD=y
7074 +# CONFIG_BLK_DEV_IDETAPE is not set
7075  CONFIG_BLK_DEV_IDEFLOPPY=y
7076  CONFIG_BLK_DEV_IDESCSI=y
7077  # CONFIG_IDE_TASK_IOCTL is not set
7078 +# CONFIG_IDE_TASKFILE_IO is not set
7079  
7080  #
7081  # IDE chipset support/bugfixes
7082  #
7083  CONFIG_BLK_DEV_IDEPCI=y
7084 -CONFIG_BLK_DEV_GENERIC=y
7085  CONFIG_IDEPCI_SHARE_IRQ=y
7086 +# CONFIG_BLK_DEV_OFFBOARD is not set
7087 +CONFIG_BLK_DEV_GENERIC=y
7088 +# CONFIG_BLK_DEV_OPTI621 is not set
7089 +CONFIG_BLK_DEV_SL82C105=y
7090  CONFIG_BLK_DEV_IDEDMA_PCI=y
7091  # CONFIG_BLK_DEV_IDE_TCQ is not set
7092 -# CONFIG_BLK_DEV_OFFBOARD is not set
7093  # CONFIG_BLK_DEV_IDEDMA_FORCED is not set
7094  CONFIG_IDEDMA_PCI_AUTO=y
7095  # CONFIG_IDEDMA_ONLYDISK is not set
7096 -CONFIG_BLK_DEV_IDEDMA=y
7097  # CONFIG_IDEDMA_PCI_WIP is not set
7098  CONFIG_BLK_DEV_ADMA=y
7099  # CONFIG_BLK_DEV_AEC62XX is not set
7100 @@ -204,12 +217,12 @@
7101  # CONFIG_BLK_DEV_TRIFLEX is not set
7102  # CONFIG_BLK_DEV_CY82C693 is not set
7103  # CONFIG_BLK_DEV_CS5520 is not set
7104 +# CONFIG_BLK_DEV_CS5530 is not set
7105  # CONFIG_BLK_DEV_HPT34X is not set
7106  # CONFIG_BLK_DEV_HPT366 is not set
7107  # CONFIG_BLK_DEV_SC1200 is not set
7108  # CONFIG_BLK_DEV_PIIX is not set
7109  # CONFIG_BLK_DEV_NS87415 is not set
7110 -# CONFIG_BLK_DEV_OPTI621 is not set
7111  # CONFIG_BLK_DEV_PDC202XX_OLD is not set
7112  CONFIG_BLK_DEV_PDC202XX_NEW=y
7113  # CONFIG_PDC202XX_FORCE is not set
7114 @@ -218,15 +231,17 @@
7115  # CONFIG_BLK_DEV_SLC90E66 is not set
7116  # CONFIG_BLK_DEV_TRM290 is not set
7117  # CONFIG_BLK_DEV_VIA82CXXX is not set
7118 -CONFIG_BLK_DEV_SL82C105=y
7119  CONFIG_BLK_DEV_IDE_PMAC=y
7120  CONFIG_BLK_DEV_IDEDMA_PMAC=y
7121  CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO=y
7122 -CONFIG_IDEDMA_AUTO=y
7123 +CONFIG_BLK_DEV_IDEDMA=y
7124  # CONFIG_IDEDMA_IVB is not set
7125 +CONFIG_IDEDMA_AUTO=y
7126 +# CONFIG_DMA_NONPCI is not set
7127 +# CONFIG_BLK_DEV_HD is not set
7128  
7129  #
7130 -# SCSI support
7131 +# SCSI device support
7132  #
7133  CONFIG_SCSI=y
7134  
7135 @@ -266,8 +281,6 @@
7136  # CONFIG_SCSI_AIC79XX is not set
7137  # CONFIG_SCSI_DPT_I2O is not set
7138  CONFIG_SCSI_ADVANSYS=m
7139 -# CONFIG_SCSI_IN2000 is not set
7140 -# CONFIG_SCSI_AM53C974 is not set
7141  # CONFIG_SCSI_MEGARAID is not set
7142  # CONFIG_SCSI_BUSLOGIC is not set
7143  # CONFIG_SCSI_CPQFCTS is not set
7144 @@ -276,11 +289,8 @@
7145  # CONFIG_SCSI_EATA_PIO is not set
7146  # CONFIG_SCSI_FUTURE_DOMAIN is not set
7147  # CONFIG_SCSI_GDTH is not set
7148 -# CONFIG_SCSI_GENERIC_NCR5380 is not set
7149 -# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
7150  # CONFIG_SCSI_INITIO is not set
7151  # CONFIG_SCSI_INIA100 is not set
7152 -# CONFIG_SCSI_NCR53C7xx is not set
7153  CONFIG_SCSI_SYM53C8XX_2=y
7154  CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0
7155  CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
7156 @@ -293,7 +303,6 @@
7157  # CONFIG_SCSI_QLOGIC_1280 is not set
7158  # CONFIG_SCSI_DC395x is not set
7159  # CONFIG_SCSI_DC390T is not set
7160 -# CONFIG_SCSI_U14_34F is not set
7161  # CONFIG_SCSI_NSP32 is not set
7162  # CONFIG_SCSI_DEBUG is not set
7163  CONFIG_SCSI_MESH=y
7164 @@ -361,8 +370,6 @@
7165  CONFIG_PACKET=y
7166  # CONFIG_PACKET_MMAP is not set
7167  # CONFIG_NETLINK_DEV is not set
7168 -CONFIG_NETFILTER=y
7169 -# CONFIG_NETFILTER_DEBUG is not set
7170  CONFIG_UNIX=y
7171  # CONFIG_NET_KEY is not set
7172  CONFIG_INET=y
7173 @@ -380,6 +387,16 @@
7174  # CONFIG_INET_IPCOMP is not set
7175  
7176  #
7177 +# IP: Virtual Server Configuration
7178 +#
7179 +# CONFIG_IP_VS is not set
7180 +# CONFIG_IPV6 is not set
7181 +# CONFIG_DECNET is not set
7182 +# CONFIG_BRIDGE is not set
7183 +CONFIG_NETFILTER=y
7184 +# CONFIG_NETFILTER_DEBUG is not set
7185 +
7186 +#
7187  # IP: Netfilter Configuration
7188  #
7189  CONFIG_IP_NF_CONNTRACK=m
7190 @@ -395,6 +412,7 @@
7191  CONFIG_IP_NF_MATCH_MARK=m
7192  CONFIG_IP_NF_MATCH_MULTIPORT=m
7193  CONFIG_IP_NF_MATCH_TOS=m
7194 +CONFIG_IP_NF_MATCH_RECENT=m
7195  CONFIG_IP_NF_MATCH_ECN=m
7196  CONFIG_IP_NF_MATCH_DSCP=m
7197  CONFIG_IP_NF_MATCH_AH_ESP=m
7198 @@ -425,10 +443,9 @@
7199  CONFIG_IP_NF_TARGET_TCPMSS=m
7200  CONFIG_IP_NF_ARPTABLES=m
7201  CONFIG_IP_NF_ARPFILTER=m
7202 +CONFIG_IP_NF_ARP_MANGLE=m
7203  CONFIG_IP_NF_COMPAT_IPCHAINS=m
7204  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
7205 -# CONFIG_IPV6 is not set
7206 -# CONFIG_XFRM_USER is not set
7207  
7208  #
7209  # SCTP Configuration (EXPERIMENTAL)
7210 @@ -438,8 +455,6 @@
7211  # CONFIG_ATM is not set
7212  # CONFIG_VLAN_8021Q is not set
7213  # CONFIG_LLC is not set
7214 -# CONFIG_DECNET is not set
7215 -# CONFIG_BRIDGE is not set
7216  # CONFIG_X25 is not set
7217  # CONFIG_LAPB is not set
7218  # CONFIG_NET_DIVERT is not set
7219 @@ -516,6 +531,7 @@
7220  # CONFIG_HAMACHI is not set
7221  # CONFIG_YELLOWFIN is not set
7222  # CONFIG_R8169 is not set
7223 +# CONFIG_SIS190 is not set
7224  # CONFIG_SK98LIN is not set
7225  # CONFIG_TIGON3 is not set
7226  
7227 @@ -568,6 +584,7 @@
7228  CONFIG_PCMCIA_HERMES=m
7229  # CONFIG_AIRO_CS is not set
7230  # CONFIG_PCMCIA_ATMEL is not set
7231 +# CONFIG_PCMCIA_WL3501 is not set
7232  CONFIG_NET_WIRELESS=y
7233  
7234  #
7235 @@ -637,25 +654,18 @@
7236  #
7237  # Old SIR device drivers
7238  #
7239 -# CONFIG_IRTTY_OLD is not set
7240  # CONFIG_IRPORT_SIR is not set
7241  
7242  #
7243  # Old Serial dongle support
7244  #
7245 -# CONFIG_DONGLE_OLD is not set
7246  
7247  #
7248  # FIR device drivers
7249  #
7250  # CONFIG_USB_IRDA is not set
7251 -# CONFIG_NSC_FIR is not set
7252 -# CONFIG_WINBOND_FIR is not set
7253  # CONFIG_TOSHIBA_OLD is not set
7254  # CONFIG_TOSHIBA_FIR is not set
7255 -# CONFIG_SMC_IRCC_OLD is not set
7256 -# CONFIG_SMC_IRCC_FIR is not set
7257 -# CONFIG_ALI_FIR is not set
7258  # CONFIG_VLSI_FIR is not set
7259  
7260  #
7261 @@ -721,11 +731,6 @@
7262  CONFIG_LOGO_LINUX_CLUT224=y
7263  
7264  #
7265 -# Old CD-ROM drivers (not SCSI, not IDE)
7266 -#
7267 -# CONFIG_CD_NO_IDESCSI is not set
7268 -
7269 -#
7270  # Input device support
7271  #
7272  CONFIG_INPUT=y
7273 @@ -766,7 +771,7 @@
7274  CONFIG_PMAC_PBOOK=y
7275  CONFIG_PMAC_APM_EMU=y
7276  CONFIG_PMAC_BACKLIGHT=y
7277 -CONFIG_MAC_FLOPPY=y
7278 +# CONFIG_MAC_FLOPPY is not set
7279  CONFIG_MAC_SERIAL=y
7280  CONFIG_ADB=y
7281  CONFIG_ADB_MACIO=y
7282 @@ -808,10 +813,12 @@
7283  #
7284  # I2C Hardware Sensors Mainboard support
7285  #
7286 +# CONFIG_I2C_ALI1535 is not set
7287  # CONFIG_I2C_ALI15X3 is not set
7288  # CONFIG_I2C_AMD756 is not set
7289  # CONFIG_I2C_AMD8111 is not set
7290  # CONFIG_I2C_I801 is not set
7291 +# CONFIG_I2C_NFORCE2 is not set
7292  # CONFIG_I2C_PIIX4 is not set
7293  # CONFIG_I2C_SIS96X is not set
7294  # CONFIG_I2C_VIAPRO is not set
7295 @@ -823,6 +830,7 @@
7296  # CONFIG_SENSORS_IT87 is not set
7297  # CONFIG_SENSORS_LM75 is not set
7298  # CONFIG_SENSORS_LM85 is not set
7299 +# CONFIG_SENSORS_LM78 is not set
7300  # CONFIG_SENSORS_VIA686A is not set
7301  # CONFIG_SENSORS_W83781D is not set
7302  # CONFIG_I2C_SENSOR is not set
7303 @@ -1028,8 +1036,7 @@
7304  # Sound
7305  #
7306  CONFIG_SOUND=m
7307 -CONFIG_DMASOUND_AWACS=m
7308 -CONFIG_DMASOUND=m
7309 +# CONFIG_DMASOUND_AWACS is not set
7310  
7311  #
7312  # Advanced Linux Sound Architecture
7313 @@ -1168,6 +1175,7 @@
7314  #
7315  # USB Network adaptors
7316  #
7317 +# CONFIG_USB_AX8817X is not set
7318  # CONFIG_USB_CATC is not set
7319  # CONFIG_USB_KAWETH is not set
7320  # CONFIG_USB_PEGASUS is not set
7321 @@ -1231,7 +1239,6 @@
7322  # Kernel hacking
7323  #
7324  # CONFIG_DEBUG_KERNEL is not set
7325 -CONFIG_KALLSYMS=y
7326  CONFIG_BOOTX_TEXT=y
7327  
7328  #
7329 diff -Nru a/arch/ppc/configs/power3_defconfig b/arch/ppc/configs/power3_defconfig
7330 --- a/arch/ppc/configs/power3_defconfig Tue Jul  1 17:01:18 2003
7331 +++ b/arch/ppc/configs/power3_defconfig Sat Aug 23 02:33:38 2003
7332 @@ -9,6 +9,7 @@
7333  # Code maturity level options
7334  #
7335  CONFIG_EXPERIMENTAL=y
7336 +# CONFIG_BROKEN is not set
7337  
7338  #
7339  # General setup
7340 @@ -18,9 +19,15 @@
7341  # CONFIG_BSD_PROCESS_ACCT is not set
7342  CONFIG_SYSCTL=y
7343  CONFIG_LOG_BUF_SHIFT=15
7344 +CONFIG_IKCONFIG=y
7345 +CONFIG_IKCONFIG_PROC=y
7346  # CONFIG_EMBEDDED is not set
7347 +CONFIG_KALLSYMS=y
7348  CONFIG_FUTEX=y
7349  CONFIG_EPOLL=y
7350 +CONFIG_IOSCHED_NOOP=y
7351 +CONFIG_IOSCHED_AS=y
7352 +CONFIG_IOSCHED_DEADLINE=y
7353  
7354  #
7355  # Loadable module support
7356 @@ -82,8 +89,8 @@
7357  CONFIG_PCI=y
7358  CONFIG_PCI_DOMAINS=y
7359  CONFIG_KCORE_ELF=y
7360 -CONFIG_BINFMT_ELF=y
7361  CONFIG_KERNEL_ELF=y
7362 +CONFIG_BINFMT_ELF=y
7363  CONFIG_BINFMT_MISC=y
7364  CONFIG_PCI_LEGACY_PROC=y
7365  CONFIG_PCI_NAMES=y
7366 @@ -121,6 +128,10 @@
7367  CONFIG_BOOT_LOAD=0x00800000
7368  
7369  #
7370 +# Generic Driver Options
7371 +#
7372 +
7373 +#
7374  # Memory Technology Devices (MTD)
7375  #
7376  # CONFIG_MTD is not set
7377 @@ -140,10 +151,12 @@
7378  # CONFIG_BLK_DEV_DAC960 is not set
7379  # CONFIG_BLK_DEV_UMEM is not set
7380  CONFIG_BLK_DEV_LOOP=y
7381 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
7382  # CONFIG_BLK_DEV_NBD is not set
7383  CONFIG_BLK_DEV_RAM=y
7384  CONFIG_BLK_DEV_RAM_SIZE=4096
7385  CONFIG_BLK_DEV_INITRD=y
7386 +CONFIG_LBD=y
7387  
7388  #
7389  # Multi-device support (RAID and LVM)
7390 @@ -156,14 +169,15 @@
7391  CONFIG_MD_RAID5=y
7392  # CONFIG_MD_MULTIPATH is not set
7393  CONFIG_BLK_DEV_DM=y
7394 +CONFIG_DM_IOCTL_V4=y
7395  
7396  #
7397 -# ATA/IDE/MFM/RLL support
7398 +# ATA/ATAPI/MFM/RLL support
7399  #
7400  # CONFIG_IDE is not set
7401  
7402  #
7403 -# SCSI support
7404 +# SCSI device support
7405  #
7406  CONFIG_SCSI=y
7407  
7408 @@ -196,8 +210,6 @@
7409  # CONFIG_SCSI_AIC79XX is not set
7410  # CONFIG_SCSI_DPT_I2O is not set
7411  # CONFIG_SCSI_ADVANSYS is not set
7412 -# CONFIG_SCSI_IN2000 is not set
7413 -# CONFIG_SCSI_AM53C974 is not set
7414  # CONFIG_SCSI_MEGARAID is not set
7415  # CONFIG_SCSI_BUSLOGIC is not set
7416  # CONFIG_SCSI_CPQFCTS is not set
7417 @@ -206,13 +218,10 @@
7418  # CONFIG_SCSI_EATA_PIO is not set
7419  # CONFIG_SCSI_FUTURE_DOMAIN is not set
7420  # CONFIG_SCSI_GDTH is not set
7421 -# CONFIG_SCSI_GENERIC_NCR5380 is not set
7422 -# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
7423  # CONFIG_SCSI_INITIO is not set
7424  # CONFIG_SCSI_INIA100 is not set
7425  # CONFIG_SCSI_PPA is not set
7426  # CONFIG_SCSI_IMM is not set
7427 -# CONFIG_SCSI_NCR53C7xx is not set
7428  CONFIG_SCSI_SYM53C8XX_2=y
7429  CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
7430  CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
7431 @@ -225,7 +234,6 @@
7432  # CONFIG_SCSI_QLOGIC_1280 is not set
7433  # CONFIG_SCSI_DC395x is not set
7434  # CONFIG_SCSI_DC390T is not set
7435 -# CONFIG_SCSI_U14_34F is not set
7436  # CONFIG_SCSI_NSP32 is not set
7437  # CONFIG_SCSI_DEBUG is not set
7438  # CONFIG_SCSI_MESH is not set
7439 @@ -257,7 +265,6 @@
7440  CONFIG_PACKET=y
7441  # CONFIG_PACKET_MMAP is not set
7442  # CONFIG_NETLINK_DEV is not set
7443 -# CONFIG_NETFILTER is not set
7444  CONFIG_UNIX=y
7445  # CONFIG_NET_KEY is not set
7446  CONFIG_INET=y
7447 @@ -274,7 +281,9 @@
7448  # CONFIG_INET_ESP is not set
7449  # CONFIG_INET_IPCOMP is not set
7450  # CONFIG_IPV6 is not set
7451 -# CONFIG_XFRM_USER is not set
7452 +# CONFIG_DECNET is not set
7453 +# CONFIG_BRIDGE is not set
7454 +# CONFIG_NETFILTER is not set
7455  
7456  #
7457  # SCTP Configuration (EXPERIMENTAL)
7458 @@ -284,8 +293,6 @@
7459  # CONFIG_ATM is not set
7460  # CONFIG_VLAN_8021Q is not set
7461  # CONFIG_LLC is not set
7462 -# CONFIG_DECNET is not set
7463 -# CONFIG_BRIDGE is not set
7464  # CONFIG_X25 is not set
7465  # CONFIG_LAPB is not set
7466  # CONFIG_NET_DIVERT is not set
7467 @@ -362,6 +369,7 @@
7468  # CONFIG_HAMACHI is not set
7469  # CONFIG_YELLOWFIN is not set
7470  # CONFIG_R8169 is not set
7471 +# CONFIG_SIS190 is not set
7472  # CONFIG_SK98LIN is not set
7473  # CONFIG_TIGON3 is not set
7474  
7475 @@ -464,11 +472,6 @@
7476  CONFIG_LOGO_LINUX_CLUT224=y
7477  
7478  #
7479 -# Old CD-ROM drivers (not SCSI, not IDE)
7480 -#
7481 -# CONFIG_CD_NO_IDESCSI is not set
7482 -
7483 -#
7484  # Input device support
7485  #
7486  CONFIG_INPUT=y
7487 @@ -495,6 +498,7 @@
7488  CONFIG_SERIO_SERPORT=y
7489  # CONFIG_SERIO_CT82C710 is not set
7490  # CONFIG_SERIO_PARKBD is not set
7491 +# CONFIG_SERIO_PCIPS2 is not set
7492  
7493  #
7494  # Input Device Drivers
7495 @@ -554,9 +558,8 @@
7496  #
7497  CONFIG_I2C=y
7498  CONFIG_I2C_ALGOBIT=y
7499 +# CONFIG_I2C_PROSAVAGE is not set
7500  # CONFIG_I2C_PHILIPSPAR is not set
7501 -# CONFIG_I2C_ELV is not set
7502 -# CONFIG_I2C_VELLEMAN is not set
7503  # CONFIG_SCx200_ACB is not set
7504  CONFIG_I2C_ALGOPCF=y
7505  # CONFIG_I2C_ELEKTOR is not set
7506 @@ -566,10 +569,12 @@
7507  #
7508  # I2C Hardware Sensors Mainboard support
7509  #
7510 +# CONFIG_I2C_ALI1535 is not set
7511  # CONFIG_I2C_ALI15X3 is not set
7512  # CONFIG_I2C_AMD756 is not set
7513  # CONFIG_I2C_AMD8111 is not set
7514  # CONFIG_I2C_I801 is not set
7515 +# CONFIG_I2C_NFORCE2 is not set
7516  # CONFIG_I2C_PIIX4 is not set
7517  # CONFIG_I2C_SIS96X is not set
7518  # CONFIG_I2C_VIAPRO is not set
7519 @@ -581,6 +586,7 @@
7520  # CONFIG_SENSORS_IT87 is not set
7521  # CONFIG_SENSORS_LM75 is not set
7522  # CONFIG_SENSORS_LM85 is not set
7523 +# CONFIG_SENSORS_LM78 is not set
7524  # CONFIG_SENSORS_VIA686A is not set
7525  # CONFIG_SENSORS_W83781D is not set
7526  # CONFIG_I2C_SENSOR is not set
7527 @@ -843,7 +849,6 @@
7528  # Kernel hacking
7529  #
7530  # CONFIG_DEBUG_KERNEL is not set
7531 -CONFIG_KALLSYMS=y
7532  CONFIG_BOOTX_TEXT=y
7533  
7534  #
7535 diff -Nru a/arch/ppc/defconfig b/arch/ppc/defconfig
7536 --- a/arch/ppc/defconfig        Sat Aug  2 12:59:32 2003
7537 +++ b/arch/ppc/defconfig        Sat Aug 23 02:33:38 2003
7538 @@ -9,6 +9,7 @@
7539  # Code maturity level options
7540  #
7541  CONFIG_EXPERIMENTAL=y
7542 +# CONFIG_BROKEN is not set
7543  
7544  #
7545  # General setup
7546 @@ -18,9 +19,15 @@
7547  # CONFIG_BSD_PROCESS_ACCT is not set
7548  CONFIG_SYSCTL=y
7549  CONFIG_LOG_BUF_SHIFT=14
7550 +CONFIG_IKCONFIG=y
7551 +CONFIG_IKCONFIG_PROC=y
7552  # CONFIG_EMBEDDED is not set
7553 +CONFIG_KALLSYMS=y
7554  CONFIG_FUTEX=y
7555  CONFIG_EPOLL=y
7556 +CONFIG_IOSCHED_NOOP=y
7557 +CONFIG_IOSCHED_AS=y
7558 +CONFIG_IOSCHED_DEADLINE=y
7559  
7560  #
7561  # Loadable module support
7562 @@ -78,6 +85,7 @@
7563  # CONFIG_TAU_INT is not set
7564  # CONFIG_TAU_AVERAGE is not set
7565  CONFIG_CPU_FREQ=y
7566 +CONFIG_CPU_FREQ_TABLE=y
7567  CONFIG_CPU_FREQ_PROC_INTF=y
7568  CONFIG_CPU_FREQ_24_API=y
7569  CONFIG_CPU_FREQ_PMAC=y
7570 @@ -89,8 +97,8 @@
7571  CONFIG_PCI=y
7572  CONFIG_PCI_DOMAINS=y
7573  CONFIG_KCORE_ELF=y
7574 -CONFIG_BINFMT_ELF=y
7575  CONFIG_KERNEL_ELF=y
7576 +CONFIG_BINFMT_ELF=y
7577  CONFIG_BINFMT_MISC=m
7578  CONFIG_PCI_LEGACY_PROC=y
7579  CONFIG_PCI_NAMES=y
7580 @@ -128,6 +136,11 @@
7581  CONFIG_BOOT_LOAD=0x00800000
7582  
7583  #
7584 +# Generic Driver Options
7585 +#
7586 +# CONFIG_FW_LOADER is not set
7587 +
7588 +#
7589  # Memory Technology Devices (MTD)
7590  #
7591  # CONFIG_MTD is not set
7592 @@ -146,10 +159,12 @@
7593  # CONFIG_BLK_DEV_DAC960 is not set
7594  # CONFIG_BLK_DEV_UMEM is not set
7595  CONFIG_BLK_DEV_LOOP=y
7596 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
7597  # CONFIG_BLK_DEV_NBD is not set
7598  CONFIG_BLK_DEV_RAM=y
7599  CONFIG_BLK_DEV_RAM_SIZE=4096
7600  CONFIG_BLK_DEV_INITRD=y
7601 +CONFIG_LBD=y
7602  
7603  #
7604  # Multi-device support (RAID and LVM)
7605 @@ -157,40 +172,38 @@
7606  # CONFIG_MD is not set
7607  
7608  #
7609 -# ATA/IDE/MFM/RLL support
7610 +# ATA/ATAPI/MFM/RLL support
7611  #
7612  CONFIG_IDE=y
7613 -
7614 -#
7615 -# IDE, ATA and ATAPI Block devices
7616 -#
7617  CONFIG_BLK_DEV_IDE=y
7618  
7619  #
7620  # Please see Documentation/ide.txt for help/info on IDE drives
7621  #
7622 -# CONFIG_BLK_DEV_HD is not set
7623  CONFIG_BLK_DEV_IDEDISK=y
7624  # CONFIG_IDEDISK_MULTI_MODE is not set
7625  # CONFIG_IDEDISK_STROKE is not set
7626  CONFIG_BLK_DEV_IDECD=y
7627 +# CONFIG_BLK_DEV_IDETAPE is not set
7628  CONFIG_BLK_DEV_IDEFLOPPY=y
7629  CONFIG_BLK_DEV_IDESCSI=y
7630  # CONFIG_IDE_TASK_IOCTL is not set
7631 +# CONFIG_IDE_TASKFILE_IO is not set
7632  
7633  #
7634  # IDE chipset support/bugfixes
7635  #
7636  CONFIG_BLK_DEV_IDEPCI=y
7637 -CONFIG_BLK_DEV_GENERIC=y
7638  CONFIG_IDEPCI_SHARE_IRQ=y
7639 +# CONFIG_BLK_DEV_OFFBOARD is not set
7640 +CONFIG_BLK_DEV_GENERIC=y
7641 +# CONFIG_BLK_DEV_OPTI621 is not set
7642 +CONFIG_BLK_DEV_SL82C105=y
7643  CONFIG_BLK_DEV_IDEDMA_PCI=y
7644  # CONFIG_BLK_DEV_IDE_TCQ is not set
7645 -# CONFIG_BLK_DEV_OFFBOARD is not set
7646  # CONFIG_BLK_DEV_IDEDMA_FORCED is not set
7647  CONFIG_IDEDMA_PCI_AUTO=y
7648  # CONFIG_IDEDMA_ONLYDISK is not set
7649 -CONFIG_BLK_DEV_IDEDMA=y
7650  # CONFIG_IDEDMA_PCI_WIP is not set
7651  CONFIG_BLK_DEV_ADMA=y
7652  # CONFIG_BLK_DEV_AEC62XX is not set
7653 @@ -200,12 +213,12 @@
7654  # CONFIG_BLK_DEV_TRIFLEX is not set
7655  # CONFIG_BLK_DEV_CY82C693 is not set
7656  # CONFIG_BLK_DEV_CS5520 is not set
7657 +# CONFIG_BLK_DEV_CS5530 is not set
7658  # CONFIG_BLK_DEV_HPT34X is not set
7659  # CONFIG_BLK_DEV_HPT366 is not set
7660  # CONFIG_BLK_DEV_SC1200 is not set
7661  # CONFIG_BLK_DEV_PIIX is not set
7662  # CONFIG_BLK_DEV_NS87415 is not set
7663 -# CONFIG_BLK_DEV_OPTI621 is not set
7664  # CONFIG_BLK_DEV_PDC202XX_OLD is not set
7665  # CONFIG_BLK_DEV_PDC202XX_NEW is not set
7666  # CONFIG_BLK_DEV_SVWKS is not set
7667 @@ -213,15 +226,17 @@
7668  # CONFIG_BLK_DEV_SLC90E66 is not set
7669  # CONFIG_BLK_DEV_TRM290 is not set
7670  # CONFIG_BLK_DEV_VIA82CXXX is not set
7671 -CONFIG_BLK_DEV_SL82C105=y
7672  CONFIG_BLK_DEV_IDE_PMAC=y
7673  CONFIG_BLK_DEV_IDEDMA_PMAC=y
7674  CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO=y
7675 -CONFIG_IDEDMA_AUTO=y
7676 +CONFIG_BLK_DEV_IDEDMA=y
7677  # CONFIG_IDEDMA_IVB is not set
7678 +CONFIG_IDEDMA_AUTO=y
7679 +# CONFIG_DMA_NONPCI is not set
7680 +# CONFIG_BLK_DEV_HD is not set
7681  
7682  #
7683 -# SCSI support
7684 +# SCSI device support
7685  #
7686  CONFIG_SCSI=y
7687  
7688 @@ -261,8 +276,6 @@
7689  # CONFIG_SCSI_AIC79XX is not set
7690  # CONFIG_SCSI_DPT_I2O is not set
7691  CONFIG_SCSI_ADVANSYS=m
7692 -# CONFIG_SCSI_IN2000 is not set
7693 -# CONFIG_SCSI_AM53C974 is not set
7694  # CONFIG_SCSI_MEGARAID is not set
7695  # CONFIG_SCSI_BUSLOGIC is not set
7696  # CONFIG_SCSI_CPQFCTS is not set
7697 @@ -271,11 +284,8 @@
7698  # CONFIG_SCSI_EATA_PIO is not set
7699  # CONFIG_SCSI_FUTURE_DOMAIN is not set
7700  # CONFIG_SCSI_GDTH is not set
7701 -# CONFIG_SCSI_GENERIC_NCR5380 is not set
7702 -# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
7703  # CONFIG_SCSI_INITIO is not set
7704  # CONFIG_SCSI_INIA100 is not set
7705 -# CONFIG_SCSI_NCR53C7xx is not set
7706  CONFIG_SCSI_SYM53C8XX_2=y
7707  CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0
7708  CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
7709 @@ -288,7 +298,6 @@
7710  # CONFIG_SCSI_QLOGIC_1280 is not set
7711  # CONFIG_SCSI_DC395x is not set
7712  # CONFIG_SCSI_DC390T is not set
7713 -# CONFIG_SCSI_U14_34F is not set
7714  # CONFIG_SCSI_NSP32 is not set
7715  # CONFIG_SCSI_DEBUG is not set
7716  CONFIG_SCSI_MESH=y
7717 @@ -322,8 +331,6 @@
7718  CONFIG_PACKET=y
7719  # CONFIG_PACKET_MMAP is not set
7720  # CONFIG_NETLINK_DEV is not set
7721 -CONFIG_NETFILTER=y
7722 -# CONFIG_NETFILTER_DEBUG is not set
7723  CONFIG_UNIX=y
7724  # CONFIG_NET_KEY is not set
7725  CONFIG_INET=y
7726 @@ -341,6 +348,16 @@
7727  # CONFIG_INET_IPCOMP is not set
7728  
7729  #
7730 +# IP: Virtual Server Configuration
7731 +#
7732 +# CONFIG_IP_VS is not set
7733 +# CONFIG_IPV6 is not set
7734 +# CONFIG_DECNET is not set
7735 +# CONFIG_BRIDGE is not set
7736 +CONFIG_NETFILTER=y
7737 +# CONFIG_NETFILTER_DEBUG is not set
7738 +
7739 +#
7740  # IP: Netfilter Configuration
7741  #
7742  CONFIG_IP_NF_CONNTRACK=m
7743 @@ -356,6 +373,7 @@
7744  CONFIG_IP_NF_MATCH_MARK=m
7745  CONFIG_IP_NF_MATCH_MULTIPORT=m
7746  CONFIG_IP_NF_MATCH_TOS=m
7747 +CONFIG_IP_NF_MATCH_RECENT=m
7748  CONFIG_IP_NF_MATCH_ECN=m
7749  CONFIG_IP_NF_MATCH_DSCP=m
7750  CONFIG_IP_NF_MATCH_AH_ESP=m
7751 @@ -386,10 +404,9 @@
7752  CONFIG_IP_NF_TARGET_TCPMSS=m
7753  CONFIG_IP_NF_ARPTABLES=m
7754  CONFIG_IP_NF_ARPFILTER=m
7755 +CONFIG_IP_NF_ARP_MANGLE=m
7756  CONFIG_IP_NF_COMPAT_IPCHAINS=m
7757  # CONFIG_IP_NF_COMPAT_IPFWADM is not set
7758 -# CONFIG_IPV6 is not set
7759 -# CONFIG_XFRM_USER is not set
7760  
7761  #
7762  # SCTP Configuration (EXPERIMENTAL)
7763 @@ -399,8 +416,6 @@
7764  # CONFIG_ATM is not set
7765  # CONFIG_VLAN_8021Q is not set
7766  # CONFIG_LLC is not set
7767 -# CONFIG_DECNET is not set
7768 -# CONFIG_BRIDGE is not set
7769  # CONFIG_X25 is not set
7770  # CONFIG_LAPB is not set
7771  # CONFIG_NET_DIVERT is not set
7772 @@ -477,6 +492,7 @@
7773  # CONFIG_HAMACHI is not set
7774  # CONFIG_YELLOWFIN is not set
7775  # CONFIG_R8169 is not set
7776 +# CONFIG_SIS190 is not set
7777  # CONFIG_SK98LIN is not set
7778  # CONFIG_TIGON3 is not set
7779  
7780 @@ -548,7 +564,7 @@
7781  # Graphics support
7782  #
7783  CONFIG_FB=y
7784 -CONFIG_FB_CIRRUS=y
7785 +# CONFIG_FB_CIRRUS is not set
7786  # CONFIG_FB_PM2 is not set
7787  # CONFIG_FB_CYBER2000 is not set
7788  CONFIG_FB_OF=y
7789 @@ -602,11 +618,6 @@
7790  CONFIG_LOGO_LINUX_CLUT224=y
7791  
7792  #
7793 -# Old CD-ROM drivers (not SCSI, not IDE)
7794 -#
7795 -# CONFIG_CD_NO_IDESCSI is not set
7796 -
7797 -#
7798  # Input device support
7799  #
7800  CONFIG_INPUT=y
7801 @@ -632,6 +643,7 @@
7802  CONFIG_SERIO_I8042=y
7803  CONFIG_SERIO_SERPORT=y
7804  # CONFIG_SERIO_CT82C710 is not set
7805 +# CONFIG_SERIO_PCIPS2 is not set
7806  
7807  #
7808  # Input Device Drivers
7809 @@ -698,10 +710,12 @@
7810  #
7811  # I2C Hardware Sensors Mainboard support
7812  #
7813 +# CONFIG_I2C_ALI1535 is not set
7814  # CONFIG_I2C_ALI15X3 is not set
7815  # CONFIG_I2C_AMD756 is not set
7816  # CONFIG_I2C_AMD8111 is not set
7817  # CONFIG_I2C_I801 is not set
7818 +# CONFIG_I2C_NFORCE2 is not set
7819  # CONFIG_I2C_PIIX4 is not set
7820  # CONFIG_I2C_SIS96X is not set
7821  # CONFIG_I2C_VIAPRO is not set
7822 @@ -713,6 +727,7 @@
7823  # CONFIG_SENSORS_IT87 is not set
7824  # CONFIG_SENSORS_LM75 is not set
7825  # CONFIG_SENSORS_LM85 is not set
7826 +# CONFIG_SENSORS_LM78 is not set
7827  # CONFIG_SENSORS_VIA686A is not set
7828  # CONFIG_SENSORS_W83781D is not set
7829  # CONFIG_I2C_SENSOR is not set
7830 @@ -1047,6 +1062,7 @@
7831  #
7832  # USB Network adaptors
7833  #
7834 +# CONFIG_USB_AX8817X is not set
7835  # CONFIG_USB_CATC is not set
7836  # CONFIG_USB_KAWETH is not set
7837  # CONFIG_USB_PEGASUS is not set
7838 @@ -1123,7 +1139,6 @@
7839  # Kernel hacking
7840  #
7841  # CONFIG_DEBUG_KERNEL is not set
7842 -CONFIG_KALLSYMS=y
7843  CONFIG_BOOTX_TEXT=y
7844  
7845  #
7846 diff -Nru a/arch/ppc/kernel/cputable.c b/arch/ppc/kernel/cputable.c
7847 --- a/arch/ppc/kernel/cputable.c        Sun Apr 27 05:41:48 2003
7848 +++ b/arch/ppc/kernel/cputable.c        Sun Aug 24 03:04:21 2003
7849 @@ -154,6 +154,15 @@
7850         32, 32,
7851         __setup_cpu_750cx
7852      },
7853 +    {  /* 750FX rev 1.x */
7854 +       0xffffff00, 0x70000100, "750FX",
7855 +       CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
7856 +       CPU_FTR_L2CR | CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_CAN_NAP |
7857 +       CPU_FTR_DUAL_PLL_750FX | CPU_FTR_NO_DPM,
7858 +       COMMON_PPC,
7859 +       32, 32,
7860 +       __setup_cpu_750
7861 +    },
7862      {  /* 750FX rev 2.0 must disable HID0[DPM] */
7863         0xffffffff, 0x70000200, "750FX",
7864         CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_CAN_DOZE | CPU_FTR_USE_TB |
7865 diff -Nru a/arch/ppc/kernel/head.S b/arch/ppc/kernel/head.S
7866 --- a/arch/ppc/kernel/head.S    Wed Jun  4 20:07:15 2003
7867 +++ b/arch/ppc/kernel/head.S    Tue Aug 26 06:38:51 2003
7868 @@ -355,11 +355,6 @@
7869   *     -- paulus.
7870   */
7871         . = 0x200
7872 -MachineCheck:
7873 -BEGIN_FTR_SECTION
7874 -       dssall
7875 -       sync
7876 -END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
7877         mtspr   SPRG0,r10
7878         mtspr   SPRG1,r11
7879         mfcr    r10
7880 diff -Nru a/arch/ppc/kernel/misc.S b/arch/ppc/kernel/misc.S
7881 --- a/arch/ppc/kernel/misc.S    Tue Jul 15 04:47:19 2003
7882 +++ b/arch/ppc/kernel/misc.S    Fri Aug 22 19:15:18 2003
7883 @@ -1380,3 +1380,4 @@
7884         .long sys_utimes
7885         .long sys_statfs64
7886         .long sys_fstatfs64
7887 +       .long ppc_fadvise64_64
7888 diff -Nru a/arch/ppc/kernel/ppc-stub.c b/arch/ppc/kernel/ppc-stub.c
7889 --- a/arch/ppc/kernel/ppc-stub.c        Mon Jun 30 10:10:33 2003
7890 +++ b/arch/ppc/kernel/ppc-stub.c        Mon Aug 25 11:39:55 2003
7891 @@ -106,6 +106,7 @@
7892  #include <linux/smp.h>
7893  #include <linux/smp_lock.h>
7894  
7895 +#include <asm/cacheflush.h>
7896  #include <asm/system.h>
7897  #include <asm/signal.h>
7898  #include <asm/kgdb.h>
7899 @@ -136,7 +137,7 @@
7900  /* typedef void (*trapfunc_t)(void); */
7901  
7902  static void kgdb_fault_handler(struct pt_regs *regs);
7903 -static void handle_exception (struct pt_regs *regs);
7904 +static int handle_exception (struct pt_regs *regs);
7905  
7906  #if 0
7907  /* Install an exception handler for kgdb */
7908 @@ -186,7 +187,7 @@
7909   * return 0.
7910   */
7911  static unsigned char *
7912 -mem2hex(char *mem, char *buf, int count)
7913 +mem2hex(const char *mem, char *buf, int count)
7914  {
7915         unsigned char ch;
7916         unsigned short tmp_s;
7917 @@ -460,14 +461,12 @@
7918  
7919  int kgdb_bpt(struct pt_regs *regs)
7920  {
7921 -       handle_exception(regs);
7922 -       return 1;
7923 +       return handle_exception(regs);
7924  }
7925  
7926  int kgdb_sstep(struct pt_regs *regs)
7927  {
7928 -       handle_exception(regs);
7929 -       return 1;
7930 +       return handle_exception(regs);
7931  }
7932  
7933  void kgdb(struct pt_regs *regs)
7934 @@ -477,16 +476,14 @@
7935  
7936  int kgdb_iabr_match(struct pt_regs *regs)
7937  {
7938 -       printk("kgdb doesn't support iabr, what?!?\n");
7939 -       handle_exception(regs);
7940 -       return 1;
7941 +       printk(KERN_ERR "kgdb doesn't support iabr, what?!?\n");
7942 +       return handle_exception(regs);
7943  }
7944  
7945  int kgdb_dabr_match(struct pt_regs *regs)
7946  {
7947 -       printk("kgdb doesn't support dabr, what?!?\n");
7948 -       handle_exception(regs);
7949 -       return 1;
7950 +       printk(KERN_ERR "kgdb doesn't support dabr, what?!?\n");
7951 +       return handle_exception(regs);
7952  }
7953  
7954  /* Convert the hardware trap type code to a unix signal number. */
7955 @@ -559,7 +556,7 @@
7956  /*
7957   * This function does all command processing for interfacing to gdb.
7958   */
7959 -static void
7960 +static int
7961  handle_exception (struct pt_regs *regs)
7962  {
7963         int sigval;
7964 @@ -568,14 +565,19 @@
7965         char *ptr;
7966         unsigned int msr;
7967  
7968 +       /* We don't handle user-mode breakpoints. */
7969 +       if (user_mode(regs))
7970 +               return 0;
7971 +
7972         if (debugger_fault_handler) {
7973                 debugger_fault_handler(regs);
7974                 panic("kgdb longjump failed!\n");
7975         }
7976         if (kgdb_active) {
7977 -               printk("interrupt while in kgdb, returning\n");
7978 -               return;
7979 +               printk(KERN_ERR "interrupt while in kgdb, returning\n");
7980 +               return 0;
7981         }
7982 +
7983         kgdb_active = 1;
7984         kgdb_started = 1;
7985  
7986 @@ -783,7 +785,7 @@
7987                                 printk("remcomInBuffer: %s\n", remcomInBuffer);
7988                                 printk("remcomOutBuffer: %s\n", remcomOutBuffer);
7989                         }
7990 -                       return;
7991 +                       return 1;
7992  
7993                 case 's':
7994                         kgdb_flush_cache_all();
7995 @@ -800,7 +802,7 @@
7996                                 printk("remcomInBuffer: %s\n", remcomInBuffer);
7997                                 printk("remcomOutBuffer: %s\n", remcomOutBuffer);
7998                         }
7999 -                       return;
8000 +                       return 1;
8001  
8002                 case 'r':               /* Reset (if user process..exit ???)*/
8003                         panic("kgdb reset.");
8004 @@ -828,11 +830,11 @@
8005                 return;
8006         }
8007  
8008 -       asm("   .globl breakinst
8009 -            breakinst: .long 0x7d821008
8010 -           ");
8011 +       asm("   .globl breakinst        \n\
8012 +            breakinst: .long 0x7d821008");
8013  }
8014  
8015 +#ifdef CONFIG_KGDB_CONSOLE
8016  /* Output string in GDB O-packet format if GDB has connected. If nothing
8017     output, returns 0 (caller must then handle output). */
8018  int
8019 @@ -852,3 +854,4 @@
8020  
8021         return 1;
8022  }
8023 +#endif
8024 diff -Nru a/arch/ppc/kernel/ppc_ksyms.c b/arch/ppc/kernel/ppc_ksyms.c
8025 --- a/arch/ppc/kernel/ppc_ksyms.c       Tue Jul  1 10:57:22 2003
8026 +++ b/arch/ppc/kernel/ppc_ksyms.c       Sun Aug 24 03:57:52 2003
8027 @@ -200,6 +200,7 @@
8028  EXPORT_SYMBOL(flush_icache_user_range);
8029  EXPORT_SYMBOL(flush_dcache_page);
8030  EXPORT_SYMBOL(flush_tlb_kernel_range);
8031 +EXPORT_SYMBOL(flush_tlb_page);
8032  #ifdef CONFIG_ALTIVEC
8033  EXPORT_SYMBOL(last_task_used_altivec);
8034  EXPORT_SYMBOL(giveup_altivec);
8035 @@ -259,6 +260,15 @@
8036  EXPORT_SYMBOL(pci_busdev_to_OF_node);
8037  EXPORT_SYMBOL(pci_device_to_OF_node);
8038  EXPORT_SYMBOL(pci_device_from_OF_node);
8039 +EXPORT_SYMBOL(of_find_node_by_name);
8040 +EXPORT_SYMBOL(of_find_node_by_type);
8041 +EXPORT_SYMBOL(of_find_compatible_node);
8042 +EXPORT_SYMBOL(of_find_node_by_path);
8043 +EXPORT_SYMBOL(of_find_all_nodes);
8044 +EXPORT_SYMBOL(of_get_parent);
8045 +EXPORT_SYMBOL(of_get_next_child);
8046 +EXPORT_SYMBOL(of_node_get);
8047 +EXPORT_SYMBOL(of_node_put);
8048  #endif /* CONFIG_PPC_OF */
8049  #if defined(CONFIG_BOOTX_TEXT)
8050  EXPORT_SYMBOL(btext_update_display);
8051 diff -Nru a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c
8052 --- a/arch/ppc/kernel/setup.c   Mon Aug 18 19:46:23 2003
8053 +++ b/arch/ppc/kernel/setup.c   Mon Aug 25 11:11:43 2003
8054 @@ -624,12 +624,10 @@
8055  #if defined(CONFIG_KGDB)
8056         kgdb_map_scc();
8057         set_debug_traps();
8058 -       if (strstr(cmd_line, "nokgdb"))
8059 -               printk("kgdb default breakpoint deactivated on command line\n");
8060 -       else {
8061 +       if (strstr(cmd_line, "gdb")) {
8062                 if (ppc_md.progress)
8063                         ppc_md.progress("setup_arch: kgdb breakpoint", 0x4000);
8064 -               printk("kgdb default breakpoint activated\n");
8065 +               printk("kgdb breakpoint activated\n");
8066                 breakpoint();
8067         }
8068  #endif
8069 diff -Nru a/arch/ppc/kernel/smp.c b/arch/ppc/kernel/smp.c
8070 --- a/arch/ppc/kernel/smp.c     Mon Aug 18 19:46:23 2003
8071 +++ b/arch/ppc/kernel/smp.c     Fri Aug 22 19:58:08 2003
8072 @@ -47,8 +47,8 @@
8073  DEFINE_PER_CPU(unsigned int, prof_multiplier);
8074  DEFINE_PER_CPU(unsigned int, prof_counter);
8075  unsigned long cache_decay_ticks = HZ/100;
8076 -unsigned long cpu_online_map = cpumask_of_cpu(0);
8077 -unsigned long cpu_possible_map = 1UL;
8078 +cpumask_t cpu_online_map;
8079 +cpumask_t cpu_possible_map;
8080  int smp_hw_index[NR_CPUS];
8081  struct thread_info *secondary_ti;
8082  
8083 @@ -336,7 +336,7 @@
8084  
8085  void __init smp_prepare_cpus(unsigned int max_cpus)
8086  {
8087 -       int num_cpus;
8088 +       int num_cpus, i;
8089  
8090         /* Fixup boot cpu */
8091          smp_store_cpu_info(smp_processor_id());
8092 @@ -350,7 +350,8 @@
8093  
8094         /* Probe platform for CPUs: always linear. */
8095         num_cpus = smp_ops->probe();
8096 -       cpu_possible_map = (1 << num_cpus)-1;
8097 +       for (i = 0; i < num_cpus; ++i)
8098 +               cpu_set(i, cpu_possible_map);
8099  
8100         /* Backup CPU 0 state */
8101         __save_cpu_setup();
8102 diff -Nru a/arch/ppc/kernel/syscalls.c b/arch/ppc/kernel/syscalls.c
8103 --- a/arch/ppc/kernel/syscalls.c        Tue Jul 15 04:49:49 2003
8104 +++ b/arch/ppc/kernel/syscalls.c        Fri Aug 22 19:15:18 2003
8105 @@ -262,4 +262,14 @@
8106         return error;
8107  }
8108  
8109 +/*
8110 + * We put the arguments in a different order so we only use 6
8111 + * registers for arguments, rather than 7 as sys_fadvise64_64 needs
8112 + * (because `offset' goes in r5/r6).
8113 + */
8114 +long ppc_fadvise64_64(int fd, int advice, loff_t offset, loff_t len)
8115 +{
8116 +       return sys_fadvise64_64(fd, offset, len, advice);
8117 +}
8118 +
8119  cond_syscall(sys_pciconfig_iobase);
8120 diff -Nru a/arch/ppc/platforms/mcpn765_serial.h b/arch/ppc/platforms/mcpn765_serial.h
8121 --- a/arch/ppc/platforms/mcpn765_serial.h       Tue Feb 11 15:48:53 2003
8122 +++ b/arch/ppc/platforms/mcpn765_serial.h       Mon Jul 21 09:05:22 2003
8123 @@ -30,7 +30,8 @@
8124  #endif
8125  
8126  /* Rate for the 1.8432 Mhz clock for the onboard serial chip */
8127 -#define BASE_BAUD ( 1843200 / 16 )
8128 +#define BASE_BAUD      ( 1843200 / 16 )
8129 +#define UART_CLK       1843200
8130  
8131  #ifdef CONFIG_SERIAL_DETECT_IRQ
8132  #define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST|ASYNC_AUTO_IRQ)
8133 diff -Nru a/arch/ppc/platforms/mcpn765_setup.c b/arch/ppc/platforms/mcpn765_setup.c
8134 --- a/arch/ppc/platforms/mcpn765_setup.c        Wed Apr 23 00:49:34 2003
8135 +++ b/arch/ppc/platforms/mcpn765_setup.c        Mon Jul 21 09:05:22 2003
8136 @@ -31,6 +31,9 @@
8137  #include <linux/ide.h>
8138  #include <linux/seq_file.h>
8139  #include <linux/root_dev.h>
8140 +#include <linux/serial.h>
8141 +#include <linux/tty.h> /* for linux/serial_core.h */
8142 +#include <linux/serial_core.h>
8143  
8144  #include <asm/system.h>
8145  #include <asm/pgtable.h>
8146 @@ -49,36 +52,94 @@
8147  #include <asm/pplus.h>
8148  
8149  #include "mcpn765.h"
8150 +#include "mcpn765_serial.h"
8151 +
8152  
8153  static u_char mcpn765_openpic_initsenses[] __initdata = {
8154 -       0,      /* 16: i8259 cascade (active high) */
8155 -       1,      /* 17: COM1,2,3,4 */
8156 -       1,      /* 18: Enet 1 (front panel) */
8157 -       1,      /* 19: HAWK WDT XXXX */
8158 -       1,      /* 20: 21554 PCI-PCI bridge */
8159 -       1,      /* 21: cPCI INTA# */
8160 -       1,      /* 22: cPCI INTB# */
8161 -       1,      /* 23: cPCI INTC# */
8162 -       1,      /* 24: cPCI INTD# */
8163 -       1,      /* 25: PMC1 INTA#, PMC2 INTB# */
8164 -       1,      /* 26: PMC1 INTB#, PMC2 INTC# */
8165 -       1,      /* 27: PMC1 INTC#, PMC2 INTD# */
8166 -       1,      /* 28: PMC1 INTD#, PMC2 INTA# */
8167 -       1,      /* 29: Enet 2 (connected to J3) */
8168 -       1,      /* 30: Abort Switch */
8169 -       1,      /* 31: RTC Alarm */
8170 +       (IRQ_SENSE_EDGE  | IRQ_POLARITY_POSITIVE),/* 16: i8259 cascade */
8171 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 17: COM1,2,3,4 */
8172 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 18: Enet 1 (front) */
8173 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 19: HAWK WDT XXXX */
8174 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 20: 21554 bridge */
8175 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 21: cPCI INTA# */
8176 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 22: cPCI INTB# */
8177 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 23: cPCI INTC# */
8178 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 24: cPCI INTD# */
8179 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 25: PMC1 INTA#,PMC2 INTB#*/
8180 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 26: PMC1 INTB#,PMC2 INTC#*/
8181 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 27: PMC1 INTC#,PMC2 INTD#*/
8182 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 28: PMC1 INTD#,PMC2 INTA#*/
8183 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 29: Enet 2 (J3) */
8184 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 30: Abort Switch */
8185 +       (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/* 31: RTC Alarm */
8186  };
8187  
8188  
8189  extern u_int openpic_irq(void);
8190  extern char cmd_line[];
8191  
8192 +extern void gen550_progress(char *, unsigned short);
8193 +extern void gen550_init(int, struct uart_port *);
8194 +
8195  int use_of_interrupt_tree = 0;
8196  
8197  static void mcpn765_halt(void);
8198  
8199  TODC_ALLOC();
8200  
8201 +#if defined(CONFIG_SERIAL_8250) && \
8202 +       (defined(CONFIG_KGDB) || defined(CONFIG_SERIAL_TEXT_DEBUG))
8203 +static void __init
8204 +mcpn765_early_serial_map(void)
8205 +{
8206 +       struct uart_port serial_req;
8207 +
8208 +       /* Setup serial port access */
8209 +       memset(&serial_req, 0, sizeof(serial_req));
8210 +       serial_req.uartclk = UART_CLK;
8211 +       serial_req.irq = 17;
8212 +       serial_req.flags = STD_COM_FLAGS;
8213 +       serial_req.iotype = SERIAL_IO_MEM;
8214 +       serial_req.membase = (u_char *)MCPN765_SERIAL_1;
8215 +       serial_req.regshift = 4;
8216 +
8217 +       gen550_init(0, &serial_req);
8218 +
8219 +       if (early_serial_setup(&serial_req) != 0)
8220 +               printk(KERN_ERR "Early serial init of port 0 failed\n");
8221 +
8222 +       /* Assume early_serial_setup() doesn't modify serial_req */
8223 +       serial_req.line = 1;
8224 +       serial_req.irq = 17;
8225 +       serial_req.membase = (u_char *)MCPN765_SERIAL_2;
8226 +
8227 +       gen550_init(1, &serial_req);
8228 +
8229 +       if (early_serial_setup(&serial_req) != 0)
8230 +               printk(KERN_ERR "Early serial init of port 1 failed\n");
8231 +
8232 +       /* Assume early_serial_setup() doesn't modify serial_req */
8233 +       serial_req.line = 2;
8234 +       serial_req.irq = 17;
8235 +       serial_req.membase = (u_char *)MCPN765_SERIAL_3;
8236 +
8237 +       gen550_init(2, &serial_req);
8238 +
8239 +       if (early_serial_setup(&serial_req) != 0)
8240 +               printk(KERN_ERR "Early serial init of port 2 failed\n");
8241 +
8242 +       /* Assume early_serial_setup() doesn't modify serial_req */
8243 +       serial_req.line = 3;
8244 +       serial_req.irq = 17;
8245 +       serial_req.membase = (u_char *)MCPN765_SERIAL_4;
8246 +
8247 +       gen550_init(3, &serial_req);
8248 +
8249 +       if (early_serial_setup(&serial_req) != 0)
8250 +               printk(KERN_ERR "Early serial init of port 3 failed\n");
8251 +}
8252 +#endif
8253 +
8254  static void __init
8255  mcpn765_setup_arch(void)
8256  {
8257 @@ -187,12 +248,12 @@
8258         if ( ppc_md.progress )
8259                 ppc_md.progress("init_irq: enter", 0);
8260  
8261 -       openpic_init(1, NUM_8259_INTERRUPTS, NULL, -1);
8262 +       openpic_init(NUM_8259_INTERRUPTS);
8263  
8264         for(i=0; i < NUM_8259_INTERRUPTS; i++)
8265                 irq_desc[i].handler = &i8259_pic;
8266  
8267 -       i8259_init(NULL);
8268 +       i8259_init(0);
8269  
8270         if ( ppc_md.progress )
8271                 ppc_md.progress("init_irq: exit", 0);
8272 @@ -361,65 +422,15 @@
8273  static __inline__ void
8274  mcpn765_set_bat(void)
8275  {
8276 -       unsigned long   bat3u, bat3l;
8277 -       static int      mapping_set = 0;
8278 -
8279 -       if (!mapping_set) {
8280 -
8281 -               __asm__ __volatile__(
8282 -               " lis %0,0xf000\n \
8283 -                 ori %1,%0,0x002a\n \
8284 -                 ori %0,%0,0x1ffe\n \
8285 -                 mtspr 0x21e,%0\n \
8286 -                 mtspr 0x21f,%1\n \
8287 -                 isync\n \
8288 -                 sync "
8289 -               : "=r" (bat3u), "=r" (bat3l));
8290 -
8291 -               mapping_set = 1;
8292 -       }
8293 -
8294 -       return;
8295 -}
8296 -
8297 -#ifdef CONFIG_SERIAL_TEXT_DEBUG
8298 -#include <linux/serialP.h>
8299 -#include <linux/serial_reg.h>
8300 -#include <asm/serial.h>
8301 -
8302 -static struct serial_state rs_table[RS_TABLE_SIZE] = {
8303 -       SERIAL_PORT_DFNS        /* Defined in <asm/serial.h> */
8304 -};
8305 -
8306 -static void
8307 -mcpn765_progress(char *s, unsigned short hex)
8308 -{
8309 -       volatile char c;
8310 -       volatile unsigned long com_port;
8311 -       u16 shift;
8312 -
8313 -       com_port = rs_table[0].port;
8314 -       shift = rs_table[0].iomem_reg_shift;
8315 -
8316 -       while ((c = *s++) != 0) {
8317 -               while ((*((volatile unsigned char *)com_port +
8318 -                               (UART_LSR << shift)) & UART_LSR_THRE) == 0)
8319 -                               ;
8320 -               *(volatile unsigned char *)com_port = c;
8321 -
8322 -               if (c == '\n') {
8323 -                       while ((*((volatile unsigned char *)com_port +
8324 -                               (UART_LSR << shift)) & UART_LSR_THRE) == 0)
8325 -                                       ;
8326 -                       *(volatile unsigned char *)com_port = '\r';
8327 -               }
8328 -       }
8329 +       mb();
8330 +       mtspr(DBAT1U, 0xfe8000fe);
8331 +       mtspr(DBAT1L, 0xfe80002a);
8332 +       mb();
8333  }
8334 -#endif /* CONFIG_SERIAL_TEXT_DEBUG */
8335  
8336  void __init
8337  platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
8338 -             unsigned long r6, unsigned long r7)
8339 +               unsigned long r6, unsigned long r7)
8340  {
8341         parse_bootinfo(find_bootinfo());
8342  
8343 @@ -458,11 +469,13 @@
8344         ppc_md.heartbeat_reset = 0;
8345         ppc_md.heartbeat_count = 0;
8346  
8347 -#ifdef CONFIG_SERIAL_TEXT_DEBUG
8348 -       ppc_md.progress = mcpn765_progress;
8349 -#else  /* !CONFIG_SERIAL_TEXT_DEBUG */
8350 -       ppc_md.progress = NULL;
8351 -#endif /* CONFIG_SERIAL_TEXT_DEBUG */
8352 +#if defined(CONFIG_SERIAL_8250) && \
8353 +       (defined(CONFIG_KGDB) || defined(CONFIG_SERIAL_TEXT_DEBUG))
8354 +       mcpn765_early_serial_map();
8355 +#ifdef CONFIG_SERIAL_TEXT_DEBUG
8356 +       ppc_md.progress = gen550_progress;
8357 +#endif
8358 +#endif
8359  
8360  #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
8361          ppc_ide_md.default_irq = mcpn765_ide_default_irq;
8362 diff -Nru a/arch/ppc/platforms/pmac_cpufreq.c b/arch/ppc/platforms/pmac_cpufreq.c
8363 --- a/arch/ppc/platforms/pmac_cpufreq.c Wed Jul 23 17:04:23 2003
8364 +++ b/arch/ppc/platforms/pmac_cpufreq.c Mon Aug 25 09:51:43 2003
8365 @@ -21,6 +21,7 @@
8366  #include <linux/slab.h>
8367  #include <linux/cpufreq.h>
8368  #include <linux/init.h>
8369 +#include <linux/sysdev.h>
8370  #include <asm/prom.h>
8371  #include <asm/machdep.h>
8372  #include <asm/irq.h>
8373 @@ -31,12 +32,16 @@
8374  #include <asm/cputable.h>
8375  #include <asm/time.h>
8376  
8377 +/* WARNING !!! This will cause calibrate_delay() to be called,
8378 + * but this is an __init function ! So you MUST go edit
8379 + * init/main.c to make it non-init before enabling DEBUG_FREQ
8380 + */
8381  #undef DEBUG_FREQ
8382  
8383  extern void low_choose_750fx_pll(int pll);
8384  extern void low_sleep_handler(void);
8385 -extern void openpic_sleep_save_intrs(void);
8386 -extern void openpic_sleep_restore_intrs(void);
8387 +extern void openpic_suspend(struct sys_device *sysdev, u32 state);
8388 +extern void openpic_resume(struct sys_device *sysdev);
8389  extern void enable_kernel_altivec(void);
8390  extern void enable_kernel_fp(void);
8391  
8392 @@ -116,10 +121,7 @@
8393         printk(KERN_DEBUG "HID1, before: %x\n", mfspr(SPRN_HID1));      
8394  #endif
8395         /* Disable all interrupt sources on openpic */
8396 -       openpic_sleep_save_intrs();
8397 -
8398 -       /* Make sure the PMU is idle */
8399 -       pmu_suspend();
8400 +       openpic_suspend(NULL, 1);
8401  
8402         /* Make sure the decrementer won't interrupt us */
8403         asm volatile("mtdec %0" : : "r" (0x7fffffff));
8404 @@ -153,11 +155,16 @@
8405         pmu_request(&req, NULL, 6, PMU_CPU_SPEED, 'W', 'O', 'O', 'F', low_speed);
8406         while (!req.complete)
8407                 pmu_poll();
8408 -       
8409 -       pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,1,1);
8410  
8411 +       /* Prepare the northbridge for the speed transition */
8412 +       pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,1,1);
8413 +       
8414 +       /* Call low level code to backup CPU state and recover from
8415 +        * hardware reset
8416 +        */
8417         low_sleep_handler();
8418         
8419 +       /* Restore the northbridge */
8420         pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,1,0);
8421  
8422         /* Restore L2 cache */
8423 @@ -174,13 +181,14 @@
8424         printk(KERN_DEBUG "HID1, after: %x\n", mfspr(SPRN_HID1));       
8425  #endif
8426  
8427 +       /* Restore low level PMU operations */
8428 +       pmu_unlock();
8429 +
8430         /* Restore decrementer */
8431         wakeup_decrementer();
8432  
8433         /* Restore interrupts */
8434 -       openpic_sleep_restore_intrs();
8435 -
8436 -       pmu_resume();
8437 +       openpic_resume(NULL);
8438  
8439         /* Let interrupts flow again ... */
8440         local_irq_enable();
8441 @@ -195,13 +203,16 @@
8442  static int __pmac
8443  do_set_cpu_speed(int speed_mode)
8444  {
8445 -       struct cpufreq_freqs    freqs;
8446 +       struct cpufreq_freqs freqs;
8447         int rc;
8448         
8449         freqs.old = cur_freq;
8450         freqs.new = (speed_mode == PMAC_CPU_HIGH_SPEED) ? hi_freq : low_freq;
8451         freqs.cpu = smp_processor_id();
8452  
8453 +       if (freqs.old == freqs.new)
8454 +               return 0;
8455 +
8456         cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
8457         if (cpufreq_uses_pmu)
8458                 rc = pmu_set_cpu_speed(speed_mode);
8459 @@ -275,7 +286,10 @@
8460         struct device_node      *cpunode;
8461         u32                     *value;
8462         int                     has_freq_ctl = 0;
8463 -       
8464 +       
8465 +       if (strstr(cmd_line, "nocpufreq"))
8466 +               return 0;
8467 +
8468         /* Assume only one CPU */
8469         cpunode = find_type_devices("cpu");
8470         if (!cpunode)
8471 diff -Nru a/arch/ppc/platforms/pmac_pic.c b/arch/ppc/platforms/pmac_pic.c
8472 --- a/arch/ppc/platforms/pmac_pic.c     Wed Apr 30 05:41:43 2003
8473 +++ b/arch/ppc/platforms/pmac_pic.c     Sun Aug 24 04:12:57 2003
8474 @@ -22,6 +22,9 @@
8475  #include <linux/signal.h>
8476  #include <linux/pci.h>
8477  #include <linux/interrupt.h>
8478 +#include <linux/sysdev.h>
8479 +#include <linux/adb.h>
8480 +#include <linux/pmu.h>
8481  
8482  #include <asm/sections.h>
8483  #include <asm/io.h>
8484 @@ -506,7 +509,7 @@
8485  #endif /* CONFIG_XMON */
8486  }
8487  
8488 -#ifdef CONFIG_PMAC_PBOOK
8489 +#ifdef CONFIG_PM
8490  /*
8491   * These procedures are used in implementing sleep on the powerbooks.
8492   * sleep_save_intrs() saves the states of all interrupt enables
8493 @@ -515,9 +518,32 @@
8494   */
8495  unsigned long sleep_save_mask[2];
8496  
8497 -void __pmac
8498 -pmac_sleep_save_intrs(int viaint)
8499 +/* This used to be passed by the PMU driver but that link got
8500 + * broken with the new driver model. We use this tweak for now...
8501 + */
8502 +static int pmacpic_find_viaint(void)
8503  {
8504 +       int viaint = -1;
8505 +       
8506 +#ifdef CONFIG_ADB_PMU
8507 +       struct device_node *np;
8508 +
8509 +       if (pmu_get_model() != PMU_OHARE_BASED)
8510 +               goto not_found;
8511 +       np = of_find_node_by_name(NULL, "via-pmu");
8512 +       if (np == NULL)
8513 +               goto not_found;
8514 +       viaint = np->intrs[0].line;
8515 +#endif /* CONFIG_ADB_PMU */
8516 +
8517 +not_found:
8518 +       return viaint;
8519 +}
8520 +
8521 +static int pmacpic_suspend(struct sys_device *sysdev, u32 state)
8522 +{
8523 +       int viaint = pmacpic_find_viaint();
8524 +       
8525         sleep_save_mask[0] = ppc_cached_irq_mask[0];
8526         sleep_save_mask[1] = ppc_cached_irq_mask[1];
8527         ppc_cached_irq_mask[0] = 0;
8528 @@ -531,10 +557,11 @@
8529         /* make sure mask gets to controller before we return to caller */
8530         mb();
8531          (void)in_le32(&pmac_irq_hw[0]->enable);
8532 +
8533 +        return 0;
8534  }
8535  
8536 -void __pmac
8537 -pmac_sleep_restore_intrs(void)
8538 +static int pmacpic_resume(struct sys_device *sysdev)
8539  {
8540         int i;
8541  
8542 @@ -545,5 +572,39 @@
8543         for (i = 0; i < max_real_irqs; ++i)
8544                 if (test_bit(i, sleep_save_mask))
8545                         pmac_unmask_irq(i);
8546 +
8547 +       return 0;
8548  }
8549 -#endif /* CONFIG_PMAC_PBOOK */
8550 +
8551 +#endif /* CONFIG_PM */
8552 +
8553 +static struct sysdev_class pmacpic_sysclass = {
8554 +       set_kset_name("pmac_pic"),
8555 +};
8556 +
8557 +static struct sys_device device_pmacpic = {
8558 +       .id             = 0,
8559 +       .cls            = &pmacpic_sysclass,
8560 +};
8561 +
8562 +static struct sysdev_driver driver_pmacpic = {
8563 +#ifdef CONFIG_PM
8564 +       .suspend        = &pmacpic_suspend,
8565 +       .resume         = &pmacpic_resume,
8566 +#endif /* CONFIG_PM */ 
8567 +};
8568 +
8569 +static int __init init_pmacpic_sysfs(void)
8570 +{
8571 +       if (max_irqs == 0)
8572 +               return -ENODEV;
8573 +
8574 +       printk(KERN_DEBUG "Registering pmac pic with sysfs...\n");
8575 +       sysdev_class_register(&pmacpic_sysclass);
8576 +       sys_device_register(&device_pmacpic);
8577 +       sysdev_driver_register(&pmacpic_sysclass, &driver_pmacpic);
8578 +       return 0;
8579 +}
8580 +
8581 +subsys_initcall(init_pmacpic_sysfs);
8582 +
8583 diff -Nru a/arch/ppc/platforms/sandpoint.c b/arch/ppc/platforms/sandpoint.c
8584 --- a/arch/ppc/platforms/sandpoint.c    Tue Jul  1 10:56:46 2003
8585 +++ b/arch/ppc/platforms/sandpoint.c    Thu Aug 21 10:19:10 2003
8586 @@ -357,6 +357,21 @@
8587  }
8588  
8589  /*
8590 + * Fix IDE interrupts.
8591 + */
8592 +static int __init
8593 +sandpoint_fix_winbond_83553(void)
8594 +{
8595 +       /* Make all 8259 interrupt level sensitive */
8596 +       outb(0xf8, 0x4d0);
8597 +       outb(0xde, 0x4d1);
8598 +
8599 +       return 0;
8600 +}
8601 +
8602 +arch_initcall(sandpoint_fix_winbond_83553);
8603 +
8604 +/*
8605   * Initialize the ISA devices on the Nat'l PC87308VUL SuperIO chip.
8606   */
8607  static int __init
8608 @@ -390,21 +405,6 @@
8609  }
8610  
8611  arch_initcall(sandpoint_setup_natl_87308);
8612 -
8613 -/*
8614 - * Fix IDE interrupts.
8615 - */
8616 -static int __init
8617 -sandpoint_fix_winbond_83553(void)
8618 -{
8619 -       /* Make all 8259 interrupt level sensitive */
8620 -       outb(0xf8, 0x4d0);
8621 -       outb(0xde, 0x4d1);
8622 -
8623 -       return 0;
8624 -}
8625 -
8626 -arch_initcall(sandpoint_fix_winbond_83553);
8627  
8628  static int __init
8629  sandpoint_request_io(void)
8630 diff -Nru a/arch/ppc/platforms/sandpoint.h b/arch/ppc/platforms/sandpoint.h
8631 --- a/arch/ppc/platforms/sandpoint.h    Tue Jul  1 10:56:46 2003
8632 +++ b/arch/ppc/platforms/sandpoint.h    Thu Aug 21 10:19:10 2003
8633 @@ -61,9 +61,9 @@
8634  #define UART_CLK                       1843200
8635  
8636  #ifdef CONFIG_SERIAL_DETECT_IRQ
8637 -#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST|ASYNC_AUTO_IRQ)
8638 +#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_AUTO_IRQ)
8639  #else
8640 -#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST)
8641 +#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF)
8642  #endif
8643  
8644  #define STD_SERIAL_PORT_DFNS \
8645 diff -Nru a/arch/ppc/syslib/of_device.c b/arch/ppc/syslib/of_device.c
8646 --- a/arch/ppc/syslib/of_device.c       Sat Aug 16 11:48:20 2003
8647 +++ b/arch/ppc/syslib/of_device.c       Tue Aug 26 06:35:38 2003
8648 @@ -15,8 +15,8 @@
8649   * Used by a driver to check whether an of_device present in the
8650   * system is in its list of supported devices. 
8651   */
8652 -const struct of_match *
8653 -of_match_device(const struct of_match *matches, const struct of_device *dev)
8654 +const struct of_match * of_match_device(const struct of_match *matches,
8655 +                                       const struct of_device *dev)
8656  {
8657         if (!dev->node)
8658                 return NULL;
8659 @@ -38,8 +38,7 @@
8660         return NULL;
8661  }
8662  
8663 -static int
8664 -of_platform_bus_match(struct device *dev, struct device_driver *drv) 
8665 +static int of_platform_bus_match(struct device *dev, struct device_driver *drv) 
8666  {
8667         struct of_device * of_dev = to_of_device(dev);
8668         struct of_platform_driver * of_drv = to_of_platform_driver(drv);
8669 @@ -51,21 +50,27 @@
8670         return of_match_device(matches, of_dev) != NULL;
8671  }
8672  
8673 -struct bus_type of_platform_bus_type = {
8674 -       name:   "of_platform",
8675 -       match:  of_platform_bus_match,
8676 -};
8677 +struct of_device *of_dev_get(struct of_device *dev)
8678 +{
8679 +       struct device *tmp;
8680 +
8681 +       if (!dev)
8682 +               return NULL;
8683 +       tmp = get_device(&dev->dev);
8684 +       if (tmp)
8685 +               return to_of_device(tmp);
8686 +       else
8687 +               return NULL;
8688 +}
8689  
8690 -static int __init
8691 -of_bus_driver_init(void)
8692 +void of_dev_put(struct of_device *dev)
8693  {
8694 -       return bus_register(&of_platform_bus_type);
8695 +       if (dev)
8696 +               put_device(&dev->dev);
8697  }
8698  
8699 -postcore_initcall(of_bus_driver_init);
8700  
8701 -static int
8702 -of_device_probe(struct device *dev)
8703 +static int of_device_probe(struct device *dev)
8704  {
8705         int error = -ENODEV;
8706         struct of_platform_driver *drv;
8707 @@ -78,22 +83,18 @@
8708         if (!drv->probe)
8709                 return error;
8710  
8711 -/*     if (!try_module_get(driver->owner)) {
8712 -               printk(KERN_ERR "Can't get a module reference for %s\n", driver->name);
8713 -               return error;
8714 -       }
8715 -*/
8716 +       of_dev_get(of_dev);
8717 +
8718         match = of_match_device(drv->match_table, of_dev);
8719         if (match)
8720                 error = drv->probe(of_dev, match);
8721 -/*
8722 -       module_put(driver->owner);
8723 -*/     
8724 +       if (error)
8725 +               of_dev_put(of_dev);
8726 +
8727         return error;
8728  }
8729  
8730 -static int
8731 -of_device_remove(struct device *dev)
8732 +static int of_device_remove(struct device *dev)
8733  {
8734         struct of_device * of_dev = to_of_device(dev);
8735         struct of_platform_driver * drv = to_of_platform_driver(of_dev->dev.driver);
8736 @@ -103,32 +104,43 @@
8737         return 0;
8738  }
8739  
8740 -static int
8741 -of_device_suspend(struct device *dev, u32 state, u32 level)
8742 +static int of_device_suspend(struct device *dev, u32 state)
8743  {
8744         struct of_device * of_dev = to_of_device(dev);
8745         struct of_platform_driver * drv = to_of_platform_driver(of_dev->dev.driver);
8746         int error = 0;
8747  
8748         if (drv && drv->suspend)
8749 -               error = drv->suspend(of_dev, state, level);
8750 +               error = drv->suspend(of_dev, state);
8751         return error;
8752  }
8753  
8754 -static int
8755 -of_device_resume(struct device * dev, u32 level)
8756 +static int of_device_resume(struct device * dev)
8757  {
8758         struct of_device * of_dev = to_of_device(dev);
8759         struct of_platform_driver * drv = to_of_platform_driver(of_dev->dev.driver);
8760         int error = 0;
8761  
8762         if (drv && drv->resume)
8763 -               error = drv->resume(of_dev, level);
8764 +               error = drv->resume(of_dev);
8765         return error;
8766  }
8767  
8768 -int
8769 -of_register_driver(struct of_platform_driver *drv)
8770 +struct bus_type of_platform_bus_type = {
8771 +       .name   = "of_platform",
8772 +       .match  = of_platform_bus_match,
8773 +       .suspend        = of_device_suspend,
8774 +       .resume = of_device_resume,
8775 +};
8776 +
8777 +static int __init of_bus_driver_init(void)
8778 +{
8779 +       return bus_register(&of_platform_bus_type);
8780 +}
8781 +
8782 +postcore_initcall(of_bus_driver_init);
8783 +
8784 +int of_register_driver(struct of_platform_driver *drv)
8785  {
8786         int count = 0;
8787  
8788 @@ -136,8 +148,6 @@
8789         drv->driver.name = drv->name;
8790         drv->driver.bus = &of_platform_bus_type;
8791         drv->driver.probe = of_device_probe;
8792 -       drv->driver.resume = of_device_resume;
8793 -       drv->driver.suspend = of_device_suspend;
8794         drv->driver.remove = of_device_remove;
8795  
8796         /* register with core */
8797 @@ -145,15 +155,13 @@
8798         return count ? count : 1;
8799  }
8800  
8801 -void
8802 -of_unregister_driver(struct of_platform_driver *drv)
8803 +void of_unregister_driver(struct of_platform_driver *drv)
8804  {
8805         driver_unregister(&drv->driver);
8806  }
8807  
8808  
8809 -static ssize_t
8810 -dev_show_devspec(struct device *dev, char *buf)
8811 +static ssize_t dev_show_devspec(struct device *dev, char *buf)
8812  {
8813         struct of_device *ofdev;
8814  
8815 @@ -163,8 +171,22 @@
8816  
8817  static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL);
8818  
8819 -int
8820 -of_device_register(struct of_device *ofdev)
8821 +/**
8822 + * of_release_dev - free an of device structure when all users of it are finished.
8823 + * @dev: device that's been disconnected
8824 + *
8825 + * Will be called only by the device core when all users of this of device are
8826 + * done.
8827 + */
8828 +void of_release_dev(struct device *dev)
8829 +{
8830 +       struct of_device *ofdev;
8831 +
8832 +        ofdev = to_of_device(dev);
8833 +       kfree(ofdev);
8834 +}
8835 +
8836 +int of_device_register(struct of_device *ofdev)
8837  {
8838         int rc;
8839         struct of_device **odprop;
8840 @@ -197,21 +219,20 @@
8841         return 0;
8842  }
8843  
8844 -void
8845 -of_device_unregister(struct of_device *ofdev)
8846 +void of_device_unregister(struct of_device *ofdev)
8847  {
8848         struct of_device **odprop;
8849  
8850         device_remove_file(&ofdev->dev, &dev_attr_devspec);
8851 -       device_unregister(&ofdev->dev);
8852  
8853         odprop = (struct of_device **)get_property(ofdev->node, "linux,device", NULL);
8854         if (odprop)
8855                 *odprop = NULL;
8856 +
8857 +       device_unregister(&ofdev->dev);
8858  }
8859  
8860 -struct of_device*
8861 -of_platform_device_create(struct device_node *np, const char *bus_id)
8862 +struct of_device* of_platform_device_create(struct device_node *np, const char *bus_id)
8863  {
8864         struct of_device *dev;
8865         u32 *reg;
8866 @@ -226,6 +247,7 @@
8867         dev->dev.dma_mask = &dev->dma_mask;
8868         dev->dev.parent = NULL;
8869         dev->dev.bus = &of_platform_bus_type;
8870 +       dev->dev.release = of_release_dev;
8871  
8872         reg = (u32 *)get_property(np, "reg", NULL);
8873         strlcpy(dev->dev.bus_id, bus_id, BUS_ID_SIZE);
8874 @@ -244,4 +266,7 @@
8875  EXPORT_SYMBOL(of_unregister_driver);
8876  EXPORT_SYMBOL(of_device_register);
8877  EXPORT_SYMBOL(of_device_unregister);
8878 +EXPORT_SYMBOL(of_dev_get);
8879 +EXPORT_SYMBOL(of_dev_put);
8880  EXPORT_SYMBOL(of_platform_device_create);
8881 +EXPORT_SYMBOL(of_release_dev);
8882 diff -Nru a/arch/ppc/syslib/open_pic.c b/arch/ppc/syslib/open_pic.c
8883 --- a/arch/ppc/syslib/open_pic.c        Tue Jul 15 10:01:29 2003
8884 +++ b/arch/ppc/syslib/open_pic.c        Sun Aug 24 04:11:21 2003
8885 @@ -15,6 +15,7 @@
8886  #include <linux/init.h>
8887  #include <linux/irq.h>
8888  #include <linux/interrupt.h>
8889 +#include <linux/sysdev.h>
8890  #include <asm/ptrace.h>
8891  #include <asm/signal.h>
8892  #include <asm/io.h>
8893 @@ -276,7 +277,7 @@
8894  }
8895  #endif
8896  
8897 -#if defined(CONFIG_EPIC_SERIAL_MODE) || defined(CONFIG_PMAC_PBOOK)
8898 +#if defined(CONFIG_EPIC_SERIAL_MODE) || defined(CONFIG_PM)
8899  static void openpic_reset(void)
8900  {
8901         openpic_setfield(&OpenPIC->Global.Global_Configuration0,
8902 @@ -532,7 +533,7 @@
8903         openpic_write(&OpenPIC->Global.Processor_Initialization, mask);
8904  }
8905  
8906 -#if defined(CONFIG_SMP) || defined(CONFIG_PMAC_PBOOK)
8907 +#if defined(CONFIG_SMP) || defined(CONFIG_PM)
8908  static spinlock_t openpic_setup_lock = SPIN_LOCK_UNLOCKED;
8909  #endif
8910  
8911 @@ -864,20 +865,55 @@
8912  }
8913  #endif /* CONFIG_SMP */
8914  
8915 -#ifdef CONFIG_PMAC_PBOOK
8916 +#ifdef CONFIG_PM
8917 +
8918 +/*
8919 + * We implement the IRQ controller as a sysdev and put it
8920 + * to sleep at powerdown stage (the callback is named suspend,
8921 + * but it's old semantics, for the Device Model, it's really
8922 + * powerdown). The possible problem is that another sysdev that
8923 + * happens to be suspend after this one will have interrupts off,
8924 + * that may be an issue... For now, this isn't an issue on pmac
8925 + * though...
8926 + */
8927 +
8928  static u32 save_ipi_vp[OPENPIC_NUM_IPI];
8929  static u32 save_irq_src_vp[OPENPIC_MAX_SOURCES];
8930  static u32 save_irq_src_dest[OPENPIC_MAX_SOURCES];
8931  static u32 save_cpu_task_pri[OPENPIC_MAX_PROCESSORS];
8932 +static int openpic_suspend_count;
8933 +
8934 +static void openpic_cached_enable_irq(u_int irq)
8935 +{
8936 +       check_arg_irq(irq);
8937 +       save_irq_src_vp[irq - open_pic_irq_offset] &= ~OPENPIC_MASK; 
8938 +}
8939  
8940 -void __pmac
8941 -openpic_sleep_save_intrs(void)
8942 +static void openpic_cached_disable_irq(u_int irq)
8943 +{
8944 +       check_arg_irq(irq);
8945 +       save_irq_src_vp[irq - open_pic_irq_offset] |= OPENPIC_MASK; 
8946 +}
8947 +
8948 +/* WARNING: Can be called directly by the cpufreq code with NULL parameter,
8949 + * we need something better to deal with that... Maybe switch to S1 for
8950 + * cpufreq changes
8951 + */
8952 +int openpic_suspend(struct sys_device *sysdev, u32 state)
8953  {
8954         int     i;
8955         unsigned long flags;
8956         
8957         spin_lock_irqsave(&openpic_setup_lock, flags);
8958  
8959 +       if (openpic_suspend_count++ > 0) {
8960 +               spin_unlock_irqrestore(&openpic_setup_lock, flags);
8961 +               return 0;
8962 +       }
8963 +
8964 +       open_pic.enable = openpic_cached_enable_irq;
8965 +       open_pic.disable = openpic_cached_disable_irq;
8966 +
8967         for (i=0; i<NumProcessors; i++) {
8968                 save_cpu_task_pri[i] = openpic_read(&OpenPIC->Processor[i].Current_Task_Priority);
8969                 openpic_writefield(&OpenPIC->Processor[i].Current_Task_Priority,
8970 @@ -889,38 +925,112 @@
8971         for (i=0; i<NumSources; i++) {
8972                 if (ISR[i] == 0)
8973                         continue;
8974 -               save_irq_src_vp[i] = openpic_read(&ISR[i]->Vector_Priority)
8975 -                       & ~OPENPIC_ACTIVITY;
8976 +               save_irq_src_vp[i] = openpic_read(&ISR[i]->Vector_Priority) & ~OPENPIC_ACTIVITY;
8977                 save_irq_src_dest[i] = openpic_read(&ISR[i]->Destination);
8978         }
8979 +
8980         spin_unlock_irqrestore(&openpic_setup_lock, flags);
8981 +
8982 +       return 0;
8983  }
8984  
8985 -void __pmac
8986 -openpic_sleep_restore_intrs(void)
8987 +/* WARNING: Can be called directly by the cpufreq code with NULL parameter,
8988 + * we need something better to deal with that... Maybe switch to S1 for
8989 + * cpufreq changes
8990 + */
8991 +int openpic_resume(struct sys_device *sysdev)
8992  {
8993         int             i;
8994         unsigned long   flags;
8995 +       u32             vppmask =       OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK |
8996 +                                       OPENPIC_SENSE_MASK | OPENPIC_POLARITY_MASK |
8997 +                                       OPENPIC_MASK;
8998  
8999         spin_lock_irqsave(&openpic_setup_lock, flags);
9000         
9001 +       if ((--openpic_suspend_count) > 0) {
9002 +               spin_unlock_irqrestore(&openpic_setup_lock, flags);
9003 +               return 0;
9004 +       }
9005 +
9006         openpic_reset();
9007  
9008 +       /* OpenPIC sometimes seem to need some time to be fully back up... */
9009 +       do {
9010 +               openpic_set_spurious(OPENPIC_VEC_SPURIOUS+open_pic_irq_offset);
9011 +       } while(openpic_readfield(&OpenPIC->Global.Spurious_Vector, OPENPIC_VECTOR_MASK)
9012 +                       != (OPENPIC_VEC_SPURIOUS + open_pic_irq_offset));
9013 +                       
9014 +       openpic_disable_8259_pass_through();
9015 +
9016         for (i=0; i<OPENPIC_NUM_IPI; i++)
9017                 openpic_write(&OpenPIC->Global.IPI_Vector_Priority(i),
9018                               save_ipi_vp[i]);
9019         for (i=0; i<NumSources; i++) {
9020                 if (ISR[i] == 0)
9021                         continue;
9022 -               openpic_write(&ISR[i]->Vector_Priority, save_irq_src_vp[i]);
9023                 openpic_write(&ISR[i]->Destination, save_irq_src_dest[i]);
9024 +               openpic_write(&ISR[i]->Vector_Priority, save_irq_src_vp[i]);
9025 +               /* make sure mask gets to controller before we return to user */
9026 +               do {
9027 +                       openpic_write(&ISR[i]->Vector_Priority, save_irq_src_vp[i]);
9028 +               } while (openpic_readfield(&ISR[i]->Vector_Priority, vppmask)
9029 +                        != (save_irq_src_vp[i] & vppmask));
9030         }
9031 -       openpic_set_spurious(OPENPIC_VEC_SPURIOUS+open_pic_irq_offset);
9032 -       openpic_disable_8259_pass_through();
9033         for (i=0; i<NumProcessors; i++)
9034                 openpic_write(&OpenPIC->Processor[i].Current_Task_Priority,
9035                               save_cpu_task_pri[i]);
9036  
9037 +       open_pic.enable = openpic_enable_irq;
9038 +       open_pic.disable = openpic_disable_irq;
9039 +
9040         spin_unlock_irqrestore(&openpic_setup_lock, flags);
9041 +
9042 +       return 0;
9043 +}
9044 +
9045 +#endif /* CONFIG_PM */
9046 +
9047 +static struct sysdev_class openpic_sysclass = {
9048 +       set_kset_name("openpic"),
9049 +};
9050 +
9051 +static struct sys_device device_openpic = {
9052 +       .id             = 0,
9053 +       .cls            = &openpic_sysclass,
9054 +};
9055 +
9056 +static struct sysdev_driver driver_openpic = {
9057 +#ifdef CONFIG_PM
9058 +       .suspend        = &openpic_suspend,
9059 +       .resume         = &openpic_resume,
9060 +#endif /* CONFIG_PM */ 
9061 +};
9062 +
9063 +static int __init init_openpic_sysfs(void)
9064 +{
9065 +       int rc;
9066 +
9067 +       if (!OpenPIC_Addr)
9068 +               return -ENODEV;
9069 +       printk(KERN_DEBUG "Registering openpic with sysfs...\n");
9070 +       rc = sysdev_class_register(&openpic_sysclass);
9071 +       if (rc) {
9072 +               printk(KERN_ERR "Failed registering openpic sys class\n");
9073 +               return -ENODEV;
9074 +       }
9075 +       rc = sys_device_register(&device_openpic);
9076 +       if (rc) {
9077 +               printk(KERN_ERR "Failed registering openpic sys device\n");
9078 +               return -ENODEV;
9079 +       }
9080 +       rc = sysdev_driver_register(&openpic_sysclass, &driver_openpic);
9081 +       if (rc) {
9082 +               printk(KERN_ERR "Failed registering openpic sys driver\n");
9083 +               return -ENODEV;
9084 +       }
9085 +       return 0;
9086  }
9087 -#endif /* CONFIG_PMAC_PBOOK */
9088 +
9089 +subsys_initcall(init_openpic_sysfs);
9090 +
9091 diff -Nru a/arch/ppc/syslib/prom.c b/arch/ppc/syslib/prom.c
9092 --- a/arch/ppc/syslib/prom.c    Sat Jun  7 02:18:01 2003
9093 +++ b/arch/ppc/syslib/prom.c    Sun Aug 24 03:57:52 2003
9094 @@ -941,6 +941,184 @@
9095         return NULL;
9096  }
9097  
9098 +/*******
9099 + *
9100 + * New implementation of the OF "find" APIs, return a refcounted
9101 + * object, call of_node_put() when done. Currently, still lacks
9102 + * locking as old implementation, this is beeing done for ppc64.
9103 + *
9104 + * Note that property management will need some locking as well,
9105 + * this isn't dealt with yet
9106 + *
9107 + *******/
9108 +
9109 +/**
9110 + *     of_find_node_by_name - Find a node by it's "name" property
9111 + *     @from:  The node to start searching from or NULL, the node
9112 + *             you pass will not be searched, only the next one
9113 + *             will; typically, you pass what the previous call
9114 + *             returned. of_node_put() will be called on it
9115 + *     @name:  The name string to match against
9116 + *
9117 + *     Returns a node pointer with refcount incremented, use
9118 + *     of_node_put() on it when done.
9119 + */ 
9120 +struct device_node *of_find_node_by_name(struct device_node *from,
9121 +       const char *name)
9122 +{
9123 +       struct device_node *np = from ? from->allnext : allnodes;
9124 +
9125 +       for (; np != 0; np = np->allnext)
9126 +               if (np->name != 0 && strcasecmp(np->name, name) == 0)
9127 +                       break;
9128 +       if (from)
9129 +               of_node_put(from);
9130 +       return of_node_get(np);
9131 +}
9132 +
9133 +/**
9134 + *     of_find_node_by_type - Find a node by it's "device_type" property
9135 + *     @from:  The node to start searching from or NULL, the node
9136 + *             you pass will not be searched, only the next one
9137 + *             will; typically, you pass what the previous call
9138 + *             returned. of_node_put() will be called on it
9139 + *     @name:  The type string to match against
9140 + *
9141 + *     Returns a node pointer with refcount incremented, use
9142 + *     of_node_put() on it when done.
9143 + */
9144 +struct device_node *of_find_node_by_type(struct device_node *from,
9145 +       const char *type)
9146 +{
9147 +       struct device_node *np = from ? from->allnext : allnodes;
9148 +
9149 +       for (; np != 0; np = np->allnext)
9150 +               if (np->type != 0 && strcasecmp(np->type, type) == 0)
9151 +                       break;
9152 +       if (from)
9153 +               of_node_put(from);
9154 +       return of_node_get(np);
9155 +}
9156 +
9157 +/**
9158 + *     of_find_compatible_node - Find a node based on type and one of the
9159 + *                                tokens in it's "compatible" property
9160 + *     @from:          The node to start searching from or NULL, the node
9161 + *                     you pass will not be searched, only the next one
9162 + *                     will; typically, you pass what the previous call
9163 + *                     returned. of_node_put() will be called on it
9164 + *     @type:          The type string to match "device_type" or NULL to ignore
9165 + *     @compatible:    The string to match to one of the tokens in the device
9166 + *                     "compatible" list.
9167 + *
9168 + *     Returns a node pointer with refcount incremented, use
9169 + *     of_node_put() on it when done.
9170 + */
9171 +struct device_node *of_find_compatible_node(struct device_node *from,
9172 +       const char *type, const char *compatible)
9173 +{
9174 +       struct device_node *np = from ? from->allnext : allnodes;
9175 +
9176 +       for (; np != 0; np = np->allnext) {
9177 +               if (type != NULL
9178 +                   && !(np->type != 0 && strcasecmp(np->type, type) == 0))
9179 +                       continue;
9180 +               if (device_is_compatible(np, compatible))
9181 +                       break;
9182 +       }
9183 +       if (from)
9184 +               of_node_put(from);
9185 +       return of_node_get(np);
9186 +}
9187 +
9188 +/**
9189 + *     of_find_node_by_path - Find a node matching a full OF path
9190 + *     @path:  The full path to match
9191 + *
9192 + *     Returns a node pointer with refcount incremented, use
9193 + *     of_node_put() on it when done.
9194 + */
9195 +struct device_node *of_find_node_by_path(const char *path)
9196 +{
9197 +       struct device_node *np = allnodes;
9198 +
9199 +       for (; np != 0; np = np->allnext)
9200 +               if (np->full_name != 0 && strcasecmp(np->full_name, path) == 0)
9201 +                       break;
9202 +       return of_node_get(np);
9203 +}
9204 +
9205 +/**
9206 + *     of_find_all_nodes - Get next node in global list
9207 + *     @prev:  Previous node or NULL to start iteration
9208 + *             of_node_put() will be called on it
9209 + *
9210 + *     Returns a node pointer with refcount incremented, use
9211 + *     of_node_put() on it when done.
9212 + */
9213 +struct device_node *of_find_all_nodes(struct device_node *prev)
9214 +{
9215 +       return of_node_get(prev ? prev->allnext : allnodes);
9216 +}
9217 +
9218 +/**
9219 + *     of_get_parent - Get a node's parent if any
9220 + *     @node:  Node to get parent
9221 + *
9222 + *     Returns a node pointer with refcount incremented, use
9223 + *     of_node_put() on it when done.
9224 + */
9225 +struct device_node *of_get_parent(const struct device_node *node)
9226 +{
9227 +       return node ? of_node_get(node->parent) : NULL;
9228 +}
9229 +
9230 +/**
9231 + *     of_get_next_child - Iterate a node childs
9232 + *     @node:  parent node
9233 + *     @prev:  previous child of the parent node, or NULL to get first
9234 + *
9235 + *     Returns a node pointer with refcount incremented, use
9236 + *     of_node_put() on it when done.
9237 + */
9238 +struct device_node *of_get_next_child(const struct device_node *node,
9239 +                                     struct device_node *prev)
9240 +{
9241 +       struct device_node *next = prev ? prev->sibling : node->child;
9242 +
9243 +       for (; next != 0; next = next->sibling)
9244 +               if (of_node_get(next))
9245 +                       break;
9246 +       if (prev)
9247 +               of_node_put(prev);
9248 +       return next;
9249 +}
9250 +
9251 +/**
9252 + *     of_node_get - Increment refcount of a node
9253 + *     @node:  Node to inc refcount, NULL is supported to
9254 + *             simplify writing of callers
9255 + *
9256 + *     Returns the node itself or NULL if gone. Current implementation
9257 + *     does nothing as we don't yet do dynamic node allocation on ppc32
9258 + */
9259 +struct device_node *of_node_get(struct device_node *node)
9260 +{
9261 +       return node;
9262 +}
9263 +
9264 +/**
9265 + *     of_node_put - Decrement refcount of a node
9266 + *     @node:  Node to dec refcount, NULL is supported to
9267 + *             simplify writing of callers
9268 + *
9269 + *     Current implementation does nothing as we don't yet do dynamic node
9270 + *     allocation on ppc32
9271 + */
9272 +void  of_node_put(struct device_node *node)
9273 +{    
9274 +}
9275 +
9276  /*
9277   * Find the device_node with a given phandle.
9278   */
9279 diff -Nru a/arch/ppc/xmon/start.c b/arch/ppc/xmon/start.c
9280 --- a/arch/ppc/xmon/start.c     Sat Jun  7 02:18:02 2003
9281 +++ b/arch/ppc/xmon/start.c     Sun Aug 24 07:39:33 2003
9282 @@ -225,14 +225,13 @@
9283  static int scc_initialized = 0;
9284  
9285  void xmon_init_scc(void);
9286 -extern void pmu_poll(void);
9287  extern void cuda_poll(void);
9288  
9289  static inline void do_poll_adb(void)
9290  {
9291  #ifdef CONFIG_ADB_PMU
9292         if (sys_ctrler == SYS_CTRLER_PMU)
9293 -               pmu_poll();
9294 +               pmu_poll_adb();
9295  #endif /* CONFIG_ADB_PMU */
9296  #ifdef CONFIG_ADB_CUDA
9297         if (sys_ctrler == SYS_CTRLER_CUDA)
9298 diff -Nru a/arch/ppc64/Kconfig b/arch/ppc64/Kconfig
9299 --- a/arch/ppc64/Kconfig        Mon Aug 18 19:46:23 2003
9300 +++ b/arch/ppc64/Kconfig        Sun Aug 31 16:14:22 2003
9301 @@ -175,22 +175,6 @@
9302         bool
9303         default PCI
9304  
9305 -# only elf supported, a.out is not -- Cort
9306 -config KCORE_ELF
9307 -       bool
9308 -       depends on PROC_FS
9309 -       default y
9310 -       help
9311 -         If you enabled support for /proc file system then the file
9312 -         /proc/kcore will contain the kernel core image in ELF format. This
9313 -         can be used in gdb:
9314 -
9315 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
9316 -
9317 -         This is especially useful if you have compiled the kernel with the
9318 -         "-g" option to preserve debugging information. It is mainly used
9319 -         for examining kernel data structures on the live kernel.
9320 -
9321  source "fs/Kconfig.binfmt"
9322  
9323  source "drivers/pci/Kconfig"
9324 diff -Nru a/arch/ppc64/kernel/ioctl32.c b/arch/ppc64/kernel/ioctl32.c
9325 --- a/arch/ppc64/kernel/ioctl32.c       Fri Aug  8 14:53:47 2003
9326 +++ b/arch/ppc64/kernel/ioctl32.c       Sun Aug 31 16:14:44 2003
9327 @@ -725,7 +725,7 @@
9328  #define IOCTL_TABLE_START \
9329         struct ioctl_trans ioctl_start[] = {
9330  #define IOCTL_TABLE_END \
9331 -       }; struct ioctl_trans ioctl_end[0];
9332 +       };
9333  
9334  IOCTL_TABLE_START
9335  #include <linux/compat_ioctl.h>
9336 @@ -763,3 +763,5 @@
9337  HANDLE_IOCTL(USBDEVFS_REAPURBNDELAY32, do_usbdevfs_reapurb)
9338  HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
9339  IOCTL_TABLE_END
9340 +
9341 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
9342 diff -Nru a/arch/ppc64/kernel/proc_ppc64.c b/arch/ppc64/kernel/proc_ppc64.c
9343 --- a/arch/ppc64/kernel/proc_ppc64.c    Tue Mar 25 20:30:59 2003
9344 +++ b/arch/ppc64/kernel/proc_ppc64.c    Sun Aug 31 16:14:08 2003
9345 @@ -47,9 +47,9 @@
9346  static int     page_map_mmap( struct file *file, struct vm_area_struct *vma );
9347  
9348  static struct file_operations page_map_fops = {
9349 -       llseek: page_map_seek,
9350 -       read:   page_map_read,
9351 -       mmap:   page_map_mmap
9352 +       .llseek = page_map_seek,
9353 +       .read   = page_map_read,
9354 +       .mmap   = page_map_mmap
9355  };
9356  
9357  
9358 diff -Nru a/arch/ppc64/kernel/scanlog.c b/arch/ppc64/kernel/scanlog.c
9359 --- a/arch/ppc64/kernel/scanlog.c       Thu Feb 13 00:47:26 2003
9360 +++ b/arch/ppc64/kernel/scanlog.c       Sun Aug 31 16:14:08 2003
9361 @@ -190,11 +190,11 @@
9362  }
9363  
9364  struct file_operations scanlog_fops = {
9365 -       owner:          THIS_MODULE,
9366 -       read:           scanlog_read,
9367 -       write:          scanlog_write,
9368 -       open:           scanlog_open,
9369 -       release:        scanlog_release,
9370 +       .owner          = THIS_MODULE,
9371 +       .read           = scanlog_read,
9372 +       .write          = scanlog_write,
9373 +       .open           = scanlog_open,
9374 +       .release        = scanlog_release,
9375  };
9376  
9377  int __init scanlog_init(void)
9378 diff -Nru a/arch/s390/Kconfig b/arch/s390/Kconfig
9379 --- a/arch/s390/Kconfig Mon Jul 21 13:25:16 2003
9380 +++ b/arch/s390/Kconfig Sun Aug 31 16:14:22 2003
9381 @@ -217,10 +217,6 @@
9382  
9383  endchoice
9384  
9385 -config KCORE_ELF
9386 -       bool
9387 -       default y
9388 -
9389  source "fs/Kconfig.binfmt"
9390  
9391  config PROCESS_DEBUG
9392 diff -Nru a/arch/s390/kernel/compat_ioctl.c b/arch/s390/kernel/compat_ioctl.c
9393 --- a/arch/s390/kernel/compat_ioctl.c   Tue May 27 12:34:41 2003
9394 +++ b/arch/s390/kernel/compat_ioctl.c   Sun Aug 31 16:14:44 2003
9395 @@ -808,7 +808,7 @@
9396  #define IOCTL_TABLE_START \
9397         struct ioctl_trans ioctl_start[] = {
9398  #define IOCTL_TABLE_END \
9399 -       }; struct ioctl_trans ioctl_end[0];
9400 +       };
9401  
9402  IOCTL_TABLE_START
9403  #include <linux/compat_ioctl.h>
9404 @@ -899,3 +899,5 @@
9405  HANDLE_IOCTL(BLKPG, blkpg_ioctl_trans)
9406  
9407  IOCTL_TABLE_END
9408 +
9409 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
9410 diff -Nru a/arch/sh/Kconfig b/arch/sh/Kconfig
9411 --- a/arch/sh/Kconfig   Sat Aug  2 14:26:16 2003
9412 +++ b/arch/sh/Kconfig   Sun Aug 31 16:14:22 2003
9413 @@ -729,40 +729,6 @@
9414  
9415  menu "Executable file formats"
9416  
9417 -choice
9418 -       prompt "Kernel core (/proc/kcore) format"
9419 -       depends on PROC_FS
9420 -       default KCORE_ELF
9421 -
9422 -config KCORE_ELF
9423 -       bool "ELF"
9424 -       ---help---
9425 -         If you enabled support for /proc file system then the file
9426 -         /proc/kcore will contain the kernel core image. This can be used
9427 -         in gdb:
9428 -
9429 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
9430 -
9431 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
9432 -         /proc/kcore appear in ELF core format as defined by the Executable
9433 -         and Linking Format specification. Selecting A.OUT will choose the
9434 -         old "a.out" format which may be necessary for some old versions
9435 -         of binutils or on some architectures.
9436 -
9437 -         This is especially useful if you have compiled the kernel with the
9438 -         "-g" option to preserve debugging information. It is mainly used
9439 -         for examining kernel data structures on the live kernel so if you
9440 -         don't understand what this means or are not a kernel hacker, just
9441 -         leave it at its default value ELF.
9442 -
9443 -config KCORE_AOUT
9444 -       bool "A.OUT"
9445 -       help
9446 -         Not necessary unless you're using a very out-of-date binutils
9447 -         version.  You probably want KCORE_ELF.
9448 -
9449 -endchoice
9450 -
9451  source "fs/Kconfig.binfmt"
9452  
9453  endmenu
9454 diff -Nru a/arch/sh/boards/adx/mach.c b/arch/sh/boards/adx/mach.c
9455 --- a/arch/sh/boards/adx/mach.c Mon May 19 16:04:36 2003
9456 +++ b/arch/sh/boards/adx/mach.c Sun Aug 31 16:14:08 2003
9457 @@ -24,41 +24,41 @@
9458   */
9459  
9460  struct sh_machine_vector mv_adx __initmv = {
9461 -       mv_nr_irqs:             48,
9462 +       .mv_nr_irqs             = 48,
9463  
9464 -       mv_inb:                 adx_inb,
9465 -       mv_inw:                 adx_inw,
9466 -       mv_inl:                 adx_inl,
9467 -       mv_outb:                adx_outb,
9468 -       mv_outw:                adx_outw,
9469 -       mv_outl:                adx_outl,
9470 -
9471 -       mv_inb_p:               adx_inb_p,
9472 -       mv_inw_p:               adx_inw,
9473 -       mv_inl_p:               adx_inl,
9474 -       mv_outb_p:              adx_outb_p,
9475 -       mv_outw_p:              adx_outw,
9476 -       mv_outl_p:              adx_outl,
9477 -
9478 -       mv_insb:                adx_insb,
9479 -       mv_insw:                adx_insw,
9480 -       mv_insl:                adx_insl,
9481 -       mv_outsb:               adx_outsb,
9482 -       mv_outsw:               adx_outsw,
9483 -       mv_outsl:               adx_outsl,
9484 -
9485 -       mv_readb:               adx_readb,
9486 -       mv_readw:               adx_readw,
9487 -       mv_readl:               adx_readl,
9488 -       mv_writeb:              adx_writeb,
9489 -       mv_writew:              adx_writew,
9490 -       mv_writel:              adx_writel,
9491 +       .mv_inb                 = adx_inb,
9492 +       .mv_inw                 = adx_inw,
9493 +       .mv_inl                 = adx_inl,
9494 +       .mv_outb                = adx_outb,
9495 +       .mv_outw                = adx_outw,
9496 +       .mv_outl                = adx_outl,
9497 +
9498 +       .mv_inb_p               = adx_inb_p,
9499 +       .mv_inw_p               = adx_inw,
9500 +       .mv_inl_p               = adx_inl,
9501 +       .mv_outb_p              = adx_outb_p,
9502 +       .mv_outw_p              = adx_outw,
9503 +       .mv_outl_p              = adx_outl,
9504 +
9505 +       .mv_insb                = adx_insb,
9506 +       .mv_insw                = adx_insw,
9507 +       .mv_insl                = adx_insl,
9508 +       .mv_outsb               = adx_outsb,
9509 +       .mv_outsw               = adx_outsw,
9510 +       .mv_outsl               = adx_outsl,
9511 +
9512 +       .mv_readb               = adx_readb,
9513 +       .mv_readw               = adx_readw,
9514 +       .mv_readl               = adx_readl,
9515 +       .mv_writeb              = adx_writeb,
9516 +       .mv_writew              = adx_writew,
9517 +       .mv_writel              = adx_writel,
9518  
9519 -       mv_ioremap:             adx_ioremap,
9520 -       mv_iounmap:             adx_iounmap,
9521 +       .mv_ioremap             = adx_ioremap,
9522 +       .mv_iounmap             = adx_iounmap,
9523  
9524 -       mv_isa_port2addr:       adx_isa_port2addr,
9525 +       .mv_isa_port2addr       = adx_isa_port2addr,
9526  
9527 -       mv_init_irq:            init_adx_IRQ,
9528 +       .mv_init_irq            = init_adx_IRQ,
9529  };
9530  ALIAS_MV(adx)
9531 diff -Nru a/arch/sh/boards/bigsur/mach.c b/arch/sh/boards/bigsur/mach.c
9532 --- a/arch/sh/boards/bigsur/mach.c      Sat Mar  2 08:57:07 2002
9533 +++ b/arch/sh/boards/bigsur/mach.c      Sun Aug 31 16:14:08 2003
9534 @@ -28,44 +28,44 @@
9535  extern void init_bigsur_IRQ(void);
9536  
9537  struct sh_machine_vector mv_bigsur __initmv = {
9538 -       mv_nr_irqs:             NR_IRQS,     // Defined in <asm/irq.h>
9539 -       mv_inb:                 bigsur_inb,
9540 -       mv_inw:                 bigsur_inw,
9541 -       mv_inl:                 bigsur_inl,
9542 -       mv_outb:                bigsur_outb,
9543 -       mv_outw:                bigsur_outw,
9544 -       mv_outl:                bigsur_outl,
9545 -
9546 -       mv_inb_p:               bigsur_inb_p,
9547 -       mv_inw_p:               bigsur_inw,
9548 -       mv_inl_p:               bigsur_inl,
9549 -       mv_outb_p:              bigsur_outb_p,
9550 -       mv_outw_p:              bigsur_outw,
9551 -       mv_outl_p:              bigsur_outl,
9552 -
9553 -       mv_insb:                bigsur_insb,
9554 -       mv_insw:                bigsur_insw,
9555 -       mv_insl:                bigsur_insl,
9556 -       mv_outsb:               bigsur_outsb,
9557 -       mv_outsw:               bigsur_outsw,
9558 -       mv_outsl:               bigsur_outsl,
9559 -
9560 -       mv_readb:               generic_readb,
9561 -       mv_readw:               generic_readw,
9562 -       mv_readl:               generic_readl,
9563 -       mv_writeb:              generic_writeb,
9564 -       mv_writew:              generic_writew,
9565 -       mv_writel:              generic_writel,
9566 +       .mv_nr_irqs             = NR_IRQS,     // Defined in <asm/irq.h>
9567 +       .mv_inb                 = bigsur_inb,
9568 +       .mv_inw                 = bigsur_inw,
9569 +       .mv_inl                 = bigsur_inl,
9570 +       .mv_outb                = bigsur_outb,
9571 +       .mv_outw                = bigsur_outw,
9572 +       .mv_outl                = bigsur_outl,
9573 +
9574 +       .mv_inb_p               = bigsur_inb_p,
9575 +       .mv_inw_p               = bigsur_inw,
9576 +       .mv_inl_p               = bigsur_inl,
9577 +       .mv_outb_p              = bigsur_outb_p,
9578 +       .mv_outw_p              = bigsur_outw,
9579 +       .mv_outl_p              = bigsur_outl,
9580 +
9581 +       .mv_insb                = bigsur_insb,
9582 +       .mv_insw                = bigsur_insw,
9583 +       .mv_insl                = bigsur_insl,
9584 +       .mv_outsb               = bigsur_outsb,
9585 +       .mv_outsw               = bigsur_outsw,
9586 +       .mv_outsl               = bigsur_outsl,
9587 +
9588 +       .mv_readb               = generic_readb,
9589 +       .mv_readw               = generic_readw,
9590 +       .mv_readl               = generic_readl,
9591 +       .mv_writeb              = generic_writeb,
9592 +       .mv_writew              = generic_writew,
9593 +       .mv_writel              = generic_writel,
9594  
9595 -       mv_ioremap:             generic_ioremap,
9596 -       mv_iounmap:             generic_iounmap,
9597 +       .mv_ioremap             = generic_ioremap,
9598 +       .mv_iounmap             = generic_iounmap,
9599  
9600 -       mv_isa_port2addr:       bigsur_isa_port2addr,
9601 -       mv_irq_demux:       bigsur_irq_demux,
9602 +       .mv_isa_port2addr       = bigsur_isa_port2addr,
9603 +       .mv_irq_demux       = bigsur_irq_demux,
9604  
9605 -       mv_init_irq:            init_bigsur_IRQ,
9606 +       .mv_init_irq            = init_bigsur_IRQ,
9607  #ifdef CONFIG_HEARTBEAT
9608 -       mv_heartbeat:           heartbeat_bigsur,
9609 +       .mv_heartbeat           = heartbeat_bigsur,
9610  #endif
9611  
9612  };
9613 diff -Nru a/arch/sh/boards/cat68701/mach.c b/arch/sh/boards/cat68701/mach.c
9614 --- a/arch/sh/boards/cat68701/mach.c    Sat Mar  2 08:57:07 2002
9615 +++ b/arch/sh/boards/cat68701/mach.c    Sun Aug 31 16:14:08 2003
9616 @@ -23,44 +23,44 @@
9617   */
9618  
9619  struct sh_machine_vector mv_cat68701 __initmv = {
9620 -       mv_nr_irqs:             32,
9621 -       mv_inb:                 cat68701_inb,
9622 -       mv_inw:                 cat68701_inw,
9623 -       mv_inl:                 cat68701_inl,
9624 -       mv_outb:                cat68701_outb,
9625 -       mv_outw:                cat68701_outw,
9626 -       mv_outl:                cat68701_outl,
9627 -
9628 -       mv_inb_p:               cat68701_inb_p,
9629 -       mv_inw_p:               cat68701_inw,
9630 -       mv_inl_p:               cat68701_inl,
9631 -       mv_outb_p:              cat68701_outb_p,
9632 -       mv_outw_p:              cat68701_outw,
9633 -       mv_outl_p:              cat68701_outl,
9634 -
9635 -       mv_insb:                cat68701_insb,
9636 -       mv_insw:                cat68701_insw,
9637 -       mv_insl:                cat68701_insl,
9638 -       mv_outsb:               cat68701_outsb,
9639 -       mv_outsw:               cat68701_outsw,
9640 -       mv_outsl:               cat68701_outsl,
9641 -
9642 -       mv_readb:               cat68701_readb,
9643 -       mv_readw:               cat68701_readw,
9644 -       mv_readl:               cat68701_readl,
9645 -       mv_writeb:              cat68701_writeb,
9646 -       mv_writew:              cat68701_writew,
9647 -       mv_writel:              cat68701_writel,
9648 +       .mv_nr_irqs             = 32,
9649 +       .mv_inb                 = cat68701_inb,
9650 +       .mv_inw                 = cat68701_inw,
9651 +       .mv_inl                 = cat68701_inl,
9652 +       .mv_outb                = cat68701_outb,
9653 +       .mv_outw                = cat68701_outw,
9654 +       .mv_outl                = cat68701_outl,
9655 +
9656 +       .mv_inb_p               = cat68701_inb_p,
9657 +       .mv_inw_p               = cat68701_inw,
9658 +       .mv_inl_p               = cat68701_inl,
9659 +       .mv_outb_p              = cat68701_outb_p,
9660 +       .mv_outw_p              = cat68701_outw,
9661 +       .mv_outl_p              = cat68701_outl,
9662 +
9663 +       .mv_insb                = cat68701_insb,
9664 +       .mv_insw                = cat68701_insw,
9665 +       .mv_insl                = cat68701_insl,
9666 +       .mv_outsb               = cat68701_outsb,
9667 +       .mv_outsw               = cat68701_outsw,
9668 +       .mv_outsl               = cat68701_outsl,
9669 +
9670 +       .mv_readb               = cat68701_readb,
9671 +       .mv_readw               = cat68701_readw,
9672 +       .mv_readl               = cat68701_readl,
9673 +       .mv_writeb              = cat68701_writeb,
9674 +       .mv_writew              = cat68701_writew,
9675 +       .mv_writel              = cat68701_writel,
9676  
9677 -       mv_ioremap:             cat68701_ioremap,
9678 -       mv_iounmap:             cat68701_iounmap,
9679 +       .mv_ioremap             = cat68701_ioremap,
9680 +       .mv_iounmap             = cat68701_iounmap,
9681  
9682 -       mv_isa_port2addr:       cat68701_isa_port2addr,
9683 -       mv_irq_demux:           cat68701_irq_demux,
9684 +       .mv_isa_port2addr       = cat68701_isa_port2addr,
9685 +       .mv_irq_demux           = cat68701_irq_demux,
9686  
9687 -       mv_init_irq:            init_cat68701_IRQ,
9688 +       .mv_init_irq            = init_cat68701_IRQ,
9689  #ifdef CONFIG_HEARTBEAT
9690 -       mv_heartbeat:           heartbeat_cat68701,
9691 +       .mv_heartbeat           = heartbeat_cat68701,
9692  #endif
9693  };
9694  ALIAS_MV(cat68701)
9695 diff -Nru a/arch/sh/boards/cqreek/mach.c b/arch/sh/boards/cqreek/mach.c
9696 --- a/arch/sh/boards/cqreek/mach.c      Sat Jun 14 11:02:09 2003
9697 +++ b/arch/sh/boards/cqreek/mach.c      Sun Aug 31 16:14:08 2003
9698 @@ -21,46 +21,46 @@
9699  
9700  struct sh_machine_vector mv_cqreek __initmv = {
9701  #if defined(CONFIG_CPU_SH4)
9702 -       mv_nr_irqs:             48,
9703 +       .mv_nr_irqs             = 48,
9704  #elif defined(CONFIG_CPU_SUBTYPE_SH7708)
9705 -       mv_nr_irqs:             32,
9706 +       .mv_nr_irqs             = 32,
9707  #elif defined(CONFIG_CPU_SUBTYPE_SH7709)
9708 -       mv_nr_irqs:             61,
9709 +       .mv_nr_irqs             = 61,
9710  #endif
9711  
9712 -       mv_inb:                 generic_inb,
9713 -       mv_inw:                 generic_inw,
9714 -       mv_inl:                 generic_inl,
9715 -       mv_outb:                generic_outb,
9716 -       mv_outw:                generic_outw,
9717 -       mv_outl:                generic_outl,
9718 -
9719 -       mv_inb_p:               generic_inb_p,
9720 -       mv_inw_p:               generic_inw_p,
9721 -       mv_inl_p:               generic_inl_p,
9722 -       mv_outb_p:              generic_outb_p,
9723 -       mv_outw_p:              generic_outw_p,
9724 -       mv_outl_p:              generic_outl_p,
9725 -
9726 -       mv_insb:                generic_insb,
9727 -       mv_insw:                generic_insw,
9728 -       mv_insl:                generic_insl,
9729 -       mv_outsb:               generic_outsb,
9730 -       mv_outsw:               generic_outsw,
9731 -       mv_outsl:               generic_outsl,
9732 -
9733 -       mv_readb:               generic_readb,
9734 -       mv_readw:               generic_readw,
9735 -       mv_readl:               generic_readl,
9736 -       mv_writeb:              generic_writeb,
9737 -       mv_writew:              generic_writew,
9738 -       mv_writel:              generic_writel,
9739 +       .mv_inb                 = generic_inb,
9740 +       .mv_inw                 = generic_inw,
9741 +       .mv_inl                 = generic_inl,
9742 +       .mv_outb                = generic_outb,
9743 +       .mv_outw                = generic_outw,
9744 +       .mv_outl                = generic_outl,
9745 +
9746 +       .mv_inb_p               = generic_inb_p,
9747 +       .mv_inw_p               = generic_inw_p,
9748 +       .mv_inl_p               = generic_inl_p,
9749 +       .mv_outb_p              = generic_outb_p,
9750 +       .mv_outw_p              = generic_outw_p,
9751 +       .mv_outl_p              = generic_outl_p,
9752 +
9753 +       .mv_insb                = generic_insb,
9754 +       .mv_insw                = generic_insw,
9755 +       .mv_insl                = generic_insl,
9756 +       .mv_outsb               = generic_outsb,
9757 +       .mv_outsw               = generic_outsw,
9758 +       .mv_outsl               = generic_outsl,
9759 +
9760 +       .mv_readb               = generic_readb,
9761 +       .mv_readw               = generic_readw,
9762 +       .mv_readl               = generic_readl,
9763 +       .mv_writeb              = generic_writeb,
9764 +       .mv_writew              = generic_writew,
9765 +       .mv_writel              = generic_writel,
9766  
9767 -       mv_init_irq:            init_cqreek_IRQ,
9768 +       .mv_init_irq            = init_cqreek_IRQ,
9769  
9770 -       mv_isa_port2addr:       cqreek_port2addr,
9771 +       .mv_isa_port2addr       = cqreek_port2addr,
9772  
9773 -       mv_ioremap:             generic_ioremap,
9774 -       mv_iounmap:             generic_iounmap,
9775 +       .mv_ioremap             = generic_ioremap,
9776 +       .mv_iounmap             = generic_iounmap,
9777  };
9778  ALIAS_MV(cqreek)
9779 diff -Nru a/arch/sh/boards/dmida/mach.c b/arch/sh/boards/dmida/mach.c
9780 --- a/arch/sh/boards/dmida/mach.c       Mon May 19 16:04:36 2003
9781 +++ b/arch/sh/boards/dmida/mach.c       Sun Aug 31 16:14:08 2003
9782 @@ -30,42 +30,42 @@
9783   */
9784  
9785  struct sh_machine_vector mv_dmida __initmv = {
9786 -       mv_name:                "DMIDA",
9787 +       .mv_name                = "DMIDA",
9788  
9789 -       mv_nr_irqs:             HD64465_IRQ_BASE+HD64465_IRQ_NUM,
9790 +       .mv_nr_irqs             = HD64465_IRQ_BASE+HD64465_IRQ_NUM,
9791  
9792 -       mv_inb:                 hd64465_inb,
9793 -       mv_inw:                 hd64465_inw,
9794 -       mv_inl:                 hd64465_inl,
9795 -       mv_outb:                hd64465_outb,
9796 -       mv_outw:                hd64465_outw,
9797 -       mv_outl:                hd64465_outl,
9798 -
9799 -       mv_inb_p:               hd64465_inb_p,
9800 -       mv_inw_p:               hd64465_inw,
9801 -       mv_inl_p:               hd64465_inl,
9802 -       mv_outb_p:              hd64465_outb_p,
9803 -       mv_outw_p:              hd64465_outw,
9804 -       mv_outl_p:              hd64465_outl,
9805 -
9806 -       mv_insb:                hd64465_insb,
9807 -       mv_insw:                hd64465_insw,
9808 -       mv_insl:                hd64465_insl,
9809 -       mv_outsb:               hd64465_outsb,
9810 -       mv_outsw:               hd64465_outsw,
9811 -       mv_outsl:               hd64465_outsl,
9812 -
9813 -       mv_readb:               generic_readb,
9814 -       mv_readw:               generic_readw,
9815 -       mv_readl:               generic_readl,
9816 -       mv_writeb:              generic_writeb,
9817 -       mv_writew:              generic_writew,
9818 -       mv_writel:              generic_writel,
9819 +       .mv_inb                 = hd64465_inb,
9820 +       .mv_inw                 = hd64465_inw,
9821 +       .mv_inl                 = hd64465_inl,
9822 +       .mv_outb                = hd64465_outb,
9823 +       .mv_outw                = hd64465_outw,
9824 +       .mv_outl                = hd64465_outl,
9825 +
9826 +       .mv_inb_p               = hd64465_inb_p,
9827 +       .mv_inw_p               = hd64465_inw,
9828 +       .mv_inl_p               = hd64465_inl,
9829 +       .mv_outb_p              = hd64465_outb_p,
9830 +       .mv_outw_p              = hd64465_outw,
9831 +       .mv_outl_p              = hd64465_outl,
9832 +
9833 +       .mv_insb                = hd64465_insb,
9834 +       .mv_insw                = hd64465_insw,
9835 +       .mv_insl                = hd64465_insl,
9836 +       .mv_outsb               = hd64465_outsb,
9837 +       .mv_outsw               = hd64465_outsw,
9838 +       .mv_outsl               = hd64465_outsl,
9839 +
9840 +       .mv_readb               = generic_readb,
9841 +       .mv_readw               = generic_readw,
9842 +       .mv_readl               = generic_readl,
9843 +       .mv_writeb              = generic_writeb,
9844 +       .mv_writew              = generic_writew,
9845 +       .mv_writel              = generic_writel,
9846  
9847 -       mv_irq_demux:           hd64465_irq_demux,
9848 +       .mv_irq_demux           = hd64465_irq_demux,
9849  
9850 -       mv_rtc_gettimeofday:    sh_rtc_gettimeofday,
9851 -       mv_rtc_settimeofday:    sh_rtc_settimeofday,
9852 +       .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
9853 +       .mv_rtc_settimeofday    = sh_rtc_settimeofday,
9854  };
9855  ALIAS_MV(dmida)
9856  
9857 diff -Nru a/arch/sh/boards/dreamcast/irq.c b/arch/sh/boards/dreamcast/irq.c
9858 --- a/arch/sh/boards/dreamcast/irq.c    Sat Jun 14 11:02:09 2003
9859 +++ b/arch/sh/boards/dreamcast/irq.c    Sun Aug 31 16:14:08 2003
9860 @@ -110,13 +110,13 @@
9861  }
9862  
9863  struct hw_interrupt_type systemasic_int = {
9864 -        typename:       "System ASIC",
9865 -        startup:        startup_systemasic_irq,
9866 -        shutdown:       shutdown_systemasic_irq,
9867 -        enable:         enable_systemasic_irq,
9868 -        disable:        disable_systemasic_irq,
9869 -        ack:            ack_systemasic_irq,
9870 -        end:            end_systemasic_irq,
9871 +        .typename       = "System ASIC",
9872 +        .startup        = startup_systemasic_irq,
9873 +        .shutdown       = shutdown_systemasic_irq,
9874 +        .enable         = enable_systemasic_irq,
9875 +        .disable        = disable_systemasic_irq,
9876 +        .ack            = ack_systemasic_irq,
9877 +        .end            = end_systemasic_irq,
9878  };
9879  
9880  /*
9881 diff -Nru a/arch/sh/boards/dreamcast/mach.c b/arch/sh/boards/dreamcast/mach.c
9882 --- a/arch/sh/boards/dreamcast/mach.c   Mon May 19 16:04:36 2003
9883 +++ b/arch/sh/boards/dreamcast/mach.c   Sun Aug 31 16:14:08 2003
9884 @@ -21,40 +21,40 @@
9885   */
9886  
9887  struct sh_machine_vector mv_dreamcast __initmv = {
9888 -       mv_nr_irqs:             NR_IRQS,
9889 +       .mv_nr_irqs             = NR_IRQS,
9890  
9891 -       mv_inb:                 generic_inb,
9892 -       mv_inw:                 generic_inw,
9893 -       mv_inl:                 generic_inl,
9894 -       mv_outb:                generic_outb,
9895 -       mv_outw:                generic_outw,
9896 -       mv_outl:                generic_outl,
9897 -
9898 -       mv_inb_p:               generic_inb_p,
9899 -       mv_inw_p:               generic_inw,
9900 -       mv_inl_p:               generic_inl,
9901 -       mv_outb_p:              generic_outb_p,
9902 -       mv_outw_p:              generic_outw,
9903 -       mv_outl_p:              generic_outl,
9904 -
9905 -       mv_insb:                generic_insb,
9906 -       mv_insw:                generic_insw,
9907 -       mv_insl:                generic_insl,
9908 -       mv_outsb:               generic_outsb,
9909 -       mv_outsw:               generic_outsw,
9910 -       mv_outsl:               generic_outsl,
9911 -
9912 -       mv_readb:               generic_readb,
9913 -       mv_readw:               generic_readw,
9914 -       mv_readl:               generic_readl,
9915 -       mv_writeb:              generic_writeb,
9916 -       mv_writew:              generic_writew,
9917 -       mv_writel:              generic_writel,
9918 +       .mv_inb                 = generic_inb,
9919 +       .mv_inw                 = generic_inw,
9920 +       .mv_inl                 = generic_inl,
9921 +       .mv_outb                = generic_outb,
9922 +       .mv_outw                = generic_outw,
9923 +       .mv_outl                = generic_outl,
9924 +
9925 +       .mv_inb_p               = generic_inb_p,
9926 +       .mv_inw_p               = generic_inw,
9927 +       .mv_inl_p               = generic_inl,
9928 +       .mv_outb_p              = generic_outb_p,
9929 +       .mv_outw_p              = generic_outw,
9930 +       .mv_outl_p              = generic_outl,
9931 +
9932 +       .mv_insb                = generic_insb,
9933 +       .mv_insw                = generic_insw,
9934 +       .mv_insl                = generic_insl,
9935 +       .mv_outsb               = generic_outsb,
9936 +       .mv_outsw               = generic_outsw,
9937 +       .mv_outsl               = generic_outsl,
9938 +
9939 +       .mv_readb               = generic_readb,
9940 +       .mv_readw               = generic_readw,
9941 +       .mv_readl               = generic_readl,
9942 +       .mv_writeb              = generic_writeb,
9943 +       .mv_writew              = generic_writew,
9944 +       .mv_writel              = generic_writel,
9945  
9946 -       mv_ioremap:             generic_ioremap,
9947 -       mv_iounmap:             generic_iounmap,
9948 +       .mv_ioremap             = generic_ioremap,
9949 +       .mv_iounmap             = generic_iounmap,
9950  
9951 -       mv_isa_port2addr:       dreamcast_isa_port2addr,
9952 -       mv_irq_demux:           systemasic_irq_demux,
9953 +       .mv_isa_port2addr       = dreamcast_isa_port2addr,
9954 +       .mv_irq_demux           = systemasic_irq_demux,
9955  };
9956  ALIAS_MV(dreamcast)
9957 diff -Nru a/arch/sh/boards/ec3104/irq.c b/arch/sh/boards/ec3104/irq.c
9958 --- a/arch/sh/boards/ec3104/irq.c       Sat Jun 14 11:02:09 2003
9959 +++ b/arch/sh/boards/ec3104/irq.c       Sun Aug 31 16:14:08 2003
9960 @@ -169,13 +169,13 @@
9961  }
9962  
9963  static struct hw_interrupt_type ec3104_int = {
9964 -        typename:       "EC3104",
9965 -        enable:         enable_ec3104_irq,
9966 -        disable:        disable_ec3104_irq,
9967 -        ack:            mask_and_ack_ec3104_irq,
9968 -        end:            end_ec3104_irq,
9969 -        startup:        startup_ec3104_irq,
9970 -        shutdown:       shutdown_ec3104_irq,
9971 +        .typename       = "EC3104",
9972 +        .enable         = enable_ec3104_irq,
9973 +        .disable        = disable_ec3104_irq,
9974 +        .ack            = mask_and_ack_ec3104_irq,
9975 +        .end            = end_ec3104_irq,
9976 +        .startup        = startup_ec3104_irq,
9977 +        .shutdown       = shutdown_ec3104_irq,
9978  };
9979  
9980  /* Yuck.  the _demux API is ugly */
9981 diff -Nru a/arch/sh/boards/ec3104/mach.c b/arch/sh/boards/ec3104/mach.c
9982 --- a/arch/sh/boards/ec3104/mach.c      Sat Jan 19 10:54:19 2002
9983 +++ b/arch/sh/boards/ec3104/mach.c      Sun Aug 31 16:14:08 2003
9984 @@ -28,42 +28,42 @@
9985   */
9986  
9987  struct sh_machine_vector mv_ec3104 __initmv = {
9988 -       mv_name:                "EC3104",
9989 +       .mv_name                = "EC3104",
9990  
9991 -       mv_nr_irqs:             96,
9992 +       .mv_nr_irqs             = 96,
9993  
9994 -       mv_inb:                 ec3104_inb,
9995 -       mv_inw:                 ec3104_inw,
9996 -       mv_inl:                 ec3104_inl,
9997 -       mv_outb:                ec3104_outb,
9998 -       mv_outw:                ec3104_outw,
9999 -       mv_outl:                ec3104_outl,
10000 -
10001 -       mv_inb_p:               generic_inb_p,
10002 -       mv_inw_p:               generic_inw,
10003 -       mv_inl_p:               generic_inl,
10004 -       mv_outb_p:              generic_outb_p,
10005 -       mv_outw_p:              generic_outw,
10006 -       mv_outl_p:              generic_outl,
10007 -
10008 -       mv_insb:                generic_insb,
10009 -       mv_insw:                generic_insw,
10010 -       mv_insl:                generic_insl,
10011 -       mv_outsb:               generic_outsb,
10012 -       mv_outsw:               generic_outsw,
10013 -       mv_outsl:               generic_outsl,
10014 -
10015 -       mv_readb:               generic_readb,
10016 -       mv_readw:               generic_readw,
10017 -       mv_readl:               generic_readl,
10018 -       mv_writeb:              generic_writeb,
10019 -       mv_writew:              generic_writew,
10020 -       mv_writel:              generic_writel,
10021 +       .mv_inb                 = ec3104_inb,
10022 +       .mv_inw                 = ec3104_inw,
10023 +       .mv_inl                 = ec3104_inl,
10024 +       .mv_outb                = ec3104_outb,
10025 +       .mv_outw                = ec3104_outw,
10026 +       .mv_outl                = ec3104_outl,
10027 +
10028 +       .mv_inb_p               = generic_inb_p,
10029 +       .mv_inw_p               = generic_inw,
10030 +       .mv_inl_p               = generic_inl,
10031 +       .mv_outb_p              = generic_outb_p,
10032 +       .mv_outw_p              = generic_outw,
10033 +       .mv_outl_p              = generic_outl,
10034 +
10035 +       .mv_insb                = generic_insb,
10036 +       .mv_insw                = generic_insw,
10037 +       .mv_insl                = generic_insl,
10038 +       .mv_outsb               = generic_outsb,
10039 +       .mv_outsw               = generic_outsw,
10040 +       .mv_outsl               = generic_outsl,
10041 +
10042 +       .mv_readb               = generic_readb,
10043 +       .mv_readw               = generic_readw,
10044 +       .mv_readl               = generic_readl,
10045 +       .mv_writeb              = generic_writeb,
10046 +       .mv_writew              = generic_writew,
10047 +       .mv_writel              = generic_writel,
10048  
10049 -       mv_irq_demux:           ec3104_irq_demux,
10050 +       .mv_irq_demux           = ec3104_irq_demux,
10051  
10052 -       mv_rtc_gettimeofday:    sh_rtc_gettimeofday,
10053 -       mv_rtc_settimeofday:    sh_rtc_settimeofday,
10054 +       .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
10055 +       .mv_rtc_settimeofday    = sh_rtc_settimeofday,
10056  };
10057  
10058  ALIAS_MV(ec3104)
10059 diff -Nru a/arch/sh/boards/harp/mach.c b/arch/sh/boards/harp/mach.c
10060 --- a/arch/sh/boards/harp/mach.c        Sat Mar  2 08:57:07 2002
10061 +++ b/arch/sh/boards/harp/mach.c        Sun Aug 31 16:14:08 2003
10062 @@ -26,46 +26,46 @@
10063   */
10064  
10065  struct sh_machine_vector mv_harp __initmv = {
10066 -       mv_nr_irqs:             89 + HD64465_IRQ_NUM,
10067 +       .mv_nr_irqs             = 89 + HD64465_IRQ_NUM,
10068  
10069 -       mv_inb:                 hd64465_inb,
10070 -       mv_inw:                 hd64465_inw,
10071 -       mv_inl:                 hd64465_inl,
10072 -       mv_outb:                hd64465_outb,
10073 -       mv_outw:                hd64465_outw,
10074 -       mv_outl:                hd64465_outl,
10075 -
10076 -       mv_inb_p:               hd64465_inb_p,
10077 -       mv_inw_p:               hd64465_inw,
10078 -       mv_inl_p:               hd64465_inl,
10079 -       mv_outb_p:              hd64465_outb_p,
10080 -       mv_outw_p:              hd64465_outw,
10081 -       mv_outl_p:              hd64465_outl,
10082 -
10083 -       mv_insb:                hd64465_insb,
10084 -       mv_insw:                hd64465_insw,
10085 -       mv_insl:                hd64465_insl,
10086 -       mv_outsb:               hd64465_outsb,
10087 -       mv_outsw:               hd64465_outsw,
10088 -       mv_outsl:               hd64465_outsl,
10089 -
10090 -       mv_readb:               generic_readb,
10091 -       mv_readw:               generic_readw,
10092 -       mv_readl:               generic_readl,
10093 -       mv_writeb:              generic_writeb,
10094 -       mv_writew:              generic_writew,
10095 -       mv_writel:              generic_writel,
10096 +       .mv_inb                 = hd64465_inb,
10097 +       .mv_inw                 = hd64465_inw,
10098 +       .mv_inl                 = hd64465_inl,
10099 +       .mv_outb                = hd64465_outb,
10100 +       .mv_outw                = hd64465_outw,
10101 +       .mv_outl                = hd64465_outl,
10102 +
10103 +       .mv_inb_p               = hd64465_inb_p,
10104 +       .mv_inw_p               = hd64465_inw,
10105 +       .mv_inl_p               = hd64465_inl,
10106 +       .mv_outb_p              = hd64465_outb_p,
10107 +       .mv_outw_p              = hd64465_outw,
10108 +       .mv_outl_p              = hd64465_outl,
10109 +
10110 +       .mv_insb                = hd64465_insb,
10111 +       .mv_insw                = hd64465_insw,
10112 +       .mv_insl                = hd64465_insl,
10113 +       .mv_outsb               = hd64465_outsb,
10114 +       .mv_outsw               = hd64465_outsw,
10115 +       .mv_outsl               = hd64465_outsl,
10116 +
10117 +       .mv_readb               = generic_readb,
10118 +       .mv_readw               = generic_readw,
10119 +       .mv_readl               = generic_readl,
10120 +       .mv_writeb              = generic_writeb,
10121 +       .mv_writew              = generic_writew,
10122 +       .mv_writel              = generic_writel,
10123  
10124 -        mv_ioremap:             generic_ioremap,
10125 -        mv_iounmap:             generic_iounmap,
10126 +        .mv_ioremap             = generic_ioremap,
10127 +        .mv_iounmap             = generic_iounmap,
10128   
10129 -        mv_isa_port2addr:       hd64465_isa_port2addr,
10130 +        .mv_isa_port2addr       = hd64465_isa_port2addr,
10131  
10132  #ifdef CONFIG_PCI
10133 -       mv_init_irq:            init_harp_irq,
10134 +       .mv_init_irq            = init_harp_irq,
10135  #endif
10136  #ifdef CONFIG_HEARTBEAT
10137 -       mv_heartbeat:           heartbeat_harp,
10138 +       .mv_heartbeat           = heartbeat_harp,
10139  #endif
10140  };
10141  
10142 diff -Nru a/arch/sh/boards/hp6xx/hp620/mach.c b/arch/sh/boards/hp6xx/hp620/mach.c
10143 --- a/arch/sh/boards/hp6xx/hp620/mach.c Mon May 19 16:04:36 2003
10144 +++ b/arch/sh/boards/hp6xx/hp620/mach.c Sun Aug 31 16:14:08 2003
10145 @@ -24,41 +24,41 @@
10146   */
10147  
10148  struct sh_machine_vector mv_hp620 __initmv = {
10149 -        mv_name:                "hp620",
10150 +        .mv_name                = "hp620",
10151  
10152 -        mv_nr_irqs:             HD64461_IRQBASE+HD64461_IRQ_NUM,
10153 +        .mv_nr_irqs             = HD64461_IRQBASE+HD64461_IRQ_NUM,
10154  
10155 -        mv_inb:                 hd64461_inb,
10156 -        mv_inw:                 hd64461_inw,
10157 -        mv_inl:                 hd64461_inl,
10158 -        mv_outb:                hd64461_outb,
10159 -        mv_outw:                hd64461_outw,
10160 -        mv_outl:                hd64461_outl,
10161 -
10162 -        mv_inb_p:               hd64461_inb_p,
10163 -        mv_inw_p:               hd64461_inw,
10164 -        mv_inl_p:               hd64461_inl,
10165 -        mv_outb_p:              hd64461_outb_p,
10166 -        mv_outw_p:              hd64461_outw,
10167 -        mv_outl_p:              hd64461_outl,
10168 -
10169 -        mv_insb:                hd64461_insb,
10170 -        mv_insw:                hd64461_insw,
10171 -        mv_insl:                hd64461_insl,
10172 -        mv_outsb:               hd64461_outsb,
10173 -        mv_outsw:               hd64461_outsw,
10174 -        mv_outsl:               hd64461_outsl,
10175 -
10176 -        mv_readb:               generic_readb,
10177 -        mv_readw:               generic_readw,
10178 -        mv_readl:               generic_readl,
10179 -        mv_writeb:              generic_writeb,
10180 -        mv_writew:              generic_writew,
10181 -        mv_writel:              generic_writel,
10182 +        .mv_inb                 = hd64461_inb,
10183 +        .mv_inw                 = hd64461_inw,
10184 +        .mv_inl                 = hd64461_inl,
10185 +        .mv_outb                = hd64461_outb,
10186 +        .mv_outw                = hd64461_outw,
10187 +        .mv_outl                = hd64461_outl,
10188 +
10189 +        .mv_inb_p               = hd64461_inb_p,
10190 +        .mv_inw_p               = hd64461_inw,
10191 +        .mv_inl_p               = hd64461_inl,
10192 +        .mv_outb_p              = hd64461_outb_p,
10193 +        .mv_outw_p              = hd64461_outw,
10194 +        .mv_outl_p              = hd64461_outl,
10195 +
10196 +        .mv_insb                = hd64461_insb,
10197 +        .mv_insw                = hd64461_insw,
10198 +        .mv_insl                = hd64461_insl,
10199 +        .mv_outsb               = hd64461_outsb,
10200 +        .mv_outsw               = hd64461_outsw,
10201 +        .mv_outsl               = hd64461_outsl,
10202 +
10203 +        .mv_readb               = generic_readb,
10204 +        .mv_readw               = generic_readw,
10205 +        .mv_readl               = generic_readl,
10206 +        .mv_writeb              = generic_writeb,
10207 +        .mv_writew              = generic_writew,
10208 +        .mv_writel              = generic_writel,
10209  
10210 -        mv_irq_demux:           hd64461_irq_demux,
10211 +        .mv_irq_demux           = hd64461_irq_demux,
10212  
10213 -        mv_rtc_gettimeofday:    sh_rtc_gettimeofday,
10214 -        mv_rtc_settimeofday:    sh_rtc_settimeofday,
10215 +        .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
10216 +        .mv_rtc_settimeofday    = sh_rtc_settimeofday,
10217  };
10218  ALIAS_MV(hp620)
10219 diff -Nru a/arch/sh/boards/hp6xx/hp680/mach.c b/arch/sh/boards/hp6xx/hp680/mach.c
10220 --- a/arch/sh/boards/hp6xx/hp680/mach.c Mon May 19 16:04:37 2003
10221 +++ b/arch/sh/boards/hp6xx/hp680/mach.c Sun Aug 31 16:14:08 2003
10222 @@ -20,41 +20,41 @@
10223  #include <asm/irq.h>
10224  
10225  struct sh_machine_vector mv_hp680 __initmv = {
10226 -        mv_name:                "hp680",
10227 +        .mv_name                = "hp680",
10228  
10229 -        mv_nr_irqs:             HD64461_IRQBASE+HD64461_IRQ_NUM,
10230 +        .mv_nr_irqs             = HD64461_IRQBASE+HD64461_IRQ_NUM,
10231  
10232 -        mv_inb:                 hd64461_inb,
10233 -        mv_inw:                 hd64461_inw,
10234 -        mv_inl:                 hd64461_inl,
10235 -        mv_outb:                hd64461_outb,
10236 -        mv_outw:                hd64461_outw,
10237 -        mv_outl:                hd64461_outl,
10238 -
10239 -        mv_inb_p:               hd64461_inb_p,
10240 -        mv_inw_p:               hd64461_inw,
10241 -        mv_inl_p:               hd64461_inl,
10242 -        mv_outb_p:              hd64461_outb_p,
10243 -        mv_outw_p:              hd64461_outw,
10244 -        mv_outl_p:              hd64461_outl,
10245 -
10246 -        mv_insb:                hd64461_insb,
10247 -        mv_insw:                hd64461_insw,
10248 -        mv_insl:                hd64461_insl,
10249 -        mv_outsb:               hd64461_outsb,
10250 -        mv_outsw:               hd64461_outsw,
10251 -        mv_outsl:               hd64461_outsl,
10252 -
10253 -        mv_readb:               generic_readb,
10254 -        mv_readw:               generic_readw,
10255 -        mv_readl:               generic_readl,
10256 -        mv_writeb:              generic_writeb,
10257 -        mv_writew:              generic_writew,
10258 -        mv_writel:              generic_writel,
10259 +        .mv_inb                 = hd64461_inb,
10260 +        .mv_inw                 = hd64461_inw,
10261 +        .mv_inl                 = hd64461_inl,
10262 +        .mv_outb                = hd64461_outb,
10263 +        .mv_outw                = hd64461_outw,
10264 +        .mv_outl                = hd64461_outl,
10265 +
10266 +        .mv_inb_p               = hd64461_inb_p,
10267 +        .mv_inw_p               = hd64461_inw,
10268 +        .mv_inl_p               = hd64461_inl,
10269 +        .mv_outb_p              = hd64461_outb_p,
10270 +        .mv_outw_p              = hd64461_outw,
10271 +        .mv_outl_p              = hd64461_outl,
10272 +
10273 +        .mv_insb                = hd64461_insb,
10274 +        .mv_insw                = hd64461_insw,
10275 +        .mv_insl                = hd64461_insl,
10276 +        .mv_outsb               = hd64461_outsb,
10277 +        .mv_outsw               = hd64461_outsw,
10278 +        .mv_outsl               = hd64461_outsl,
10279 +
10280 +        .mv_readb               = generic_readb,
10281 +        .mv_readw               = generic_readw,
10282 +        .mv_readl               = generic_readl,
10283 +        .mv_writeb              = generic_writeb,
10284 +        .mv_writew              = generic_writew,
10285 +        .mv_writel              = generic_writel,
10286  
10287 -        mv_irq_demux:           hd64461_irq_demux,
10288 +        .mv_irq_demux           = hd64461_irq_demux,
10289  
10290 -        mv_rtc_gettimeofday:    sh_rtc_gettimeofday,
10291 -        mv_rtc_settimeofday:    sh_rtc_settimeofday,
10292 +        .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
10293 +        .mv_rtc_settimeofday    = sh_rtc_settimeofday,
10294  };
10295  ALIAS_MV(hp680)
10296 diff -Nru a/arch/sh/boards/hp6xx/hp690/mach.c b/arch/sh/boards/hp6xx/hp690/mach.c
10297 --- a/arch/sh/boards/hp6xx/hp690/mach.c Mon May 19 16:04:37 2003
10298 +++ b/arch/sh/boards/hp6xx/hp690/mach.c Sun Aug 31 16:14:08 2003
10299 @@ -20,41 +20,41 @@
10300  #include <asm/irq.h>
10301  
10302  struct sh_machine_vector mv_hp690 __initmv = {
10303 -        mv_name:                "hp690",
10304 +        .mv_name                = "hp690",
10305  
10306 -        mv_nr_irqs:             HD64461_IRQBASE+HD64461_IRQ_NUM,
10307 +        .mv_nr_irqs             = HD64461_IRQBASE+HD64461_IRQ_NUM,
10308  
10309 -        mv_inb:                 hd64461_inb,
10310 -        mv_inw:                 hd64461_inw,
10311 -        mv_inl:                 hd64461_inl,
10312 -        mv_outb:                hd64461_outb,
10313 -        mv_outw:                hd64461_outw,
10314 -        mv_outl:                hd64461_outl,
10315 -
10316 -        mv_inb_p:               hd64461_inb_p,
10317 -        mv_inw_p:               hd64461_inw,
10318 -        mv_inl_p:               hd64461_inl,
10319 -        mv_outb_p:              hd64461_outb_p,
10320 -        mv_outw_p:              hd64461_outw,
10321 -        mv_outl_p:              hd64461_outl,
10322 -
10323 -        mv_insb:                hd64461_insb,
10324 -        mv_insw:                hd64461_insw,
10325 -        mv_insl:                hd64461_insl,
10326 -        mv_outsb:               hd64461_outsb,
10327 -        mv_outsw:               hd64461_outsw,
10328 -        mv_outsl:               hd64461_outsl,
10329 -
10330 -        mv_readb:               generic_readb,
10331 -        mv_readw:               generic_readw,
10332 -        mv_readl:               generic_readl,
10333 -        mv_writeb:              generic_writeb,
10334 -        mv_writew:              generic_writew,
10335 -        mv_writel:              generic_writel,
10336 +        .mv_inb                 = hd64461_inb,
10337 +        .mv_inw                 = hd64461_inw,
10338 +        .mv_inl                 = hd64461_inl,
10339 +        .mv_outb                = hd64461_outb,
10340 +        .mv_outw                = hd64461_outw,
10341 +        .mv_outl                = hd64461_outl,
10342 +
10343 +        .mv_inb_p               = hd64461_inb_p,
10344 +        .mv_inw_p               = hd64461_inw,
10345 +        .mv_inl_p               = hd64461_inl,
10346 +        .mv_outb_p              = hd64461_outb_p,
10347 +        .mv_outw_p              = hd64461_outw,
10348 +        .mv_outl_p              = hd64461_outl,
10349 +
10350 +        .mv_insb                = hd64461_insb,
10351 +        .mv_insw                = hd64461_insw,
10352 +        .mv_insl                = hd64461_insl,
10353 +        .mv_outsb               = hd64461_outsb,
10354 +        .mv_outsw               = hd64461_outsw,
10355 +        .mv_outsl               = hd64461_outsl,
10356 +
10357 +        .mv_readb               = generic_readb,
10358 +        .mv_readw               = generic_readw,
10359 +        .mv_readl               = generic_readl,
10360 +        .mv_writeb              = generic_writeb,
10361 +        .mv_writew              = generic_writew,
10362 +        .mv_writel              = generic_writel,
10363  
10364 -        mv_irq_demux:           hd64461_irq_demux,
10365 +        .mv_irq_demux           = hd64461_irq_demux,
10366  
10367 -        mv_rtc_gettimeofday:    sh_rtc_gettimeofday,
10368 -        mv_rtc_settimeofday:    sh_rtc_settimeofday,
10369 +        .mv_rtc_gettimeofday    = sh_rtc_gettimeofday,
10370 +        .mv_rtc_settimeofday    = sh_rtc_settimeofday,
10371  };
10372  ALIAS_MV(hp690)
10373 diff -Nru a/arch/sh/boards/overdrive/mach.c b/arch/sh/boards/overdrive/mach.c
10374 --- a/arch/sh/boards/overdrive/mach.c   Sat Jun 14 11:02:09 2003
10375 +++ b/arch/sh/boards/overdrive/mach.c   Sun Aug 31 16:14:08 2003
10376 @@ -28,46 +28,46 @@
10377   */
10378  
10379  struct sh_machine_vector mv_od __initmv = {
10380 -       mv_nr_irqs:             48,
10381 +       .mv_nr_irqs             = 48,
10382  
10383 -       mv_inb:                 od_inb,
10384 -       mv_inw:                 od_inw,
10385 -       mv_inl:                 od_inl,
10386 -       mv_outb:                od_outb,
10387 -       mv_outw:                od_outw,
10388 -       mv_outl:                od_outl,
10389 -
10390 -       mv_inb_p:               od_inb_p,
10391 -       mv_inw_p:               od_inw_p,
10392 -       mv_inl_p:               od_inl_p,
10393 -       mv_outb_p:              od_outb_p,
10394 -       mv_outw_p:              od_outw_p,
10395 -       mv_outl_p:              od_outl_p,
10396 -
10397 -       mv_insb:                od_insb,
10398 -       mv_insw:                od_insw,
10399 -       mv_insl:                od_insl,
10400 -       mv_outsb:               od_outsb,
10401 -       mv_outsw:               od_outsw,
10402 -       mv_outsl:               od_outsl,
10403 -
10404 -       mv_readb:               generic_readb,
10405 -       mv_readw:               generic_readw,
10406 -       mv_readl:               generic_readl,
10407 -       mv_writeb:              generic_writeb,
10408 -       mv_writew:              generic_writew,
10409 -       mv_writel:              generic_writel,
10410 +       .mv_inb                 = od_inb,
10411 +       .mv_inw                 = od_inw,
10412 +       .mv_inl                 = od_inl,
10413 +       .mv_outb                = od_outb,
10414 +       .mv_outw                = od_outw,
10415 +       .mv_outl                = od_outl,
10416 +
10417 +       .mv_inb_p               = od_inb_p,
10418 +       .mv_inw_p               = od_inw_p,
10419 +       .mv_inl_p               = od_inl_p,
10420 +       .mv_outb_p              = od_outb_p,
10421 +       .mv_outw_p              = od_outw_p,
10422 +       .mv_outl_p              = od_outl_p,
10423 +
10424 +       .mv_insb                = od_insb,
10425 +       .mv_insw                = od_insw,
10426 +       .mv_insl                = od_insl,
10427 +       .mv_outsb               = od_outsb,
10428 +       .mv_outsw               = od_outsw,
10429 +       .mv_outsl               = od_outsl,
10430 +
10431 +       .mv_readb               = generic_readb,
10432 +       .mv_readw               = generic_readw,
10433 +       .mv_readl               = generic_readl,
10434 +       .mv_writeb              = generic_writeb,
10435 +       .mv_writew              = generic_writew,
10436 +       .mv_writel              = generic_writel,
10437  
10438 -       mv_ioremap:             generic_ioremap,
10439 -       mv_iounmap:             generic_iounmap,
10440 +       .mv_ioremap             = generic_ioremap,
10441 +       .mv_iounmap             = generic_iounmap,
10442  
10443 -       mv_isa_port2addr:       generic_isa_port2addr,
10444 +       .mv_isa_port2addr       = generic_isa_port2addr,
10445  
10446  #ifdef CONFIG_PCI
10447 -       mv_init_irq:            init_overdrive_irq,
10448 +       .mv_init_irq            = init_overdrive_irq,
10449  #endif
10450  #ifdef CONFIG_HEARTBEAT
10451 -       mv_heartbeat:           heartbeat_od,
10452 +       .mv_heartbeat           = heartbeat_od,
10453  #endif
10454  };
10455  
10456 diff -Nru a/arch/sh/boards/saturn/irq.c b/arch/sh/boards/saturn/irq.c
10457 --- a/arch/sh/boards/saturn/irq.c       Sat Jun 14 11:02:09 2003
10458 +++ b/arch/sh/boards/saturn/irq.c       Sun Aug 31 16:14:08 2003
10459 @@ -102,13 +102,13 @@
10460  }
10461  
10462  static struct hw_interrupt_type saturn_int = {
10463 -       typename:       "Saturn",
10464 -       enable:         enable_saturn_irq,
10465 -       disable:        disable_saturn_irq,
10466 -       ack:            mask_and_ack_saturn_irq,
10467 -       end:            end_saturn_irq,
10468 -       startup:        startup_saturn_irq,
10469 -       shutdown:       shutdown_saturn_irq,
10470 +       .typename       = "Saturn",
10471 +       .enable         = enable_saturn_irq,
10472 +       .disable        = disable_saturn_irq,
10473 +       .ack            = mask_and_ack_saturn_irq,
10474 +       .end            = end_saturn_irq,
10475 +       .startup        = startup_saturn_irq,
10476 +       .shutdown       = shutdown_saturn_irq,
10477  };
10478  
10479  int saturn_irq_demux(int irq_nr)
10480 diff -Nru a/arch/sh/boards/saturn/mach.c b/arch/sh/boards/saturn/mach.c
10481 --- a/arch/sh/boards/saturn/mach.c      Mon May 19 16:04:39 2003
10482 +++ b/arch/sh/boards/saturn/mach.c      Sun Aug 31 16:14:08 2003
10483 @@ -18,41 +18,41 @@
10484   * The Machine Vector
10485   */
10486  struct sh_machine_vector mv_saturn __initmv = {
10487 -        mv_nr_irqs:             80,    /* Fix this later */
10488 +        .mv_nr_irqs             = 80,  /* Fix this later */
10489  
10490 -        mv_inb:                 generic_inb,
10491 -        mv_inw:                 generic_inw,
10492 -        mv_inl:                 generic_inl,
10493 -        mv_outb:                generic_outb,
10494 -        mv_outw:                generic_outw,
10495 -        mv_outl:                generic_outl,
10496 -
10497 -        mv_inb_p:               generic_inb_p,
10498 -        mv_inw_p:               generic_inw_p,
10499 -        mv_inl_p:               generic_inl_p,
10500 -        mv_outb_p:              generic_outb_p,
10501 -        mv_outw_p:              generic_outw_p,
10502 -        mv_outl_p:              generic_outl_p,
10503 -
10504 -        mv_insb:                generic_insb,
10505 -        mv_insw:                generic_insw,
10506 -        mv_insl:                generic_insl,
10507 -        mv_outsb:               generic_outsb,
10508 -        mv_outsw:               generic_outsw,
10509 -        mv_outsl:               generic_outsl,
10510 -
10511 -        mv_readb:               generic_readb,
10512 -        mv_readw:               generic_readw,
10513 -        mv_readl:               generic_readl,
10514 -        mv_writeb:              generic_writeb,
10515 -        mv_writew:              generic_writew,
10516 -        mv_writel:              generic_writel,
10517 +        .mv_inb                 = generic_inb,
10518 +        .mv_inw                 = generic_inw,
10519 +        .mv_inl                 = generic_inl,
10520 +        .mv_outb                = generic_outb,
10521 +        .mv_outw                = generic_outw,
10522 +        .mv_outl                = generic_outl,
10523 +
10524 +        .mv_inb_p               = generic_inb_p,
10525 +        .mv_inw_p               = generic_inw_p,
10526 +        .mv_inl_p               = generic_inl_p,
10527 +        .mv_outb_p              = generic_outb_p,
10528 +        .mv_outw_p              = generic_outw_p,
10529 +        .mv_outl_p              = generic_outl_p,
10530 +
10531 +        .mv_insb                = generic_insb,
10532 +        .mv_insw                = generic_insw,
10533 +        .mv_insl                = generic_insl,
10534 +        .mv_outsb               = generic_outsb,
10535 +        .mv_outsw               = generic_outsw,
10536 +        .mv_outsl               = generic_outsl,
10537 +
10538 +        .mv_readb               = generic_readb,
10539 +        .mv_readw               = generic_readw,
10540 +        .mv_readl               = generic_readl,
10541 +        .mv_writeb              = generic_writeb,
10542 +        .mv_writew              = generic_writew,
10543 +        .mv_writel              = generic_writel,
10544  
10545 -        mv_isa_port2addr:       saturn_isa_port2addr,
10546 -       mv_irq_demux:           saturn_irq_demux,
10547 +        .mv_isa_port2addr       = saturn_isa_port2addr,
10548 +       .mv_irq_demux           = saturn_irq_demux,
10549  
10550 -        mv_ioremap:             saturn_ioremap,
10551 -        mv_iounmap:             saturn_iounmap,
10552 +        .mv_ioremap             = saturn_ioremap,
10553 +        .mv_iounmap             = saturn_iounmap,
10554  };
10555  
10556  ALIAS_MV(saturn)
10557 diff -Nru a/arch/sh/boards/se/770x/mach.c b/arch/sh/boards/se/770x/mach.c
10558 --- a/arch/sh/boards/se/770x/mach.c     Mon May 19 16:04:39 2003
10559 +++ b/arch/sh/boards/se/770x/mach.c     Sun Aug 31 16:14:08 2003
10560 @@ -28,49 +28,49 @@
10561  
10562  struct sh_machine_vector mv_se __initmv = {
10563  #if defined(CONFIG_CPU_SH4)
10564 -       mv_nr_irqs:             48,
10565 +       .mv_nr_irqs             = 48,
10566  #elif defined(CONFIG_CPU_SUBTYPE_SH7708)
10567 -       mv_nr_irqs:             32,
10568 +       .mv_nr_irqs             = 32,
10569  #elif defined(CONFIG_CPU_SUBTYPE_SH7709)
10570 -       mv_nr_irqs:             61,
10571 +       .mv_nr_irqs             = 61,
10572  #endif
10573  
10574 -       mv_inb:                 se_inb,
10575 -       mv_inw:                 se_inw,
10576 -       mv_inl:                 se_inl,
10577 -       mv_outb:                se_outb,
10578 -       mv_outw:                se_outw,
10579 -       mv_outl:                se_outl,
10580 -
10581 -       mv_inb_p:               se_inb_p,
10582 -       mv_inw_p:               se_inw,
10583 -       mv_inl_p:               se_inl,
10584 -       mv_outb_p:              se_outb_p,
10585 -       mv_outw_p:              se_outw,
10586 -       mv_outl_p:              se_outl,
10587 -
10588 -       mv_insb:                se_insb,
10589 -       mv_insw:                se_insw,
10590 -       mv_insl:                se_insl,
10591 -       mv_outsb:               se_outsb,
10592 -       mv_outsw:               se_outsw,
10593 -       mv_outsl:               se_outsl,
10594 -
10595 -       mv_readb:               se_readb,
10596 -       mv_readw:               se_readw,
10597 -       mv_readl:               se_readl,
10598 -       mv_writeb:              se_writeb,
10599 -       mv_writew:              se_writew,
10600 -       mv_writel:              se_writel,
10601 +       .mv_inb                 = se_inb,
10602 +       .mv_inw                 = se_inw,
10603 +       .mv_inl                 = se_inl,
10604 +       .mv_outb                = se_outb,
10605 +       .mv_outw                = se_outw,
10606 +       .mv_outl                = se_outl,
10607 +
10608 +       .mv_inb_p               = se_inb_p,
10609 +       .mv_inw_p               = se_inw,
10610 +       .mv_inl_p               = se_inl,
10611 +       .mv_outb_p              = se_outb_p,
10612 +       .mv_outw_p              = se_outw,
10613 +       .mv_outl_p              = se_outl,
10614 +
10615 +       .mv_insb                = se_insb,
10616 +       .mv_insw                = se_insw,
10617 +       .mv_insl                = se_insl,
10618 +       .mv_outsb               = se_outsb,
10619 +       .mv_outsw               = se_outsw,
10620 +       .mv_outsl               = se_outsl,
10621 +
10622 +       .mv_readb               = se_readb,
10623 +       .mv_readw               = se_readw,
10624 +       .mv_readl               = se_readl,
10625 +       .mv_writeb              = se_writeb,
10626 +       .mv_writew              = se_writew,
10627 +       .mv_writel              = se_writel,
10628  
10629 -       mv_ioremap:             generic_ioremap,
10630 -       mv_iounmap:             generic_iounmap,
10631 +       .mv_ioremap             = generic_ioremap,
10632 +       .mv_iounmap             = generic_iounmap,
10633  
10634 -       mv_isa_port2addr:       se_isa_port2addr,
10635 +       .mv_isa_port2addr       = se_isa_port2addr,
10636  
10637 -       mv_init_irq:            init_se_IRQ,
10638 +       .mv_init_irq            = init_se_IRQ,
10639  #ifdef CONFIG_HEARTBEAT
10640 -       mv_heartbeat:           heartbeat_se,
10641 +       .mv_heartbeat           = heartbeat_se,
10642  #endif
10643  };
10644  ALIAS_MV(se)
10645 diff -Nru a/arch/sh/boards/se/7751/mach.c b/arch/sh/boards/se/7751/mach.c
10646 --- a/arch/sh/boards/se/7751/mach.c     Mon May 19 16:04:39 2003
10647 +++ b/arch/sh/boards/se/7751/mach.c     Sun Aug 31 16:14:08 2003
10648 @@ -26,44 +26,44 @@
10649   */
10650  
10651  struct sh_machine_vector mv_7751se __initmv = {
10652 -       mv_nr_irqs:             72,
10653 +       .mv_nr_irqs             = 72,
10654  
10655 -       mv_inb:                 sh7751se_inb,
10656 -       mv_inw:                 sh7751se_inw,
10657 -       mv_inl:                 sh7751se_inl,
10658 -       mv_outb:                sh7751se_outb,
10659 -       mv_outw:                sh7751se_outw,
10660 -       mv_outl:                sh7751se_outl,
10661 -
10662 -       mv_inb_p:               sh7751se_inb_p,
10663 -       mv_inw_p:               sh7751se_inw,
10664 -       mv_inl_p:               sh7751se_inl,
10665 -       mv_outb_p:              sh7751se_outb_p,
10666 -       mv_outw_p:              sh7751se_outw,
10667 -       mv_outl_p:              sh7751se_outl,
10668 -
10669 -       mv_insb:                sh7751se_insb,
10670 -       mv_insw:                sh7751se_insw,
10671 -       mv_insl:                sh7751se_insl,
10672 -       mv_outsb:               sh7751se_outsb,
10673 -       mv_outsw:               sh7751se_outsw,
10674 -       mv_outsl:               sh7751se_outsl,
10675 -
10676 -       mv_readb:               sh7751se_readb,
10677 -       mv_readw:               sh7751se_readw,
10678 -       mv_readl:               sh7751se_readl,
10679 -       mv_writeb:              sh7751se_writeb,
10680 -       mv_writew:              sh7751se_writew,
10681 -       mv_writel:              sh7751se_writel,
10682 +       .mv_inb                 = sh7751se_inb,
10683 +       .mv_inw                 = sh7751se_inw,
10684 +       .mv_inl                 = sh7751se_inl,
10685 +       .mv_outb                = sh7751se_outb,
10686 +       .mv_outw                = sh7751se_outw,
10687 +       .mv_outl                = sh7751se_outl,
10688 +
10689 +       .mv_inb_p               = sh7751se_inb_p,
10690 +       .mv_inw_p               = sh7751se_inw,
10691 +       .mv_inl_p               = sh7751se_inl,
10692 +       .mv_outb_p              = sh7751se_outb_p,
10693 +       .mv_outw_p              = sh7751se_outw,
10694 +       .mv_outl_p              = sh7751se_outl,
10695 +
10696 +       .mv_insb                = sh7751se_insb,
10697 +       .mv_insw                = sh7751se_insw,
10698 +       .mv_insl                = sh7751se_insl,
10699 +       .mv_outsb               = sh7751se_outsb,
10700 +       .mv_outsw               = sh7751se_outsw,
10701 +       .mv_outsl               = sh7751se_outsl,
10702 +
10703 +       .mv_readb               = sh7751se_readb,
10704 +       .mv_readw               = sh7751se_readw,
10705 +       .mv_readl               = sh7751se_readl,
10706 +       .mv_writeb              = sh7751se_writeb,
10707 +       .mv_writew              = sh7751se_writew,
10708 +       .mv_writel              = sh7751se_writel,
10709  
10710 -       mv_ioremap:             generic_ioremap,
10711 -       mv_iounmap:             generic_iounmap,
10712 +       .mv_ioremap             = generic_ioremap,
10713 +       .mv_iounmap             = generic_iounmap,
10714  
10715 -       mv_isa_port2addr:       sh7751se_isa_port2addr,
10716 +       .mv_isa_port2addr       = sh7751se_isa_port2addr,
10717  
10718 -       mv_init_irq:            init_7751se_IRQ,
10719 +       .mv_init_irq            = init_7751se_IRQ,
10720  #ifdef CONFIG_HEARTBEAT
10721 -       mv_heartbeat:           heartbeat_7751se,
10722 +       .mv_heartbeat           = heartbeat_7751se,
10723  #endif
10724  };
10725  ALIAS_MV(7751se)
10726 diff -Nru a/arch/sh/boards/sh2000/mach.c b/arch/sh/boards/sh2000/mach.c
10727 --- a/arch/sh/boards/sh2000/mach.c      Mon May 19 16:04:40 2003
10728 +++ b/arch/sh/boards/sh2000/mach.c      Sun Aug 31 16:14:08 2003
10729 @@ -19,39 +19,39 @@
10730   */
10731  
10732  struct sh_machine_vector mv_sh2000 __initmv = {
10733 -        mv_nr_irqs:             80,
10734 +        .mv_nr_irqs             = 80,
10735  
10736 -        mv_inb:                 generic_inb,
10737 -        mv_inw:                 generic_inw,
10738 -        mv_inl:                 generic_inl,
10739 -        mv_outb:                generic_outb,
10740 -        mv_outw:                generic_outw,
10741 -        mv_outl:                generic_outl,
10742 -
10743 -        mv_inb_p:               generic_inb_p,
10744 -        mv_inw_p:               generic_inw_p,
10745 -        mv_inl_p:               generic_inl_p,
10746 -        mv_outb_p:              generic_outb_p,
10747 -        mv_outw_p:              generic_outw_p,
10748 -        mv_outl_p:              generic_outl_p,
10749 -
10750 -        mv_insb:                generic_insb,
10751 -        mv_insw:                generic_insw,
10752 -        mv_insl:                generic_insl,
10753 -        mv_outsb:               generic_outsb,
10754 -        mv_outsw:               generic_outsw,
10755 -        mv_outsl:               generic_outsl,
10756 -
10757 -        mv_readb:               generic_readb,
10758 -        mv_readw:               generic_readw,
10759 -        mv_readl:               generic_readl,
10760 -        mv_writeb:              generic_writeb,
10761 -        mv_writew:              generic_writew,
10762 -        mv_writel:              generic_writel,
10763 +        .mv_inb                 = generic_inb,
10764 +        .mv_inw                 = generic_inw,
10765 +        .mv_inl                 = generic_inl,
10766 +        .mv_outb                = generic_outb,
10767 +        .mv_outw                = generic_outw,
10768 +        .mv_outl                = generic_outl,
10769 +
10770 +        .mv_inb_p               = generic_inb_p,
10771 +        .mv_inw_p               = generic_inw_p,
10772 +        .mv_inl_p               = generic_inl_p,
10773 +        .mv_outb_p              = generic_outb_p,
10774 +        .mv_outw_p              = generic_outw_p,
10775 +        .mv_outl_p              = generic_outl_p,
10776 +
10777 +        .mv_insb                = generic_insb,
10778 +        .mv_insw                = generic_insw,
10779 +        .mv_insl                = generic_insl,
10780 +        .mv_outsb               = generic_outsb,
10781 +        .mv_outsw               = generic_outsw,
10782 +        .mv_outsl               = generic_outsl,
10783 +
10784 +        .mv_readb               = generic_readb,
10785 +        .mv_readw               = generic_readw,
10786 +        .mv_readl               = generic_readl,
10787 +        .mv_writeb              = generic_writeb,
10788 +        .mv_writew              = generic_writew,
10789 +        .mv_writel              = generic_writel,
10790  
10791 -        mv_isa_port2addr:       sh2000_isa_port2addr,
10792 +        .mv_isa_port2addr       = sh2000_isa_port2addr,
10793  
10794 -        mv_ioremap:             generic_ioremap,
10795 -        mv_iounmap:             generic_iounmap,
10796 +        .mv_ioremap             = generic_ioremap,
10797 +        .mv_iounmap             = generic_iounmap,
10798  };
10799  ALIAS_MV(sh2000)
10800 diff -Nru a/arch/sh/boards/unknown/mach.c b/arch/sh/boards/unknown/mach.c
10801 --- a/arch/sh/boards/unknown/mach.c     Fri Jan 10 04:26:40 2003
10802 +++ b/arch/sh/boards/unknown/mach.c     Sun Aug 31 16:14:08 2003
10803 @@ -24,44 +24,44 @@
10804  
10805  struct sh_machine_vector mv_unknown __initmv = {
10806  #if defined(CONFIG_CPU_SH4)
10807 -       mv_nr_irqs:             48,
10808 +       .mv_nr_irqs             = 48,
10809  #elif defined(CONFIG_CPU_SUBTYPE_SH7708)
10810 -       mv_nr_irqs:             32,
10811 +       .mv_nr_irqs             = 32,
10812  #elif defined(CONFIG_CPU_SUBTYPE_SH7709)
10813 -       mv_nr_irqs:             61,
10814 +       .mv_nr_irqs             = 61,
10815  #endif
10816  
10817 -       mv_inb:                 unknown_inb,
10818 -       mv_inw:                 unknown_inw,
10819 -       mv_inl:                 unknown_inl,
10820 -       mv_outb:                unknown_outb,
10821 -       mv_outw:                unknown_outw,
10822 -       mv_outl:                unknown_outl,
10823 -
10824 -       mv_inb_p:               unknown_inb_p,
10825 -       mv_inw_p:               unknown_inw_p,
10826 -       mv_inl_p:               unknown_inl_p,
10827 -       mv_outb_p:              unknown_outb_p,
10828 -       mv_outw_p:              unknown_outw_p,
10829 -       mv_outl_p:              unknown_outl_p,
10830 -
10831 -       mv_insb:                unknown_insb,
10832 -       mv_insw:                unknown_insw,
10833 -       mv_insl:                unknown_insl,
10834 -       mv_outsb:               unknown_outsb,
10835 -       mv_outsw:               unknown_outsw,
10836 -       mv_outsl:               unknown_outsl,
10837 -
10838 -       mv_readb:               unknown_readb,
10839 -       mv_readw:               unknown_readw,
10840 -       mv_readl:               unknown_readl,
10841 -       mv_writeb:              unknown_writeb,
10842 -       mv_writew:              unknown_writew,
10843 -       mv_writel:              unknown_writel,
10844 +       .mv_inb                 = unknown_inb,
10845 +       .mv_inw                 = unknown_inw,
10846 +       .mv_inl                 = unknown_inl,
10847 +       .mv_outb                = unknown_outb,
10848 +       .mv_outw                = unknown_outw,
10849 +       .mv_outl                = unknown_outl,
10850 +
10851 +       .mv_inb_p               = unknown_inb_p,
10852 +       .mv_inw_p               = unknown_inw_p,
10853 +       .mv_inl_p               = unknown_inl_p,
10854 +       .mv_outb_p              = unknown_outb_p,
10855 +       .mv_outw_p              = unknown_outw_p,
10856 +       .mv_outl_p              = unknown_outl_p,
10857 +
10858 +       .mv_insb                = unknown_insb,
10859 +       .mv_insw                = unknown_insw,
10860 +       .mv_insl                = unknown_insl,
10861 +       .mv_outsb               = unknown_outsb,
10862 +       .mv_outsw               = unknown_outsw,
10863 +       .mv_outsl               = unknown_outsl,
10864 +
10865 +       .mv_readb               = unknown_readb,
10866 +       .mv_readw               = unknown_readw,
10867 +       .mv_readl               = unknown_readl,
10868 +       .mv_writeb              = unknown_writeb,
10869 +       .mv_writew              = unknown_writew,
10870 +       .mv_writel              = unknown_writel,
10871  
10872 -       mv_ioremap:             unknown_ioremap,
10873 -       mv_iounmap:             unknown_iounmap,
10874 +       .mv_ioremap             = unknown_ioremap,
10875 +       .mv_iounmap             = unknown_iounmap,
10876  
10877 -       mv_isa_port2addr:       unknown_isa_port2addr,
10878 +       .mv_isa_port2addr       = unknown_isa_port2addr,
10879  };
10880  ALIAS_MV(unknown)
10881 diff -Nru a/arch/sh/cchips/hd6446x/hd64465/setup.c b/arch/sh/cchips/hd6446x/hd64465/setup.c
10882 --- a/arch/sh/cchips/hd6446x/hd64465/setup.c    Mon Nov  4 07:33:57 2002
10883 +++ b/arch/sh/cchips/hd6446x/hd64465/setup.c    Sun Aug 31 16:14:08 2003
10884 @@ -89,13 +89,13 @@
10885  
10886  
10887  static struct hw_interrupt_type hd64465_irq_type = {
10888 -       typename:       "HD64465-IRQ",
10889 -       startup:        startup_hd64465_irq,
10890 -       shutdown:       shutdown_hd64465_irq,
10891 -       enable:         enable_hd64465_irq,
10892 -       disable:        disable_hd64465_irq,
10893 -       ack:            mask_and_ack_hd64465,
10894 -       end:            end_hd64465_irq
10895 +       .typename       = "HD64465-IRQ",
10896 +       .startup        = startup_hd64465_irq,
10897 +       .shutdown       = shutdown_hd64465_irq,
10898 +       .enable         = enable_hd64465_irq,
10899 +       .disable        = disable_hd64465_irq,
10900 +       .ack            = mask_and_ack_hd64465,
10901 +       .end            = end_hd64465_irq
10902  };
10903  
10904  
10905 diff -Nru a/arch/sparc/Kconfig b/arch/sparc/Kconfig
10906 --- a/arch/sparc/Kconfig        Sat Aug  2 14:26:16 2003
10907 +++ b/arch/sparc/Kconfig        Sun Aug 31 16:14:22 2003
10908 @@ -254,29 +254,6 @@
10909           <file:Documentation/modules.txt>.
10910           The module will be called openpromfs.  If unsure, say M.
10911  
10912 -config KCORE_ELF
10913 -       bool
10914 -       depends on PROC_FS
10915 -       default y
10916 -       ---help---
10917 -         If you enabled support for /proc file system then the file
10918 -         /proc/kcore will contain the kernel core image. This can be used
10919 -         in gdb:
10920 -
10921 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
10922 -
10923 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
10924 -         /proc/kcore appear in ELF core format as defined by the Executable
10925 -         and Linking Format specification. Selecting A.OUT will choose the
10926 -         old "a.out" format which may be necessary for some old versions
10927 -         of binutils or on some architectures.
10928 -
10929 -         This is especially useful if you have compiled the kernel with the
10930 -         "-g" option to preserve debugging information. It is mainly used
10931 -         for examining kernel data structures on the live kernel so if you
10932 -         don't understand what this means or are not a kernel hacker, just
10933 -         leave it at its default value ELF.
10934 -
10935  source "fs/Kconfig.binfmt"
10936  
10937  config SUNOS_EMUL
10938 diff -Nru a/arch/sparc/boot/Makefile b/arch/sparc/boot/Makefile
10939 --- a/arch/sparc/boot/Makefile  Sat Jul 12 22:05:29 2003
10940 +++ b/arch/sparc/boot/Makefile  Thu Aug 28 00:18:36 2003
10941 @@ -19,7 +19,7 @@
10942  
10943  BTOBJS := $(HEAD_Y) $(INIT_Y)
10944  BTLIBS := $(CORE_Y) $(LIBS_Y) $(DRIVERS_Y) $(NET_Y)
10945 -LDFLAGS_image := -T arch/sparc/vmlinux.lds.s $(BTOBJS) --start-group $(BTLIBS) --end-group
10946 +LDFLAGS_image := -T arch/sparc/kernel/vmlinux.lds.s $(BTOBJS) --start-group $(BTLIBS) --end-group
10947  
10948  # Actual linking
10949  $(obj)/image: $(obj)/btfix.o FORCE
10950 diff -Nru a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
10951 --- a/arch/sparc/kernel/entry.S Sat Aug 16 14:13:18 2003
10952 +++ b/arch/sparc/kernel/entry.S Wed Aug 27 23:52:25 2003
10953 @@ -38,7 +38,7 @@
10954  
10955  #define curptr      g6
10956  
10957 -#define NR_SYSCALLS 266      /* Each OS is different... */
10958 +#define NR_SYSCALLS 267      /* Each OS is different... */
10959  
10960  /* These are just handy. */
10961  #define _SV    save    %sp, -STACKFRAME_SZ, %sp
10962 diff -Nru a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
10963 --- a/arch/sparc/kernel/ioport.c        Sun May 25 17:00:00 2003
10964 +++ b/arch/sparc/kernel/ioport.c        Thu Aug 28 01:15:54 2003
10965 @@ -511,6 +511,26 @@
10966         }
10967  }
10968  
10969 +/*
10970 + * Same as pci_map_single, but with pages.
10971 + */
10972 +dma_addr_t pci_map_page(struct pci_dev *hwdev, struct page *page,
10973 +                       unsigned long offset, size_t size, int direction)
10974 +{
10975 +       if (direction == PCI_DMA_NONE)
10976 +               BUG();
10977 +       /* IIep is write-through, not flushing. */
10978 +       return page_to_phys(page) + offset;
10979 +}
10980 +
10981 +void pci_unmap_page(struct pci_dev *hwdev,
10982 +                       dma_addr_t dma_address, size_t size, int direction)
10983 +{
10984 +       if (direction == PCI_DMA_NONE)
10985 +               BUG();
10986 +       /* mmu_inval_dma_area XXX */
10987 +}
10988 +
10989  /* Map a set of buffers described by scatterlist in streaming
10990   * mode for DMA.  This is the scather-gather version of the
10991   * above pci_map_single interface.  Here the scatter gather list
10992 diff -Nru a/arch/sparc/kernel/sys_sunos.c b/arch/sparc/kernel/sys_sunos.c
10993 --- a/arch/sparc/kernel/sys_sunos.c     Sun May 25 17:00:00 2003
10994 +++ b/arch/sparc/kernel/sys_sunos.c     Tue Aug 26 09:25:41 2003
10995 @@ -92,8 +92,8 @@
10996          * SunOS is so stupid some times... hmph!
10997          */
10998         if (file) {
10999 -               if(major(file->f_dentry->d_inode->i_rdev) == MEM_MAJOR &&
11000 -                  minor(file->f_dentry->d_inode->i_rdev) == 5) {
11001 +               if(imajor(file->f_dentry->d_inode) == MEM_MAJOR &&
11002 +                  iminor(file->f_dentry->d_inode) == 5) {
11003                         flags |= MAP_ANONYMOUS;
11004                         fput(file);
11005                         file = 0;
11006 diff -Nru a/arch/sparc/kernel/systbls.S b/arch/sparc/kernel/systbls.S
11007 --- a/arch/sparc/kernel/systbls.S       Sat Aug 16 14:13:18 2003
11008 +++ b/arch/sparc/kernel/systbls.S       Thu Aug 28 01:35:18 2003
11009 @@ -72,7 +72,7 @@
11010  /*250*/        .long sparc_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
11011  /*255*/        .long sys_nis_syscall, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
11012  /*260*/        .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
11013 -/*261*/        .long sys_timer_delete, sys_nis_syscall
11014 +/*265*/        .long sys_timer_delete, sys_timer_create, sys_nis_syscall
11015  
11016  #ifdef CONFIG_SUNOS_EMUL
11017         /* Now the SunOS syscall table. */
11018 @@ -171,6 +171,6 @@
11019         .long sunos_nosys
11020  /*260*/        .long sunos_nosys, sunos_nosys, sunos_nosys
11021         .long sunos_nosys, sunos_nosys, sunos_nosys
11022 -       .long sunos_nosys
11023 +       .long sunos_nosys, sunos_nosys
11024  
11025  #endif
11026 diff -Nru a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
11027 --- a/arch/sparc64/Kconfig      Sat Aug  2 14:26:53 2003
11028 +++ b/arch/sparc64/Kconfig      Sun Aug 31 16:14:22 2003
11029 @@ -363,29 +363,6 @@
11030           <file:Documentation/modules.txt>.
11031           The module will be called openpromfs.  If unsure, say M.
11032  
11033 -config KCORE_ELF
11034 -       bool
11035 -       depends on PROC_FS
11036 -       default y
11037 -       ---help---
11038 -         If you enabled support for /proc file system then the file
11039 -         /proc/kcore will contain the kernel core image. This can be used
11040 -         in gdb:
11041 -
11042 -         $ cd /usr/src/linux ; gdb vmlinux /proc/kcore
11043 -
11044 -         You have two choices here: ELF and A.OUT. Selecting ELF will make
11045 -         /proc/kcore appear in ELF core format as defined by the Executable
11046 -         and Linking Format specification. Selecting A.OUT will choose the
11047 -         old "a.out" format which may be necessary for some old versions
11048 -         of binutils or on some architectures.
11049 -
11050 -         This is especially useful if you have compiled the kernel with the
11051 -         "-g" option to preserve debugging information. It is mainly used
11052 -         for examining kernel data structures on the live kernel so if you
11053 -         don't understand what this means or are not a kernel hacker, just
11054 -         leave it at its default value ELF.
11055 -
11056  config SPARC32_COMPAT
11057         bool "Kernel support for Linux/Sparc 32bit binary compatibility"
11058         help
11059 diff -Nru a/arch/sparc64/kernel/entry.S b/arch/sparc64/kernel/entry.S
11060 --- a/arch/sparc64/kernel/entry.S       Sat Aug 16 14:13:18 2003
11061 +++ b/arch/sparc64/kernel/entry.S       Wed Aug 27 23:52:25 2003
11062 @@ -26,7 +26,7 @@
11063  
11064  #define curptr      g6
11065  
11066 -#define NR_SYSCALLS 266      /* Each OS is different... */
11067 +#define NR_SYSCALLS 267      /* Each OS is different... */
11068  
11069         .text
11070         .align          32
11071 diff -Nru a/arch/sparc64/kernel/ioctl32.c b/arch/sparc64/kernel/ioctl32.c
11072 --- a/arch/sparc64/kernel/ioctl32.c     Fri Aug  8 14:53:47 2003
11073 +++ b/arch/sparc64/kernel/ioctl32.c     Sun Aug 31 16:14:44 2003
11074 @@ -1388,7 +1388,7 @@
11075  #define IOCTL_TABLE_START \
11076         struct ioctl_trans ioctl_start[] = {
11077  #define IOCTL_TABLE_END \
11078 -       }; struct ioctl_trans ioctl_end[0];
11079 +       };
11080  
11081  IOCTL_TABLE_START
11082  #include <linux/compat_ioctl.h>
11083 @@ -1583,3 +1583,5 @@
11084  HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
11085  /* take care of sizeof(sizeof()) breakage */
11086  IOCTL_TABLE_END
11087 +
11088 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
11089 diff -Nru a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c
11090 --- a/arch/sparc64/kernel/irq.c Tue Aug 19 19:00:31 2003
11091 +++ b/arch/sparc64/kernel/irq.c Thu Aug 28 17:10:27 2003
11092 @@ -1097,6 +1097,18 @@
11093  
11094         memset(__irq_work + smp_processor_id(), 0, sizeof(*workp));
11095  
11096 +       /* Make sure we are called with PSTATE_IE disabled.  */
11097 +       __asm__ __volatile__("rdpr      %%pstate, %0\n\t"
11098 +                            : "=r" (tmp));
11099 +       if (tmp & PSTATE_IE) {
11100 +               prom_printf("BUG: init_irqwork_curcpu() called with "
11101 +                           "PSTATE_IE enabled, bailing.\n");
11102 +               __asm__ __volatile__("mov       %%i7, %0\n\t"
11103 +                                    : "=r" (tmp));
11104 +               prom_printf("BUG: Called from %lx\n", tmp);
11105 +               prom_halt();
11106 +       }
11107 +
11108         /* Set interrupt globals.  */
11109         workp = &__irq_work[smp_processor_id()];
11110         __asm__ __volatile__(
11111 @@ -1105,7 +1117,7 @@
11112         "mov    %2, %%g6\n\t"
11113         "wrpr   %0, 0x0, %%pstate\n\t"
11114         : "=&r" (tmp)
11115 -       : "i" (PSTATE_IG | PSTATE_IE), "r" (workp));
11116 +       : "i" (PSTATE_IG), "r" (workp));
11117  }
11118  
11119  /* Only invoked on boot processor. */
11120 diff -Nru a/arch/sparc64/kernel/pci_psycho.c b/arch/sparc64/kernel/pci_psycho.c
11121 --- a/arch/sparc64/kernel/pci_psycho.c  Fri Jul 25 08:40:56 2003
11122 +++ b/arch/sparc64/kernel/pci_psycho.c  Sun Aug 24 03:18:58 2003
11123 @@ -874,6 +874,46 @@
11124  #define PSYCHO_PCI_AFAR_A      0x2018UL
11125  #define PSYCHO_PCI_AFAR_B      0x4018UL
11126  
11127 +static irqreturn_t psycho_pcierr_intr_other(struct pci_pbm_info *pbm, int is_pbm_a)
11128 +{
11129 +       unsigned long csr_reg, csr, csr_error_bits;
11130 +       irqreturn_t ret = IRQ_NONE;
11131 +       u16 stat;
11132 +
11133 +       if (is_pbm_a) {
11134 +               csr_reg = pbm->controller_regs + PSYCHO_PCIA_CTRL;
11135 +       } else {
11136 +               csr_reg = pbm->controller_regs + PSYCHO_PCIB_CTRL;
11137 +       }
11138 +       csr = psycho_read(csr_reg);
11139 +       csr_error_bits =
11140 +               csr & (PSYCHO_PCICTRL_SBH_ERR | PSYCHO_PCICTRL_SERR);
11141 +       if (csr_error_bits) {
11142 +               /* Clear the errors.  */
11143 +               psycho_write(csr_reg, csr);
11144 +
11145 +               /* Log 'em.  */
11146 +               if (csr_error_bits & PSYCHO_PCICTRL_SBH_ERR)
11147 +                       printk("%s: PCI streaming byte hole error asserted.\n",
11148 +                              pbm->name);
11149 +               if (csr_error_bits & PSYCHO_PCICTRL_SERR)
11150 +                       printk("%s: PCI SERR signal asserted.\n", pbm->name);
11151 +               ret = IRQ_HANDLED;
11152 +       }
11153 +       pci_read_config_word(pbm->pci_bus->self, PCI_STATUS, &stat);
11154 +       if (stat & (PCI_STATUS_PARITY |
11155 +                   PCI_STATUS_SIG_TARGET_ABORT |
11156 +                   PCI_STATUS_REC_TARGET_ABORT |
11157 +                   PCI_STATUS_REC_MASTER_ABORT |
11158 +                   PCI_STATUS_SIG_SYSTEM_ERROR)) {
11159 +               printk("%s: PCI bus error, PCI_STATUS[%04x]\n",
11160 +                      pbm->name, stat);
11161 +               pci_write_config_word(pbm->pci_bus->self, PCI_STATUS, 0xffff);
11162 +               ret = IRQ_HANDLED;
11163 +       }
11164 +       return ret;
11165 +}
11166 +
11167  static irqreturn_t psycho_pcierr_intr(int irq, void *dev_id, struct pt_regs *regs)
11168  {
11169         struct pci_pbm_info *pbm = dev_id;
11170 @@ -902,7 +942,7 @@
11171                  PSYCHO_PCIAFSR_SMA | PSYCHO_PCIAFSR_STA |
11172                  PSYCHO_PCIAFSR_SRTRY | PSYCHO_PCIAFSR_SPERR);
11173         if (!error_bits)
11174 -               return IRQ_NONE;
11175 +               return psycho_pcierr_intr_other(pbm, is_pbm_a);
11176         psycho_write(afsr_reg, error_bits);
11177  
11178         /* Log the error. */
11179 @@ -1008,6 +1048,7 @@
11180                 prom_halt();
11181         }
11182  
11183 +       pbm = &p->pbm_A;
11184         irq = psycho_irq_build(pbm, NULL, (portid << 6) | PSYCHO_PCIERR_A_INO);
11185         if (request_irq(irq, psycho_pcierr_intr,
11186                         SA_SHIRQ, "PSYCHO PCIERR", &p->pbm_A) < 0) {
11187 @@ -1016,6 +1057,7 @@
11188                 prom_halt();
11189         }
11190  
11191 +       pbm = &p->pbm_B;
11192         irq = psycho_irq_build(pbm, NULL, (portid << 6) | PSYCHO_PCIERR_B_INO);
11193         if (request_irq(irq, psycho_pcierr_intr,
11194                         SA_SHIRQ, "PSYCHO PCIERR", &p->pbm_B) < 0) {
11195 diff -Nru a/arch/sparc64/kernel/pci_sabre.c b/arch/sparc64/kernel/pci_sabre.c
11196 --- a/arch/sparc64/kernel/pci_sabre.c   Tue Aug 19 16:00:48 2003
11197 +++ b/arch/sparc64/kernel/pci_sabre.c   Sun Aug 24 03:18:58 2003
11198 @@ -221,6 +221,7 @@
11199          ((unsigned long)(REG)))
11200  
11201  static int hummingbird_p;
11202 +static struct pci_bus *sabre_root_bus;
11203  
11204  static void *sabre_pci_config_mkaddr(struct pci_pbm_info *pbm,
11205                                      unsigned char bus,
11206 @@ -860,6 +861,42 @@
11207         return IRQ_HANDLED;
11208  }
11209  
11210 +static irqreturn_t sabre_pcierr_intr_other(struct pci_controller_info *p)
11211 +{
11212 +       unsigned long csr_reg, csr, csr_error_bits;
11213 +       irqreturn_t ret = IRQ_NONE;
11214 +       u16 stat;
11215 +
11216 +       csr_reg = p->pbm_A.controller_regs + SABRE_PCICTRL;
11217 +       csr = sabre_read(csr_reg);
11218 +       csr_error_bits =
11219 +               csr & SABRE_PCICTRL_SERR;
11220 +       if (csr_error_bits) {
11221 +               /* Clear the errors.  */
11222 +               sabre_write(csr_reg, csr);
11223 +
11224 +               /* Log 'em.  */
11225 +               if (csr_error_bits & SABRE_PCICTRL_SERR)
11226 +                       printk("SABRE%d: PCI SERR signal asserted.\n",
11227 +                              p->index);
11228 +               ret = IRQ_HANDLED;
11229 +       }
11230 +       pci_read_config_word(sabre_root_bus->self,
11231 +                            PCI_STATUS, &stat);
11232 +       if (stat & (PCI_STATUS_PARITY |
11233 +                   PCI_STATUS_SIG_TARGET_ABORT |
11234 +                   PCI_STATUS_REC_TARGET_ABORT |
11235 +                   PCI_STATUS_REC_MASTER_ABORT |
11236 +                   PCI_STATUS_SIG_SYSTEM_ERROR)) {
11237 +               printk("SABRE%d: PCI bus error, PCI_STATUS[%04x]\n",
11238 +                      p->index, stat);
11239 +               pci_write_config_word(sabre_root_bus->self,
11240 +                                     PCI_STATUS, 0xffff);
11241 +               ret = IRQ_HANDLED;
11242 +       }
11243 +       return ret;
11244 +}
11245 +
11246  static irqreturn_t sabre_pcierr_intr(int irq, void *dev_id, struct pt_regs *regs)
11247  {
11248         struct pci_controller_info *p = dev_id;
11249 @@ -881,7 +918,7 @@
11250                  SABRE_PIOAFSR_SMA | SABRE_PIOAFSR_STA |
11251                  SABRE_PIOAFSR_SRTRY | SABRE_PIOAFSR_SPERR);
11252         if (!error_bits)
11253 -               return IRQ_NONE;
11254 +               return sabre_pcierr_intr_other(p);
11255         sabre_write(afsr_reg, error_bits);
11256  
11257         /* Log the error. */
11258 @@ -1167,6 +1204,8 @@
11259                                  &p->pbm_A);
11260         pci_fixup_host_bridge_self(sabre_bus);
11261         sabre_bus->self->sysdata = cookie;
11262 +
11263 +       sabre_root_bus = sabre_bus;
11264  
11265         apb_init(p, sabre_bus);
11266  
11267 diff -Nru a/arch/sparc64/kernel/pci_schizo.c b/arch/sparc64/kernel/pci_schizo.c
11268 --- a/arch/sparc64/kernel/pci_schizo.c  Sat Aug  2 18:21:52 2003
11269 +++ b/arch/sparc64/kernel/pci_schizo.c  Sun Aug 24 03:18:58 2003
11270 @@ -845,6 +845,88 @@
11271  #define SCHIZO_PCIAFSR_MEM     0x0000000020000000UL /* Schizo/Tomatillo */
11272  #define SCHIZO_PCIAFSR_IO      0x0000000010000000UL /* Schizo/Tomatillo */
11273  
11274 +#define SCHIZO_PCI_CTRL                (0x2000UL)
11275 +#define SCHIZO_PCICTRL_BUS_UNUS        (1UL << 63UL) /* Safari */
11276 +#define SCHIZO_PCICTRL_ARB_PRIO (0x1ff << 52UL) /* Tomatillo */
11277 +#define SCHIZO_PCICTRL_ESLCK   (1UL << 51UL) /* Safari */
11278 +#define SCHIZO_PCICTRL_ERRSLOT (7UL << 48UL) /* Safari */
11279 +#define SCHIZO_PCICTRL_TTO_ERR (1UL << 38UL) /* Safari/Tomatillo */
11280 +#define SCHIZO_PCICTRL_RTRY_ERR        (1UL << 37UL) /* Safari/Tomatillo */
11281 +#define SCHIZO_PCICTRL_DTO_ERR (1UL << 36UL) /* Safari/Tomatillo */
11282 +#define SCHIZO_PCICTRL_SBH_ERR (1UL << 35UL) /* Safari */
11283 +#define SCHIZO_PCICTRL_SERR    (1UL << 34UL) /* Safari/Tomatillo */
11284 +#define SCHIZO_PCICTRL_PCISPD  (1UL << 33UL) /* Safari */
11285 +#define SCHIZO_PCICTRL_MRM_PREF        (1UL << 28UL) /* Tomatillo */
11286 +#define SCHIZO_PCICTRL_RDO_PREF        (1UL << 27UL) /* Tomatillo */
11287 +#define SCHIZO_PCICTRL_RDL_PREF        (1UL << 26UL) /* Tomatillo */
11288 +#define SCHIZO_PCICTRL_PTO     (3UL << 24UL) /* Safari/Tomatillo */
11289 +#define SCHIZO_PCICTRL_PTO_SHIFT 24UL
11290 +#define SCHIZO_PCICTRL_TRWSW   (7UL << 21UL) /* Tomatillo */
11291 +#define SCHIZO_PCICTRL_F_TGT_A (1UL << 20UL) /* Tomatillo */
11292 +#define SCHIZO_PCICTRL_S_DTO_INT (1UL << 19UL) /* Safari */
11293 +#define SCHIZO_PCICTRL_F_TGT_RT        (1UL << 19UL) /* Tomatillo */
11294 +#define SCHIZO_PCICTRL_SBH_INT (1UL << 18UL) /* Safari */
11295 +#define SCHIZO_PCICTRL_T_DTO_INT (1UL << 18UL) /* Tomatillo */
11296 +#define SCHIZO_PCICTRL_EEN     (1UL << 17UL) /* Safari/Tomatillo */
11297 +#define SCHIZO_PCICTRL_PARK    (1UL << 16UL) /* Safari/Tomatillo */
11298 +#define SCHIZO_PCICTRL_PCIRST  (1UL <<  8UL) /* Safari */
11299 +#define SCHIZO_PCICTRL_ARB_S   (0x3fUL << 0UL) /* Safari */
11300 +#define SCHIZO_PCICTRL_ARB_T   (0xffUL << 0UL) /* Tomatillo */
11301 +
11302 +static irqreturn_t schizo_pcierr_intr_other(struct pci_pbm_info *pbm)
11303 +{
11304 +       unsigned long csr_reg, csr, csr_error_bits;
11305 +       irqreturn_t ret = IRQ_NONE;
11306 +       u16 stat;
11307 +
11308 +       csr_reg = pbm->pbm_regs + SCHIZO_PCI_CTRL;
11309 +       csr = schizo_read(csr_reg);
11310 +       csr_error_bits =
11311 +               csr & (SCHIZO_PCICTRL_BUS_UNUS |
11312 +                      SCHIZO_PCICTRL_TTO_ERR |
11313 +                      SCHIZO_PCICTRL_RTRY_ERR |
11314 +                      SCHIZO_PCICTRL_DTO_ERR |
11315 +                      SCHIZO_PCICTRL_SBH_ERR |
11316 +                      SCHIZO_PCICTRL_SERR);
11317 +       if (csr_error_bits) {
11318 +               /* Clear the errors.  */
11319 +               schizo_write(csr_reg, csr);
11320 +
11321 +               /* Log 'em.  */
11322 +               if (csr_error_bits & SCHIZO_PCICTRL_BUS_UNUS)
11323 +                       printk("%s: Bus unusable error asserted.\n",
11324 +                              pbm->name);
11325 +               if (csr_error_bits & SCHIZO_PCICTRL_TTO_ERR)
11326 +                       printk("%s: PCI TRDY# timeout error asserted.\n",
11327 +                              pbm->name);
11328 +               if (csr_error_bits & SCHIZO_PCICTRL_RTRY_ERR)
11329 +                       printk("%s: PCI excessive retry error asserted.\n",
11330 +                              pbm->name);
11331 +               if (csr_error_bits & SCHIZO_PCICTRL_DTO_ERR)
11332 +                       printk("%s: PCI discard timeout error asserted.\n",
11333 +                              pbm->name);
11334 +               if (csr_error_bits & SCHIZO_PCICTRL_SBH_ERR)
11335 +                       printk("%s: PCI streaming byte hole error asserted.\n",
11336 +                              pbm->name);
11337 +               if (csr_error_bits & SCHIZO_PCICTRL_SERR)
11338 +                       printk("%s: PCI SERR signal asserted.\n",
11339 +                              pbm->name);
11340 +               ret = IRQ_HANDLED;
11341 +       }
11342 +       pci_read_config_word(pbm->pci_bus->self, PCI_STATUS, &stat);
11343 +       if (stat & (PCI_STATUS_PARITY |
11344 +                   PCI_STATUS_SIG_TARGET_ABORT |
11345 +                   PCI_STATUS_REC_TARGET_ABORT |
11346 +                   PCI_STATUS_REC_MASTER_ABORT |
11347 +                   PCI_STATUS_SIG_SYSTEM_ERROR)) {
11348 +               printk("%s: PCI bus error, PCI_STATUS[%04x]\n",
11349 +                      pbm->name, stat);
11350 +               pci_write_config_word(pbm->pci_bus->self, PCI_STATUS, 0xffff);
11351 +               ret = IRQ_HANDLED;
11352 +       }
11353 +       return ret;
11354 +}
11355 +
11356  static irqreturn_t schizo_pcierr_intr(int irq, void *dev_id, struct pt_regs *regs)
11357  {
11358         struct pci_pbm_info *pbm = dev_id;
11359 @@ -871,7 +953,7 @@
11360                  SCHIZO_PCIAFSR_SRTRY | SCHIZO_PCIAFSR_SPERR |
11361                  SCHIZO_PCIAFSR_STTO | SCHIZO_PCIAFSR_SUNUS);
11362         if (!error_bits)
11363 -               return IRQ_NONE;
11364 +               return schizo_pcierr_intr_other(pbm);
11365         schizo_write(afsr_reg, error_bits);
11366  
11367         /* Log the error. */
11368 @@ -1043,34 +1125,6 @@
11369  #define SCHIZO_PCIERR_A_INO    0x32 /* PBM A PCI bus error */
11370  #define SCHIZO_PCIERR_B_INO    0x33 /* PBM B PCI bus error */
11371  #define SCHIZO_SERR_INO                0x34 /* Safari interface error */
11372 -
11373 -#define SCHIZO_PCI_CTRL                (0x2000UL)
11374 -#define SCHIZO_PCICTRL_BUS_UNUS        (1UL << 63UL) /* Safari */
11375 -#define SCHIZO_PCICTRL_ARB_PRIO (0x1ff << 52UL) /* Tomatillo */
11376 -#define SCHIZO_PCICTRL_ESLCK   (1UL << 51UL) /* Safari */
11377 -#define SCHIZO_PCICTRL_ERRSLOT (7UL << 48UL) /* Safari */
11378 -#define SCHIZO_PCICTRL_TTO_ERR (1UL << 38UL) /* Safari/Tomatillo */
11379 -#define SCHIZO_PCICTRL_RTRY_ERR        (1UL << 37UL) /* Safari/Tomatillo */
11380 -#define SCHIZO_PCICTRL_DTO_ERR (1UL << 36UL) /* Safari/Tomatillo */
11381 -#define SCHIZO_PCICTRL_SBH_ERR (1UL << 35UL) /* Safari */
11382 -#define SCHIZO_PCICTRL_SERR    (1UL << 34UL) /* Safari/Tomatillo */
11383 -#define SCHIZO_PCICTRL_PCISPD  (1UL << 33UL) /* Safari */
11384 -#define SCHIZO_PCICTRL_MRM_PREF        (1UL << 28UL) /* Tomatillo */
11385 -#define SCHIZO_PCICTRL_RDO_PREF        (1UL << 27UL) /* Tomatillo */
11386 -#define SCHIZO_PCICTRL_RDL_PREF        (1UL << 26UL) /* Tomatillo */
11387 -#define SCHIZO_PCICTRL_PTO     (3UL << 24UL) /* Safari/Tomatillo */
11388 -#define SCHIZO_PCICTRL_PTO_SHIFT 24UL
11389 -#define SCHIZO_PCICTRL_TRWSW   (7UL << 21UL) /* Tomatillo */
11390 -#define SCHIZO_PCICTRL_F_TGT_A (1UL << 20UL) /* Tomatillo */
11391 -#define SCHIZO_PCICTRL_S_DTO_INT (1UL << 19UL) /* Safari */
11392 -#define SCHIZO_PCICTRL_F_TGT_RT        (1UL << 19UL) /* Tomatillo */
11393 -#define SCHIZO_PCICTRL_SBH_INT (1UL << 18UL) /* Safari */
11394 -#define SCHIZO_PCICTRL_T_DTO_INT (1UL << 18UL) /* Tomatillo */
11395 -#define SCHIZO_PCICTRL_EEN     (1UL << 17UL) /* Safari/Tomatillo */
11396 -#define SCHIZO_PCICTRL_PARK    (1UL << 16UL) /* Safari/Tomatillo */
11397 -#define SCHIZO_PCICTRL_PCIRST  (1UL <<  8UL) /* Safari */
11398 -#define SCHIZO_PCICTRL_ARB_S   (0x3fUL << 0UL) /* Safari */
11399 -#define SCHIZO_PCICTRL_ARB_T   (0xffUL << 0UL) /* Tomatillo */
11400  
11401  struct pci_pbm_info *pbm_for_ino(struct pci_controller_info *p, u32 ino)
11402  {
11403 diff -Nru a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c
11404 --- a/arch/sparc64/kernel/sys_sparc32.c Sat Aug 16 07:09:56 2003
11405 +++ b/arch/sparc64/kernel/sys_sparc32.c Sat Aug 30 22:29:28 2003
11406 @@ -388,7 +388,7 @@
11407   *
11408   * This is really horribly ugly.
11409   */
11410 -#define IPCOP_MASK(__x)        (1UL << (__x))
11411 +#define IPCOP_MASK(__x)        (1UL << ((__x)&~IPC_64))
11412  static int do_sys32_semctl(int first, int second, int third, void *uptr)
11413  {
11414         union semun fourth;
11415 @@ -400,7 +400,7 @@
11416         err = -EFAULT;
11417         if (get_user (pad, (u32 *)uptr))
11418                 goto out;
11419 -       if(third == SETVAL)
11420 +       if ((third & ~IPC_64) == SETVAL)
11421                 fourth.val = (int)pad;
11422         else
11423                 fourth.__pad = (void *)A(pad);
11424 @@ -2779,3 +2779,41 @@
11425         return sys_lookup_dcookie((u64)cookie_high << 32 | cookie_low,
11426                                   buf, len);
11427  }
11428 +
11429 +extern asmlinkage long
11430 +sys_timer_create(clockid_t which_clock, struct sigevent *timer_event_spec,
11431 +                timer_t * created_timer_id);
11432 +
11433 +long
11434 +sys32_timer_create(u32 clock, struct sigevent32 *se32, timer_t *timer_id)
11435 +{
11436 +       struct sigevent se;
11437 +       mm_segment_t oldfs;
11438 +       timer_t t;
11439 +       long err;
11440 +
11441 +       if (se32 == NULL)
11442 +               return sys_timer_create(clock, NULL, timer_id);
11443 +
11444 +       memset(&se, 0, sizeof(struct sigevent));
11445 +       if (get_user(se.sigev_value.sival_int,  &se32->sigev_value.sival_int) ||
11446 +           __get_user(se.sigev_signo, &se32->sigev_signo) ||
11447 +           __get_user(se.sigev_notify, &se32->sigev_notify) ||
11448 +           __copy_from_user(&se._sigev_un._pad, &se32->_sigev_un._pad,
11449 +           sizeof(se._sigev_un._pad)))
11450 +               return -EFAULT;
11451 +
11452 +       if (!access_ok(VERIFY_WRITE,timer_id,sizeof(timer_t)))
11453 +               return -EFAULT;
11454 +
11455 +       oldfs = get_fs();
11456 +       set_fs(KERNEL_DS);
11457 +       err = sys_timer_create(clock, &se, &t);
11458 +       set_fs(oldfs);
11459 +
11460 +       if (!err)
11461 +               err = __put_user (t, timer_id);
11462 +
11463 +       return err;
11464 +}
11465 +
11466 diff -Nru a/arch/sparc64/kernel/sys_sunos32.c b/arch/sparc64/kernel/sys_sunos32.c
11467 --- a/arch/sparc64/kernel/sys_sunos32.c Sun May 25 17:00:00 2003
11468 +++ b/arch/sparc64/kernel/sys_sunos32.c Tue Aug 26 09:25:41 2003
11469 @@ -90,7 +90,7 @@
11470                 if (!file)
11471                         goto out;
11472                 inode = file->f_dentry->d_inode;
11473 -               if (minor(inode->i_rdev) == MEM_MAJOR && minor(inode->i_rdev) == 5) {
11474 +               if (imajor(inode) == MEM_MAJOR && iminor(inode) == 5) {
11475                         flags |= MAP_ANONYMOUS;
11476                         fput(file);
11477                         file = NULL;
11478 diff -Nru a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
11479 --- a/arch/sparc64/kernel/systbls.S     Sat Aug 16 14:55:44 2003
11480 +++ b/arch/sparc64/kernel/systbls.S     Thu Aug 28 01:35:18 2003
11481 @@ -72,7 +72,7 @@
11482  /*250*/        .word sys32_mremap, sys32_sysctl, sys_getsid, sys_fdatasync, sys32_nfsservctl
11483         .word sys_ni_syscall, compat_clock_settime, compat_clock_gettime, compat_clock_getres, compat_clock_nanosleep
11484  /*260*/        .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, compat_timer_settime, compat_timer_gettime, sys_timer_getoverrun
11485 -       .word sys_timer_delete, sys_ni_syscall
11486 +       .word sys_timer_delete, sys32_timer_create, sys_ni_syscall
11487  
11488         /* Now the 64-bit native Linux syscall table. */
11489  
11490 @@ -133,7 +133,7 @@
11491  /*250*/        .word sys64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
11492         .word sys_ni_syscall, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
11493  /*260*/        .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
11494 -       .word sys_timer_delete, sys_ni_syscall
11495 +       .word sys_timer_delete, sys_timer_create, sys_ni_syscall
11496  
11497  #if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
11498      defined(CONFIG_SOLARIS_EMUL_MODULE)
11499 @@ -228,10 +228,10 @@
11500         .word sunos_nosys, sunos_nosys, sunos_nosys
11501         .word sunos_nosys, sunos_nosys
11502  /*250*/        .word sunos_nosys, sunos_nosys, sunos_nosys
11503 -       .word sunos_nosys, sunos_nosys, sys_ni_syscall
11504 -       .word sys_ni_syscall, sys_ni_syscall, sys_ni_syscall
11505 -       .word sys_ni_syscall, sys_ni_syscall, sys_ni_syscall
11506 -       .word sys_ni_syscall, sys_ni_syscall, sys_ni_syscall
11507 -       .word sys_ni_syscall, sys_ni_syscall
11508 +       .word sunos_nosys, sunos_nosys, sunos_nosys
11509 +       .word sunos_nosys, sunos_nosys, sunos_nosys
11510 +       .word sunos_nosys, sunos_nosys, sunos_nosys
11511 +       .word sunos_nosys, sunos_nosys, sunos_nosys
11512 +       .word sunos_nosys, sunos_nosys, sunos_nosys
11513  
11514  #endif
11515 diff -Nru a/arch/sparc64/mm/hugetlbpage.c b/arch/sparc64/mm/hugetlbpage.c
11516 --- a/arch/sparc64/mm/hugetlbpage.c     Mon Feb 24 23:13:11 2003
11517 +++ b/arch/sparc64/mm/hugetlbpage.c     Tue Aug 26 09:41:27 2003
11518 @@ -380,207 +380,6 @@
11519         return 1;
11520  }
11521  
11522 -static struct inode *set_new_inode(unsigned long len, int prot, int flag, int key)
11523 -{
11524 -       struct inode *inode;
11525 -       int i;
11526 -
11527 -       for (i = 0; i < MAX_ID; i++) {
11528 -               if (htlbpagek[i].key == 0)
11529 -                       break;
11530 -       }
11531 -       if (i == MAX_ID)
11532 -               return NULL;
11533 -       inode = kmalloc(sizeof (struct inode), GFP_KERNEL);
11534 -       if (inode == NULL)
11535 -               return NULL;
11536 -
11537 -       inode_init_once(inode);
11538 -       atomic_inc(&inode->i_writecount);
11539 -       inode->i_mapping = &inode->i_data;
11540 -       inode->i_mapping->host = inode;
11541 -       inode->i_ino = (unsigned long)key;
11542 -
11543 -       htlbpagek[i].key = key;
11544 -       htlbpagek[i].in = inode;
11545 -       inode->i_uid = current->fsuid;
11546 -       inode->i_gid = current->fsgid;
11547 -       inode->i_mode = prot;
11548 -       inode->i_size = len;
11549 -       return inode;
11550 -}
11551 -
11552 -static int check_size_prot(struct inode *inode, unsigned long len, int prot, int flag)
11553 -{
11554 -       if (inode->i_uid != current->fsuid)
11555 -               return -1;
11556 -       if (inode->i_gid != current->fsgid)
11557 -               return -1;
11558 -       if (inode->i_size != len)
11559 -               return -1;
11560 -       return 0;
11561 -}
11562 -
11563 -static int alloc_shared_hugetlb_pages(int key, unsigned long addr, unsigned long len,
11564 -                                     int prot, int flag)
11565 -{
11566 -       struct mm_struct *mm = current->mm;
11567 -       struct vm_area_struct *vma;
11568 -       struct inode *inode;
11569 -       struct address_space *mapping;
11570 -       struct page *page;
11571 -       int idx;
11572 -       int retval = -ENOMEM;
11573 -       int newalloc = 0;
11574 -
11575 -try_again:
11576 -       spin_lock(&htlbpage_lock);
11577 -
11578 -       inode = find_key_inode(key);
11579 -       if (inode == NULL) {
11580 -               if (!capable(CAP_SYS_ADMIN)) {
11581 -                       if (!in_group_p(0)) {
11582 -                               retval = -EPERM;
11583 -                               goto out_err;
11584 -                       }
11585 -               }
11586 -               if (!(flag & IPC_CREAT)) {
11587 -                       retval = -ENOENT;
11588 -                       goto out_err;
11589 -               }
11590 -               inode = set_new_inode(len, prot, flag, key);
11591 -               if (inode == NULL)
11592 -                       goto out_err;
11593 -               newalloc = 1;
11594 -       } else {
11595 -               if (check_size_prot(inode, len, prot, flag) < 0) {
11596 -                       retval = -EINVAL;
11597 -                       goto out_err;
11598 -               } else if (atomic_read(&inode->i_writecount)) {
11599 -                       spin_unlock(&htlbpage_lock);
11600 -                       goto try_again;
11601 -               }
11602 -       }
11603 -       spin_unlock(&htlbpage_lock);
11604 -       mapping = inode->i_mapping;
11605 -
11606 -       addr = do_mmap_pgoff(NULL, addr, len, (unsigned long) prot,
11607 -                            MAP_NORESERVE|MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS, 0);
11608 -       if (IS_ERR((void *) addr))
11609 -               goto freeinode;
11610 -
11611 -       vma = find_vma(mm, addr);
11612 -       if (!vma) {
11613 -               retval = -EINVAL;
11614 -               goto freeinode;
11615 -       }
11616 -
11617 -       spin_lock(&mm->page_table_lock);
11618 -       do {
11619 -               pte_t *pte = huge_pte_alloc_map(mm, addr);
11620 -
11621 -               if (!pte || !pte_none(pte)) {
11622 -                       if (pte)
11623 -                               pte_unmap(pte);
11624 -                       goto out;
11625 -               }
11626 -
11627 -               idx = (addr - vma->vm_start) >> HPAGE_SHIFT;
11628 -               page = find_get_page(mapping, idx);
11629 -               if (page == NULL) {
11630 -                       page = alloc_hugetlb_page();
11631 -                       if (page == NULL) {
11632 -                               pte_unmap(pte);
11633 -                               retval = -ENOMEM;
11634 -                               goto out;
11635 -                       }
11636 -                       retval = add_to_page_cache(page, mapping,
11637 -                                               idx, GFP_ATOMIC);
11638 -                       if (retval) {
11639 -                               pte_unmap(pte);
11640 -                               free_hugetlb_page(page);
11641 -                               goto out;
11642 -                       }
11643 -               }
11644 -               set_huge_pte(mm, vma, page, pte,
11645 -                            (vma->vm_flags & VM_WRITE));
11646 -               pte_unmap(pte);
11647 -
11648 -               addr += HPAGE_SIZE;
11649 -       } while (addr < vma->vm_end);
11650 -
11651 -       retval = 0;
11652 -       vma->vm_flags |= (VM_HUGETLB | VM_RESERVED);
11653 -       vma->vm_ops = &hugetlb_vm_ops;
11654 -       spin_unlock(&mm->page_table_lock);
11655 -       spin_lock(&htlbpage_lock);
11656 -       atomic_set(&inode->i_writecount, 0);
11657 -       spin_unlock(&htlbpage_lock);
11658 -
11659 -       return retval;
11660 -
11661 -out:
11662 -       if (addr > vma->vm_start) {
11663 -               unsigned long raddr;
11664 -               raddr = vma->vm_end;
11665 -               vma->vm_end = addr;
11666 -
11667 -               flush_cache_range(vma, vma->vm_start, vma->vm_end);
11668 -               zap_hugetlb_resources(vma);
11669 -               flush_tlb_range(vma, vma->vm_start, vma->vm_end);
11670 -
11671 -               vma->vm_end = raddr;
11672 -       }
11673 -       spin_unlock(&mm->page_table_lock);
11674 -       do_munmap(mm, vma->vm_start, len);
11675 -       if (newalloc)
11676 -               goto freeinode;
11677 -
11678 -       return retval;
11679 -
11680 -out_err:
11681 -       spin_unlock(&htlbpage_lock);
11682 -
11683 -freeinode:
11684 -       if (newalloc) {
11685 -               for (idx = 0; idx < MAX_ID; idx++) {
11686 -                       if (htlbpagek[idx].key == inode->i_ino) {
11687 -                               htlbpagek[idx].key = 0;
11688 -                               htlbpagek[idx].in = NULL;
11689 -                               break;
11690 -                       }
11691 -               }
11692 -               kfree(inode);
11693 -       }
11694 -       return retval;
11695 -}
11696 -
11697 -static int alloc_private_hugetlb_pages(int key, unsigned long addr, unsigned long len,
11698 -                                      int prot, int flag)
11699 -{
11700 -       if (!capable(CAP_SYS_ADMIN)) {
11701 -               if (!in_group_p(0))
11702 -                       return -EPERM;
11703 -       }
11704 -       addr = do_mmap_pgoff(NULL, addr, len, prot,
11705 -                            MAP_NORESERVE|MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, 0);
11706 -       if (IS_ERR((void *) addr))
11707 -               return -ENOMEM;
11708 -       if (make_hugetlb_pages_present(addr, (addr + len), flag) < 0) {
11709 -               do_munmap(current->mm, addr, len);
11710 -               return -ENOMEM;
11711 -       }
11712 -       return 0;
11713 -}
11714 -
11715 -int alloc_hugetlb_pages(int key, unsigned long addr, unsigned long len, int prot,
11716 -                   int flag)
11717 -{
11718 -       if (key > 0)
11719 -               return alloc_shared_hugetlb_pages(key, addr, len, prot, flag);
11720 -       return alloc_private_hugetlb_pages(key, addr, len, prot, flag);
11721 -}
11722 -
11723  extern long htlbzone_pages;
11724  extern struct list_head htlbpage_freelist;
11725  
11726 diff -Nru a/arch/sparc64/solaris/misc.c b/arch/sparc64/solaris/misc.c
11727 --- a/arch/sparc64/solaris/misc.c       Tue Aug 19 12:12:41 2003
11728 +++ b/arch/sparc64/solaris/misc.c       Tue Aug 26 09:25:41 2003
11729 @@ -77,8 +77,8 @@
11730                         goto out;
11731                 else {
11732                         struct inode * inode = file->f_dentry->d_inode;
11733 -                       if(major(inode->i_rdev) == MEM_MAJOR &&
11734 -                          minor(inode->i_rdev) == 5) {
11735 +                       if(imajor(inode) == MEM_MAJOR &&
11736 +                          iminor(inode) == 5) {
11737                                 flags |= MAP_ANONYMOUS;
11738                                 fput(file);
11739                                 file = NULL;
11740 diff -Nru a/arch/sparc64/solaris/socksys.c b/arch/sparc64/solaris/socksys.c
11741 --- a/arch/sparc64/solaris/socksys.c    Wed May  7 08:47:29 2003
11742 +++ b/arch/sparc64/solaris/socksys.c    Tue Aug 26 09:25:40 2003
11743 @@ -70,14 +70,14 @@
11744                 (int (*)(int,int,int))SUNOS(97);
11745          struct sol_socket_struct * sock;
11746         
11747 -       family = ((minor(inode->i_rdev) >> 4) & 0xf);
11748 +       family = ((iminor(inode) >> 4) & 0xf);
11749         switch (family) {
11750         case AF_UNIX:
11751                 type = SOCK_STREAM;
11752                 protocol = 0;
11753                 break;
11754         case AF_INET:
11755 -               protocol = af_inet_protocols[minor(inode->i_rdev) & 0xf];
11756 +               protocol = af_inet_protocols[iminor(inode) & 0xf];
11757                 switch (protocol) {
11758                 case IPPROTO_TCP: type = SOCK_STREAM; break;
11759                 case IPPROTO_UDP: type = SOCK_DGRAM; break;
11760 diff -Nru a/arch/sparc64/solaris/systbl.S b/arch/sparc64/solaris/systbl.S
11761 --- a/arch/sparc64/solaris/systbl.S     Mon Aug 18 01:08:52 2003
11762 +++ b/arch/sparc64/solaris/systbl.S     Wed Aug 27 23:52:25 2003
11763 @@ -294,4 +294,5 @@
11764         .word solaris_unimplemented     /*                      264     */
11765         .word solaris_unimplemented     /*                      265     */
11766         .word solaris_unimplemented     /*                      266     */
11767 +       .word solaris_unimplemented     /*                      267     */
11768  
11769 diff -Nru a/arch/sparc64/solaris/timod.c b/arch/sparc64/solaris/timod.c
11770 --- a/arch/sparc64/solaris/timod.c      Fri Jun  6 04:40:53 2003
11771 +++ b/arch/sparc64/solaris/timod.c      Tue Aug 26 09:25:41 2003
11772 @@ -924,7 +924,7 @@
11773         if (!ino) goto out;
11774  
11775         if (!ino->i_sock &&
11776 -               (major(ino->i_rdev) != 30 || minor(ino->i_rdev) != 1))
11777 +               (imajor(ino) != 30 || iminor(ino) != 1))
11778                 goto out;
11779  
11780         ctlptr = (struct strbuf *)A(arg1);
11781 diff -Nru a/arch/v850/Kconfig b/arch/v850/Kconfig
11782 --- a/arch/v850/Kconfig Sat Aug  2 14:26:16 2003
11783 +++ b/arch/v850/Kconfig Sun Aug 31 16:14:22 2003
11784 @@ -262,14 +262,6 @@
11785  
11786  menu "Executable file formats"
11787  
11788 -config KCORE_AOUT
11789 -       bool
11790 -       default y
11791 -
11792 -config KCORE_ELF
11793 -       bool
11794 -       default y
11795 -
11796  source "fs/Kconfig.binfmt"
11797  
11798  endmenu
11799 diff -Nru a/arch/v850/kernel/vmlinux.lds.S b/arch/v850/kernel/vmlinux.lds.S
11800 --- a/arch/v850/kernel/vmlinux.lds.S    Mon Aug  4 20:42:12 2003
11801 +++ b/arch/v850/kernel/vmlinux.lds.S    Tue Aug 26 00:21:26 2003
11802 @@ -33,6 +33,30 @@
11803                         *(.intv.mach)   /* Machine-specific int. vectors.  */ \
11804                 __intv_end = . ;
11805  
11806 +#define RODATA_CONTENTS                                                              \
11807 +               . = ALIGN (16) ;                                              \
11808 +                       *(.rodata) *(.rodata.*)                               \
11809 +                       *(__vermagic)           /* Kernel version magic */    \
11810 +                       *(.rodata1)                                           \
11811 +               /* Kernel symbol table: Normal symbols */                     \
11812 +               ___start___ksymtab = .;                                       \
11813 +                       *(__ksymtab)                                          \
11814 +               ___stop___ksymtab = .;                                        \
11815 +               /* Kernel symbol table: GPL-only symbols */                   \
11816 +               ___start___ksymtab_gpl = .;                                   \
11817 +                       *(__ksymtab_gpl)                                      \
11818 +               ___stop___ksymtab_gpl = .;                                    \
11819 +               /* Kernel symbol table: strings */                            \
11820 +                       *(__ksymtab_strings)                                  \
11821 +               /* Kernel symbol table: Normal symbols */                     \
11822 +               ___start___kcrctab = .;                                       \
11823 +                       *(__kcrctab)                                          \
11824 +               ___stop___kcrctab = .;                                        \
11825 +               /* Kernel symbol table: GPL-only symbols */                   \
11826 +               ___start___kcrctab_gpl = .;                                   \
11827 +                       *(__kcrctab_gpl)                                      \
11828 +               ___stop___kcrctab_gpl = .;                                    \
11829 +
11830  /* Kernel text segment, and some constant data areas.  */
11831  #define TEXT_CONTENTS                                                        \
11832                 __stext = . ;                                                 \
11833 @@ -42,7 +66,7 @@
11834                         *(.text.lock)                                         \
11835                         *(.exitcall.exit)                                     \
11836                 __real_etext = . ;      /* There may be data after here.  */  \
11837 -               RODATA                                                        \
11838 +               RODATA_CONTENTS                                               \
11839                 . = ALIGN (4) ;                                               \
11840                         *(.call_table_data)                                   \
11841                         *(.call_table_text)                                   \
11842 diff -Nru a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
11843 --- a/arch/x86_64/Kconfig       Sat Aug  2 14:26:16 2003
11844 +++ b/arch/x86_64/Kconfig       Sun Aug 31 16:14:22 2003
11845 @@ -370,11 +370,6 @@
11846  
11847  menu "Executable file formats / Emulations"
11848  
11849 -config KCORE_ELF
11850 -       bool
11851 -       depends on PROC_FS
11852 -       default y
11853 -
11854  source "fs/Kconfig.binfmt"
11855  
11856  config IA32_EMULATION
11857 diff -Nru a/arch/x86_64/defconfig b/arch/x86_64/defconfig
11858 --- a/arch/x86_64/defconfig     Sat Aug  9 07:53:46 2003
11859 +++ b/arch/x86_64/defconfig     Sat Aug 23 04:57:05 2003
11860 @@ -14,6 +14,7 @@
11861  # Code maturity level options
11862  #
11863  CONFIG_EXPERIMENTAL=y
11864 +# CONFIG_BROKEN is not set
11865  
11866  #
11867  # General setup
11868 @@ -23,10 +24,12 @@
11869  # CONFIG_BSD_PROCESS_ACCT is not set
11870  CONFIG_SYSCTL=y
11871  CONFIG_LOG_BUF_SHIFT=18
11872 +# CONFIG_IKCONFIG is not set
11873  # CONFIG_EMBEDDED is not set
11874  CONFIG_KALLSYMS=y
11875  CONFIG_FUTEX=y
11876  CONFIG_EPOLL=y
11877 +CONFIG_IOSCHED_NOOP=y
11878  CONFIG_IOSCHED_AS=y
11879  CONFIG_IOSCHED_DEADLINE=y
11880  
11881 @@ -72,10 +75,10 @@
11882  CONFIG_SOFTWARE_SUSPEND=y
11883  
11884  #
11885 -# ACPI Support
11886 +# ACPI (Advanced Configuration and Power Interface) Support
11887  #
11888 +# CONFIG_ACPI_HT is not set
11889  CONFIG_ACPI=y
11890 -# CONFIG_ACPI_HT_ONLY is not set
11891  CONFIG_ACPI_BOOT=y
11892  CONFIG_ACPI_SLEEP=y
11893  CONFIG_ACPI_SLEEP_PROC_FS=y
11894 @@ -117,7 +120,6 @@
11895  #
11896  # Generic Driver Options
11897  #
11898 -# CONFIG_FW_LOADER is not set
11899  
11900  #
11901  # Memory Technology Devices (MTD)
11902 @@ -159,6 +161,7 @@
11903  CONFIG_IDEDISK_MULTI_MODE=y
11904  # CONFIG_IDEDISK_STROKE is not set
11905  CONFIG_BLK_DEV_IDECD=y
11906 +# CONFIG_BLK_DEV_IDETAPE is not set
11907  # CONFIG_BLK_DEV_IDEFLOPPY is not set
11908  # CONFIG_BLK_DEV_IDESCSI is not set
11909  # CONFIG_IDE_TASK_IOCTL is not set
11910 @@ -318,7 +321,6 @@
11911  # CONFIG_DECNET is not set
11912  # CONFIG_BRIDGE is not set
11913  # CONFIG_NETFILTER is not set
11914 -# CONFIG_XFRM_USER is not set
11915  
11916  #
11917  # SCTP Configuration (EXPERIMENTAL)
11918 @@ -405,6 +407,7 @@
11919  # CONFIG_HAMACHI is not set
11920  # CONFIG_YELLOWFIN is not set
11921  # CONFIG_R8169 is not set
11922 +# CONFIG_SIS190 is not set
11923  # CONFIG_SK98LIN is not set
11924  CONFIG_TIGON3=y
11925  
11926 @@ -595,10 +598,7 @@
11927  CONFIG_REISERFS_FS=y
11928  # CONFIG_REISERFS_CHECK is not set
11929  # CONFIG_REISERFS_PROC_INFO is not set
11930 -CONFIG_JFS_FS=y
11931 -CONFIG_JFS_POSIX_ACL=y
11932 -# CONFIG_JFS_DEBUG is not set
11933 -# CONFIG_JFS_STATISTICS is not set
11934 +# CONFIG_JFS_FS is not set
11935  CONFIG_FS_POSIX_ACL=y
11936  # CONFIG_XFS_FS is not set
11937  # CONFIG_MINIX_FS is not set
11938 @@ -674,49 +674,6 @@
11939  #
11940  # CONFIG_PARTITION_ADVANCED is not set
11941  CONFIG_MSDOS_PARTITION=y
11942 -CONFIG_NLS=y
11943 -
11944 -#
11945 -# Native Language Support
11946 -#
11947 -CONFIG_NLS_DEFAULT="iso8859-1"
11948 -# CONFIG_NLS_CODEPAGE_437 is not set
11949 -# CONFIG_NLS_CODEPAGE_737 is not set
11950 -# CONFIG_NLS_CODEPAGE_775 is not set
11951 -# CONFIG_NLS_CODEPAGE_850 is not set
11952 -# CONFIG_NLS_CODEPAGE_852 is not set
11953 -# CONFIG_NLS_CODEPAGE_855 is not set
11954 -# CONFIG_NLS_CODEPAGE_857 is not set
11955 -# CONFIG_NLS_CODEPAGE_860 is not set
11956 -# CONFIG_NLS_CODEPAGE_861 is not set
11957 -# CONFIG_NLS_CODEPAGE_862 is not set
11958 -# CONFIG_NLS_CODEPAGE_863 is not set
11959 -# CONFIG_NLS_CODEPAGE_864 is not set
11960 -# CONFIG_NLS_CODEPAGE_865 is not set
11961 -# CONFIG_NLS_CODEPAGE_866 is not set
11962 -# CONFIG_NLS_CODEPAGE_869 is not set
11963 -# CONFIG_NLS_CODEPAGE_936 is not set
11964 -# CONFIG_NLS_CODEPAGE_950 is not set
11965 -# CONFIG_NLS_CODEPAGE_932 is not set
11966 -# CONFIG_NLS_CODEPAGE_949 is not set
11967 -# CONFIG_NLS_CODEPAGE_874 is not set
11968 -# CONFIG_NLS_ISO8859_8 is not set
11969 -# CONFIG_NLS_CODEPAGE_1250 is not set
11970 -# CONFIG_NLS_CODEPAGE_1251 is not set
11971 -# CONFIG_NLS_ISO8859_1 is not set
11972 -# CONFIG_NLS_ISO8859_2 is not set
11973 -# CONFIG_NLS_ISO8859_3 is not set
11974 -# CONFIG_NLS_ISO8859_4 is not set
11975 -# CONFIG_NLS_ISO8859_5 is not set
11976 -# CONFIG_NLS_ISO8859_6 is not set
11977 -# CONFIG_NLS_ISO8859_7 is not set
11978 -# CONFIG_NLS_ISO8859_9 is not set
11979 -# CONFIG_NLS_ISO8859_13 is not set
11980 -# CONFIG_NLS_ISO8859_14 is not set
11981 -# CONFIG_NLS_ISO8859_15 is not set
11982 -# CONFIG_NLS_KOI8_R is not set
11983 -# CONFIG_NLS_KOI8_U is not set
11984 -# CONFIG_NLS_UTF8 is not set
11985  
11986  #
11987  # Graphics support
11988 diff -Nru a/arch/x86_64/ia32/ia32_ioctl.c b/arch/x86_64/ia32/ia32_ioctl.c
11989 --- a/arch/x86_64/ia32/ia32_ioctl.c     Fri Jul 11 05:14:13 2003
11990 +++ b/arch/x86_64/ia32/ia32_ioctl.c     Sun Aug 31 16:14:44 2003
11991 @@ -673,12 +673,10 @@
11992         return err;
11993  } 
11994  
11995 -#define REF_SYMBOL(handler) if (0) (void)handler;
11996 -#define HANDLE_IOCTL2(cmd,handler) REF_SYMBOL(handler);  asm volatile(".quad %P0, " #handler ",0"::"i" (cmd)); 
11997 -#define HANDLE_IOCTL(cmd,handler) HANDLE_IOCTL2(cmd,handler)
11998 +#define HANDLE_IOCTL(cmd,handler) { (cmd), (ioctl_trans_handler_t)(handler), NULL },
11999  #define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL(cmd,sys_ioctl)
12000 -#define IOCTL_TABLE_START void ioctl_dummy(void) { asm volatile("\n.global ioctl_start\nioctl_start:\n\t" );
12001 -#define IOCTL_TABLE_END  asm volatile("\n.global ioctl_end;\nioctl_end:\n"); }
12002 +#define IOCTL_TABLE_START struct ioctl_trans ioctl_start[] = {
12003 +#define IOCTL_TABLE_END  };
12004  
12005  IOCTL_TABLE_START
12006  #include <linux/compat_ioctl.h>
12007 @@ -765,3 +763,4 @@
12008  HANDLE_IOCTL(MTRRIOC32_KILL_PAGE_ENTRY, mtrr_ioctl32)
12009  IOCTL_TABLE_END
12010  
12011 +int ioctl_table_size = ARRAY_SIZE(ioctl_start);
12012 diff -Nru a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c
12013 --- a/arch/x86_64/ia32/sys_ia32.c       Mon Jul 14 04:19:39 2003
12014 +++ b/arch/x86_64/ia32/sys_ia32.c       Sun Aug 31 05:33:07 2003
12015 @@ -1170,8 +1170,6 @@
12016         return ret;
12017  }
12018  
12019 -extern void check_pending(int signum);
12020 -
12021  asmlinkage long sys_utimes(char *, struct timeval *);
12022  
12023  asmlinkage long
12024 diff -Nru a/arch/x86_64/kernel/apic.c b/arch/x86_64/kernel/apic.c
12025 --- a/arch/x86_64/kernel/apic.c Mon Aug 18 19:46:23 2003
12026 +++ b/arch/x86_64/kernel/apic.c Sat Aug 23 05:13:33 2003
12027 @@ -299,7 +299,7 @@
12028          * This is meaningless in clustered apic mode, so we skip it.
12029          */
12030         if (!clustered_apic_mode &&
12031 -               !cpu_isset(GET_APIC_ID(apic_read(APIC_ID)), phys_cpu_present_map))
12032 +               !physid_isset(GET_APIC_ID(apic_read(APIC_ID)), phys_cpu_present_map))
12033                 BUG();
12034  
12035         /*
12036 @@ -993,7 +993,7 @@
12037  
12038         connect_bsp_APIC();
12039  
12040 -       phys_cpu_present_map = cpumask_of_cpu(0);
12041 +       phys_cpu_present_map = physid_mask_of_physid(0);
12042         apic_write_around(APIC_ID, boot_cpu_id);
12043  
12044         setup_local_APIC();
12045 diff -Nru a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
12046 --- a/arch/x86_64/kernel/io_apic.c      Tue Aug 19 07:45:10 2003
12047 +++ b/arch/x86_64/kernel/io_apic.c      Sat Aug 23 05:13:33 2003
12048 @@ -1014,7 +1014,7 @@
12049  static void __init setup_ioapic_ids_from_mpc (void)
12050  {
12051         union IO_APIC_reg_00 reg_00;
12052 -       cpumask_t phys_id_present_map = phys_cpu_present_map;
12053 +       physid_mask_t phys_id_present_map = phys_cpu_present_map;
12054         int apic;
12055         int i;
12056         unsigned char old_id;
12057 @@ -1047,22 +1047,22 @@
12058                  * system must have a unique ID or we get lots of nice
12059                  * 'stuck on smp_invalidate_needed IPI wait' messages.
12060                  */
12061 -               if (cpu_isset(mp_ioapics[apic].mpc_apicid, phys_id_present_map)) {
12062 +               if (physid_isset(mp_ioapics[apic].mpc_apicid, phys_id_present_map)) {
12063                         printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n",
12064                                 apic, mp_ioapics[apic].mpc_apicid);
12065                         for (i = 0; i < 0xf; i++)
12066 -                               if (!cpu_isset(i, phys_id_present_map))
12067 +                               if (!physid_isset(i, phys_id_present_map))
12068                                         break;
12069                         if (i >= 0xf)
12070                                 panic("Max APIC ID exceeded!\n");
12071                         printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n",
12072                                 i);
12073 -                       cpu_set(i, phys_id_present_map);
12074 +                       physid_set(i, phys_id_present_map);
12075                         mp_ioapics[apic].mpc_apicid = i;
12076                 } else {
12077                         printk(KERN_INFO 
12078                                "Using IO-APIC %d\n", mp_ioapics[apic].mpc_apicid);
12079 -                       cpu_set(mp_ioapics[apic].mpc_apicid, phys_id_present_map);
12080 +                       physid_set(mp_ioapics[apic].mpc_apicid, phys_id_present_map);
12081                 }
12082  
12083  
12084 @@ -1642,7 +1642,7 @@
12085  int __init io_apic_get_unique_id (int ioapic, int apic_id)
12086  {
12087         union IO_APIC_reg_00 reg_00;
12088 -       static cpumask_t apic_id_map;
12089 +       static physid_mask_t apic_id_map;
12090         unsigned long flags;
12091         int i = 0;
12092  
12093 @@ -1655,7 +1655,7 @@
12094          *      advantage of new APIC bus architecture.
12095          */
12096  
12097 -       if (!cpus_empty(apic_id_map))
12098 +       if (!physids_empty(apic_id_map))
12099                 apic_id_map = phys_cpu_present_map;
12100  
12101         spin_lock_irqsave(&ioapic_lock, flags);
12102 @@ -1672,10 +1672,10 @@
12103          * Every APIC in a system must have a unique ID or we get lots of nice 
12104          * 'stuck on smp_invalidate_needed IPI wait' messages.
12105          */
12106 -       if (cpu_isset(apic_id, apic_id_map)) {
12107 +       if (physid_isset(apic_id, apic_id_map)) {
12108  
12109                 for (i = 0; i < IO_APIC_MAX_ID; i++) {
12110 -                       if (!cpu_isset(i, apic_id_map))
12111 +                       if (!physid_isset(i, apic_id_map))
12112                                 break;
12113                 }
12114  
12115 @@ -1688,7 +1688,7 @@
12116                 apic_id = i;
12117         } 
12118  
12119 -       cpu_set(apic_id, apic_id_map);
12120 +       physid_set(apic_id, apic_id_map);
12121  
12122         if (reg_00.bits.ID != apic_id) {
12123                 reg_00.bits.ID = apic_id;
12124 diff -Nru a/arch/x86_64/kernel/ioport.c b/arch/x86_64/kernel/ioport.c
12125 --- a/arch/x86_64/kernel/ioport.c       Wed Aug 20 10:43:52 2003
12126 +++ b/arch/x86_64/kernel/ioport.c       Sat Aug 23 05:03:34 2003
12127 @@ -10,12 +10,11 @@
12128  #include <linux/errno.h>
12129  #include <linux/types.h>
12130  #include <linux/ioport.h>
12131 -#include <linux/mm.h>
12132  #include <linux/smp.h>
12133  #include <linux/smp_lock.h>
12134  #include <linux/stddef.h>
12135  #include <linux/slab.h>
12136 -#include <asm/io.h>
12137 +#include <linux/thread_info.h>
12138  
12139  /* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */
12140  static void set_bitmap(unsigned long *bitmap, unsigned int base, unsigned int extent, int new_value)
12141 @@ -118,12 +117,7 @@
12142                         return -EPERM;
12143         }
12144         regs.eflags = (regs.eflags &~ 0x3000UL) | (level << 12);
12145 +       /* Make sure we return the long way (not sysenter) */
12146 +       set_thread_flag(TIF_IRET);
12147         return 0;
12148  }
12149 -
12150 -void eat_key(void)
12151 -{
12152 -       if (inb(0x60) & 1) 
12153 -               inb(0x64);
12154 -}
12155 -
12156 diff -Nru a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c
12157 --- a/arch/x86_64/kernel/mpparse.c      Tue Aug 19 07:45:28 2003
12158 +++ b/arch/x86_64/kernel/mpparse.c      Sat Aug 23 05:13:33 2003
12159 @@ -67,7 +67,7 @@
12160  static unsigned int num_processors = 0;
12161  
12162  /* Bitmask of physically existing CPUs */
12163 -cpumask_t phys_cpu_present_map = CPU_MASK_NONE;
12164 +physid_mask_t phys_cpu_present_map = PHYSID_MASK_NONE;
12165  
12166  /* ACPI MADT entry parsing functions */
12167  #ifdef CONFIG_ACPI_BOOT
12168 @@ -126,7 +126,7 @@
12169         }
12170         ver = m->mpc_apicver;
12171  
12172 -       cpu_set(m->mpc_apicid, phys_cpu_present_map);
12173 +       physid_set(m->mpc_apicid, phys_cpu_present_map);
12174         /*
12175          * Validate version
12176          */
12177 diff -Nru a/arch/x86_64/kernel/msr.c b/arch/x86_64/kernel/msr.c
12178 --- a/arch/x86_64/kernel/msr.c  Mon Aug 18 19:46:23 2003
12179 +++ b/arch/x86_64/kernel/msr.c  Tue Aug 26 09:25:40 2003
12180 @@ -194,7 +194,7 @@
12181    u32 data[2];
12182    size_t rv;
12183    u32 reg = *ppos;
12184 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
12185 +  int cpu = iminor(file->f_dentry->d_inode);
12186    int err;
12187  
12188    if ( count % 8 )
12189 @@ -219,7 +219,7 @@
12190    u32 data[2];
12191    size_t rv;
12192    u32 reg = *ppos;
12193 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
12194 +  int cpu = iminor(file->f_dentry->d_inode);
12195    int err;
12196  
12197    if ( count % 8 )
12198 @@ -239,7 +239,7 @@
12199  
12200  static int msr_open(struct inode *inode, struct file *file)
12201  {
12202 -  int cpu = minor(file->f_dentry->d_inode->i_rdev);
12203 +  int cpu = iminor(file->f_dentry->d_inode);
12204    struct cpuinfo_x86 *c = &(cpu_data)[cpu];
12205    
12206    if (!cpu_online(cpu))
12207 diff -Nru a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
12208 --- a/arch/x86_64/kernel/setup.c        Mon Aug 18 19:46:23 2003
12209 +++ b/arch/x86_64/kernel/setup.c        Sat Aug 23 04:55:48 2003
12210 @@ -243,6 +243,8 @@
12211  
12212  void __init setup_arch(char **cmdline_p)
12213  {
12214 +       unsigned long low_mem_size;
12215 +
12216         ROOT_DEV = ORIG_ROOT_DEV;
12217         drive_info = DRIVE_INFO;
12218         screen_info = SCREEN_INFO;
12219 @@ -378,7 +380,13 @@
12220                 request_resource(&ioport_resource, standard_io_resources+i);
12221         }
12222  
12223 -       pci_mem_start = IOMAP_START; 
12224 +       /* Will likely break when you have unassigned resources with more
12225 +          than 4GB memory and bridges that don't support more than 4GB. 
12226 +          Doing it properly would require to allocate GFP_DMA memory
12227 +          in this case. */
12228 +       low_mem_size = ((end_pfn << PAGE_SHIFT) + 0xfffff) & ~0xfffff;
12229 +       if (low_mem_size > pci_mem_start)
12230 +               pci_mem_start = low_mem_size;
12231  
12232  #ifdef CONFIG_GART_IOMMU
12233         iommu_hole_init();
12234 diff -Nru a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
12235 --- a/arch/x86_64/kernel/smpboot.c      Mon Aug 18 19:46:23 2003
12236 +++ b/arch/x86_64/kernel/smpboot.c      Sat Aug 23 05:13:33 2003
12237 @@ -734,10 +734,10 @@
12238         current_thread_info()->cpu = 0;
12239         smp_tune_scheduling();
12240  
12241 -       if (!cpu_isset(hard_smp_processor_id(), phys_cpu_present_map)) {
12242 +       if (!physid_isset(hard_smp_processor_id(), phys_cpu_present_map)) {
12243                 printk("weird, boot CPU (#%d) not listed by the BIOS.\n",
12244                        hard_smp_processor_id());
12245 -               cpu_set(hard_smp_processor_id(), phys_cpu_present_map);
12246 +               physid_set(hard_smp_processor_id(), phys_cpu_present_map);
12247         }
12248  
12249         /*
12250 @@ -748,7 +748,7 @@
12251                 printk(KERN_NOTICE "SMP motherboard not detected.\n");
12252                 io_apic_irqs = 0;
12253                 cpu_online_map = cpumask_of_cpu(0);
12254 -               phys_cpu_present_map = cpumask_of_cpu(0);
12255 +               phys_cpu_present_map = physid_mask_of_physid(0);
12256                 if (APIC_init_uniprocessor())
12257                         printk(KERN_NOTICE "Local APIC not detected."
12258                                            " Using dummy APIC emulation.\n");
12259 @@ -759,10 +759,10 @@
12260          * Should not be necessary because the MP table should list the boot
12261          * CPU too, but we do it for the sake of robustness anyway.
12262          */
12263 -       if (!cpu_isset(boot_cpu_id, phys_cpu_present_map)) {
12264 +       if (!physid_isset(boot_cpu_id, phys_cpu_present_map)) {
12265                 printk(KERN_NOTICE "weird, boot CPU (#%d) not listed by the BIOS.\n",
12266                                                                  boot_cpu_id);
12267 -               cpu_set(hard_smp_processor_id(), phys_cpu_present_map);
12268 +               physid_set(hard_smp_processor_id(), phys_cpu_present_map);
12269         }
12270  
12271         /*
12272 @@ -774,7 +774,7 @@
12273                 printk(KERN_ERR "... forcing use of dummy APIC emulation. (tell your hw vendor)\n");
12274                 io_apic_irqs = 0;
12275                 cpu_online_map = cpumask_of_cpu(0);
12276 -               phys_cpu_present_map = cpumask_of_cpu(0);
12277 +               phys_cpu_present_map = physid_mask_of_physid(0);
12278                 disable_apic = 1;
12279                 goto smp_done;
12280         }
12281 @@ -789,7 +789,7 @@
12282                 printk(KERN_INFO "SMP mode deactivated, forcing use of dummy APIC emulation.\n");
12283                 io_apic_irqs = 0;
12284                 cpu_online_map = cpumask_of_cpu(0);
12285 -               phys_cpu_present_map = cpumask_of_cpu(0);
12286 +               phys_cpu_present_map = physid_mask_of_physid(0);
12287                 disable_apic = 1;
12288                 goto smp_done;
12289         }
12290 @@ -803,7 +803,7 @@
12291         /*
12292          * Now scan the CPU present map and fire up the other CPUs.
12293          */
12294 -       Dprintk("CPU present map: %lx\n", phys_cpu_present_map);
12295 +       Dprintk("CPU present map: %lx\n", physids_coerce(phys_cpu_present_map));
12296  
12297         for (apicid = 0; apicid < NR_CPUS; apicid++) {
12298                 /*
12299 diff -Nru a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
12300 --- a/arch/x86_64/kernel/time.c Thu Jul 10 22:22:57 2003
12301 +++ b/arch/x86_64/kernel/time.c Sat Aug 23 04:31:18 2003
12302 @@ -79,6 +79,7 @@
12303         unsigned long t;
12304         unsigned long x;
12305         rdtscll_sync(&t);
12306 +       if (t < vxtime.last_tsc) t = vxtime.last_tsc; /* hack */
12307         x = ((t - vxtime.last_tsc) * vxtime.tsc_quot) >> 32;
12308         return x;
12309  }
12310 diff -Nru a/arch/x86_64/kernel/vsyscall.c b/arch/x86_64/kernel/vsyscall.c
12311 --- a/arch/x86_64/kernel/vsyscall.c     Fri Jun 13 01:16:29 2003
12312 +++ b/arch/x86_64/kernel/vsyscall.c     Sat Aug 23 04:31:40 2003
12313 @@ -85,6 +85,7 @@
12314                 if (__vxtime.mode == VXTIME_TSC) {
12315                         sync_core();
12316                         rdtscll(t);
12317 +                       if (t < __vxtime.last_tsc) t = __vxtime.last_tsc;
12318                         usec += ((t - __vxtime.last_tsc) *
12319                                  __vxtime.tsc_quot) >> 32;
12320                 } else {
12321 diff -Nru a/drivers/Makefile b/drivers/Makefile
12322 --- a/drivers/Makefile  Tue Aug 12 08:42:21 2003
12323 +++ b/drivers/Makefile  Sun Aug 24 07:59:26 2003
12324 @@ -20,6 +20,7 @@
12325  obj-y                          += base/ block/ misc/ net/ media/
12326  obj-$(CONFIG_NUBUS)            += nubus/
12327  obj-$(CONFIG_ATM)              += atm/
12328 +obj-$(CONFIG_PPC_PMAC)         += macintosh/
12329  obj-$(CONFIG_IDE)              += ide/
12330  obj-$(CONFIG_FC4)              += fc4/
12331  obj-$(CONFIG_SCSI)             += scsi/
12332 @@ -31,7 +32,6 @@
12333  obj-$(CONFIG_DIO)              += dio/
12334  obj-$(CONFIG_SBUS)             += sbus/
12335  obj-$(CONFIG_ZORRO)            += zorro/
12336 -obj-$(CONFIG_PPC_PMAC)         += macintosh/
12337  obj-$(CONFIG_MAC)              += macintosh/
12338  obj-$(CONFIG_PARIDE)           += block/paride/
12339  obj-$(CONFIG_TC)               += tc/
12340 diff -Nru a/drivers/acorn/block/fd1772.c b/drivers/acorn/block/fd1772.c
12341 --- a/drivers/acorn/block/fd1772.c      Thu Aug  7 02:25:23 2003
12342 +++ b/drivers/acorn/block/fd1772.c      Tue Aug 26 09:25:40 2003
12343 @@ -1455,8 +1455,8 @@
12344  
12345  static int floppy_open(struct inode *inode, struct file *filp)
12346  {
12347 -       int drive = minor(inode->i_rdev) & 3;
12348 -       int type =  minor(inode->i_rdev) >> 2;
12349 +       int drive = iminor(inode) & 3;
12350 +       int type =  iminor(inode) >> 2;
12351         int old_dev = fd_device[drive];
12352  
12353         if (fd_ref[drive] && old_dev != type)
12354 @@ -1490,7 +1490,7 @@
12355  
12356  static int floppy_release(struct inode *inode, struct file *filp)
12357  {
12358 -       int drive = minor(inode->i_rdev) & 3;
12359 +       int drive = iminor(inode) & 3;
12360  
12361         if (fd_ref[drive] < 0)
12362                 fd_ref[drive] = 0;
12363 diff -Nru a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
12364 --- a/drivers/acpi/Kconfig      Wed Aug 20 09:06:49 2003
12365 +++ b/drivers/acpi/Kconfig      Sat Aug 23 04:07:34 2003
12366 @@ -69,6 +69,7 @@
12367         bool "Sleep States (EXPERIMENTAL)"
12368         depends on X86 && ACPI
12369         depends on EXPERIMENTAL && PM
12370 +       select SOFTWARE_SUSPEND
12371         default y
12372         ---help---
12373           This option adds support for ACPI suspend states. 
12374 diff -Nru a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
12375 --- a/drivers/acpi/pci_link.c   Tue Jul 29 13:28:29 2003
12376 +++ b/drivers/acpi/pci_link.c   Sun Aug 31 16:14:25 2003
12377 @@ -516,9 +516,8 @@
12378                 return_VALUE(0);
12379         }
12380  
12381 -       if (acpi_pci_link_allocate(link)) {
12382 -               return -ENODEV;
12383 -       }
12384 +       if (acpi_pci_link_allocate(link))
12385 +               return_VALUE(0);
12386            
12387         if (!link->irq.active) {
12388                 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link disabled\n"));
12389 diff -Nru a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
12390 --- a/drivers/atm/ambassador.c  Tue Aug 19 21:10:45 2003
12391 +++ b/drivers/atm/ambassador.c  Wed Aug 27 23:17:10 2003
12392 @@ -310,10 +310,11 @@
12393    0xdeadbeef
12394  };
12395  
12396 +static void do_housekeeping (unsigned long arg);
12397  /********** globals **********/
12398  
12399  static amb_dev * amb_devs = NULL;
12400 -static struct timer_list housekeeping;
12401 +static struct timer_list housekeeping = TIMER_INITIALIZER(do_housekeeping, 0, 1);
12402  
12403  static unsigned short debug = 0;
12404  static unsigned int cmds = 8;
12405 @@ -937,63 +938,6 @@
12406    return IRQ_HANDLED;
12407  }
12408  
12409 -/********** don't panic... yeah, right **********/
12410 -
12411 -#ifdef DEBUG_AMBASSADOR
12412 -static void dont_panic (amb_dev * dev) {
12413 -  amb_cq * cq = &dev->cq;
12414 -  volatile amb_cq_ptrs * ptrs = &cq->ptrs;
12415 -  amb_txq * txq;
12416 -  amb_rxq * rxq;
12417 -  command * cmd;
12418 -  tx_in * tx;
12419 -  tx_simple * tx_descr;
12420 -  unsigned char pool;
12421 -  rx_in * rx;
12422 -  
12423 -  unsigned long flags;
12424 -  save_flags (flags);
12425 -  cli();
12426 -  
12427 -  PRINTK (KERN_INFO, "don't panic - putting adapter into reset");
12428 -  wr_plain (dev, offsetof(amb_mem, reset_control),
12429 -           rd_plain (dev, offsetof(amb_mem, reset_control)) | AMB_RESET_BITS);
12430 -  
12431 -  PRINTK (KERN_INFO, "marking all commands complete");
12432 -  for (cmd = ptrs->start; cmd < ptrs->limit; ++cmd)
12433 -    cmd->request = cpu_to_be32 (SRB_COMPLETE);
12434 -
12435 -  PRINTK (KERN_INFO, "completing all TXs");
12436 -  txq = &dev->txq;
12437 -  tx = txq->in.ptr;
12438 -  while (txq->pending--) {
12439 -    if (tx == txq->in.start)
12440 -      tx = txq->in.limit;
12441 -    --tx;
12442 -    tx_descr = bus_to_virt (be32_to_cpu (tx->tx_descr_addr));
12443 -    amb_kfree_skb (tx_descr->skb);
12444 -    kfree (tx_descr);
12445 -  }
12446 -  
12447 -  PRINTK (KERN_INFO, "freeing all RX buffers");
12448 -  for (pool = 0; pool < NUM_RX_POOLS; ++pool) {
12449 -    rxq = &dev->rxq[pool];
12450 -    rx = rxq->in.ptr;
12451 -    while (rxq->pending--) {
12452 -      if (rx == rxq->in.start)
12453 -       rx = rxq->in.limit;
12454 -      --rx;
12455 -      dev_kfree_skb_any (bus_to_virt (rx->handle));
12456 -    }
12457 -  }
12458 -  
12459 -  PRINTK (KERN_INFO, "don't panic over - close all VCs and rmmod");
12460 -  set_bit (dead, &dev->flags);
12461 -  restore_flags (flags);
12462 -  return;
12463 -}
12464 -#endif
12465 -
12466  /********** make rate (not quite as much fun as Horizon) **********/
12467  
12468  static unsigned int make_rate (unsigned int rate, rounding r,
12469 @@ -1420,32 +1364,6 @@
12470    return;
12471  }
12472  
12473 -/********** Debug\17Ioctl **********/
12474 -
12475 -#if 0
12476 -static int amb_ioctl (struct atm_dev * dev, unsigned int cmd, void * arg) {
12477 -  unsigned short newdebug;
12478 -  if (cmd == AMB_SETDEBUG) {
12479 -    if (!capable(CAP_NET_ADMIN))
12480 -      return -EPERM;
12481 -    if (copy_from_user (&newdebug, arg, sizeof(newdebug))) {
12482 -      // moan
12483 -      return -EFAULT;
12484 -    } else {
12485 -      debug = newdebug;
12486 -      return 0;
12487 -    }
12488 -  } else if (cmd == AMB_DONTPANIC) {
12489 -    if (!capable(CAP_NET_ADMIN))
12490 -      return -EPERM;
12491 -    dont_panic (dev);
12492 -  } else {
12493 -    // moan
12494 -    return -ENOIOCTLCMD;
12495 -  }
12496 -}
12497 -#endif
12498 -
12499  /********** Set socket options for a VC **********/
12500  
12501  // int amb_getsockopt (struct atm_vcc * atm_vcc, int level, int optname, void * optval, int optlen);
12502 @@ -1524,33 +1442,6 @@
12503    tx.tx_descr_length = cpu_to_be16 (sizeof(tx_frag)+sizeof(tx_frag_end));
12504    tx.tx_descr_addr = cpu_to_be32 (virt_to_bus (&tx_descr->tx_frag));
12505    
12506 -#ifdef DEBUG_AMBASSADOR
12507 -  /* wey-hey! */
12508 -  if (vc == 1023) {
12509 -    unsigned int i;
12510 -    unsigned short d = 0;
12511 -    char * s = skb->data;
12512 -    switch (*s++) {
12513 -      case 'D': {
12514 -       for (i = 0; i < 4; ++i) {
12515 -         d = (d<<4) | ((*s <= '9') ? (*s - '0') : (*s - 'a' + 10));
12516 -         ++s;
12517 -       }
12518 -       PRINTK (KERN_INFO, "debug bitmap is now %hx", debug = d);
12519 -       break;
12520 -      }
12521 -      case 'R': {
12522 -       if (*s++ == 'e' && *s++ == 's' && *s++ == 'e' && *s++ == 't')
12523 -         dont_panic (dev);
12524 -       break;
12525 -      }
12526 -      default: {
12527 -       break;
12528 -      }
12529 -    }
12530 -  }
12531 -#endif
12532 -  
12533    while (tx_give (dev, &tx))
12534      schedule();
12535    return 0;
12536 @@ -1663,21 +1554,14 @@
12537  /********** Operation Structure **********/
12538  
12539  static const struct atmdev_ops amb_ops = {
12540 -  .open        = amb_open,
12541 +  .open         = amb_open,
12542    .close       = amb_close,
12543 -  .send        = amb_send,
12544 +  .send         = amb_send,
12545    .proc_read   = amb_proc_read,
12546    .owner       = THIS_MODULE,
12547  };
12548  
12549  /********** housekeeping **********/
12550 -
12551 -static inline void set_timer (struct timer_list * timer, unsigned long delay) {
12552 -  timer->expires = jiffies + delay;
12553 -  add_timer (timer);
12554 -  return;
12555 -}
12556 -
12557  static void do_housekeeping (unsigned long arg) {
12558    amb_dev * dev = amb_devs;
12559    // data is set to zero at module unload
12560 @@ -1693,7 +1577,7 @@
12561        
12562        dev = dev->prev;
12563      }
12564 -    set_timer (&housekeeping, 10*HZ);
12565 +    mod_timer(&housekeeping, jiffies + 10*HZ);
12566    }
12567    
12568    return;
12569 @@ -2579,11 +2463,7 @@
12570    devs = amb_probe();
12571    
12572    if (devs) {
12573 -    init_timer (&housekeeping);
12574 -    housekeeping.function = do_housekeeping;
12575 -    // paranoia
12576 -    housekeeping.data = 1;
12577 -    set_timer (&housekeeping, 0);
12578 +    mod_timer (&housekeeping, jiffies);
12579    } else {
12580      PRINTK (KERN_INFO, "no (usable) adapters found");
12581    }
12582 @@ -2600,7 +2480,7 @@
12583    
12584    // paranoia
12585    housekeeping.data = 0;
12586 -  del_timer (&housekeeping);
12587 +  del_timer_sync(&housekeeping);
12588    
12589    while (amb_devs) {
12590      dev = amb_devs;
12591 diff -Nru a/drivers/atm/eni.c b/drivers/atm/eni.c
12592 --- a/drivers/atm/eni.c Tue Aug 19 21:10:45 2003
12593 +++ b/drivers/atm/eni.c Mon Sep  1 08:23:55 2003
12594 @@ -1809,10 +1809,6 @@
12595                     "master (0x%02x)\n",dev->number,error);
12596                 return error;
12597         }
12598 -#ifdef __sparc_v9__ /* copied from drivers/net/sunhme.c */
12599 -       /* NOTE: Cache line size is in 32-bit word units. */
12600 -       pci_write_config_byte(eni_dev->pci_dev, PCI_CACHE_LINE_SIZE, 0x10);
12601 -#endif
12602         if ((error = pci_write_config_byte(eni_dev->pci_dev,PCI_TONGA_CTRL,
12603             END_SWAP_DMA))) {
12604                 printk(KERN_ERR DEV_LABEL "(itf %d): can't set endian swap "
12605 @@ -2345,7 +2341,7 @@
12606         struct sk_buff *skb; /* dummy for sizeof */
12607  
12608         if (sizeof(skb->cb) < sizeof(struct eni_skb_prv)) {
12609 -               printk(KERN_ERR "eni_detect: skb->cb is too small (%d < %d)\n",
12610 +               printk(KERN_ERR "eni_detect: skb->cb is too small (%Zd < %Zd)\n",
12611                     sizeof(skb->cb),sizeof(struct eni_skb_prv));
12612                 return -EIO;
12613         }
12614 diff -Nru a/drivers/atm/firestream.c b/drivers/atm/firestream.c
12615 --- a/drivers/atm/firestream.c  Tue Aug 19 21:10:45 2003
12616 +++ b/drivers/atm/firestream.c  Sun Aug 31 16:14:27 2003
12617 @@ -895,7 +895,7 @@
12618         /* XXX handle qos parameters (rate limiting) ? */
12619  
12620         vcc = kmalloc(sizeof(struct fs_vcc), GFP_KERNEL);
12621 -       fs_dprintk (FS_DEBUG_ALLOC, "Alloc VCC: %p(%d)\n", vcc, sizeof(struct fs_vcc));
12622 +       fs_dprintk (FS_DEBUG_ALLOC, "Alloc VCC: %p(%Zd)\n", vcc, sizeof(struct fs_vcc));
12623         if (!vcc) {
12624                 clear_bit(ATM_VF_ADDR, &atm_vcc->flags);
12625                 return -ENOMEM;
12626 @@ -946,7 +946,7 @@
12627  
12628         if (DO_DIRECTION (txtp)) {
12629                 tc = kmalloc (sizeof (struct fs_transmit_config), GFP_KERNEL);
12630 -               fs_dprintk (FS_DEBUG_ALLOC, "Alloc tc: %p(%d)\n", 
12631 +               fs_dprintk (FS_DEBUG_ALLOC, "Alloc tc: %p(%Zd)\n",
12632                             tc, sizeof (struct fs_transmit_config));
12633                 if (!tc) {
12634                         fs_dprintk (FS_DEBUG_OPEN, "fs: can't alloc transmit_config.\n");
12635 @@ -1180,7 +1180,7 @@
12636         vcc->last_skb = skb;
12637  
12638         td = kmalloc (sizeof (struct FS_BPENTRY), GFP_ATOMIC);
12639 -       fs_dprintk (FS_DEBUG_ALLOC, "Alloc transd: %p(%d)\n", td, sizeof (struct FS_BPENTRY));
12640 +       fs_dprintk (FS_DEBUG_ALLOC, "Alloc transd: %p(%Zd)\n", td, sizeof (struct FS_BPENTRY));
12641         if (!td) {
12642                 /* Oops out of mem */
12643                 return -ENOMEM;
12644 @@ -1487,7 +1487,7 @@
12645                 fs_dprintk (FS_DEBUG_ALLOC, "Alloc rec-skb: %p(%d)\n", skb, fp->bufsize);
12646                 if (!skb) break;
12647                 ne = kmalloc (sizeof (struct FS_BPENTRY), gfp_flags);
12648 -               fs_dprintk (FS_DEBUG_ALLOC, "Alloc rec-d: %p(%d)\n", ne, sizeof (struct FS_BPENTRY));
12649 +               fs_dprintk (FS_DEBUG_ALLOC, "Alloc rec-d: %p(%Zd)\n", ne, sizeof (struct FS_BPENTRY));
12650                 if (!ne) {
12651                         fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p\n", skb);
12652                         dev_kfree_skb_any (skb);
12653 @@ -1792,7 +1792,7 @@
12654         }
12655         dev->atm_vccs = kmalloc (dev->nchannels * sizeof (struct atm_vcc *), 
12656                                  GFP_KERNEL);
12657 -       fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%d)\n", 
12658 +       fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%Zd)\n",
12659                     dev->atm_vccs, dev->nchannels * sizeof (struct atm_vcc *));
12660  
12661         if (!dev->atm_vccs) {
12662 @@ -1900,7 +1900,7 @@
12663                 goto err_out;
12664  
12665         fs_dev = kmalloc (sizeof (struct fs_dev), GFP_KERNEL);
12666 -       fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%d)\n", 
12667 +       fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%Zd)\n",
12668                     fs_dev, sizeof (struct fs_dev));
12669         if (!fs_dev)
12670                 goto err_out;
12671 diff -Nru a/drivers/block/DAC960.c b/drivers/block/DAC960.c
12672 --- a/drivers/block/DAC960.c    Fri Aug 15 09:39:48 2003
12673 +++ b/drivers/block/DAC960.c    Sun Aug 31 16:13:56 2003
12674 @@ -23,6 +23,7 @@
12675  #include <linux/version.h>
12676  #include <linux/module.h>
12677  #include <linux/types.h>
12678 +#include <linux/miscdevice.h>
12679  #include <linux/blkdev.h>
12680  #include <linux/bio.h>
12681  #include <linux/completion.h>
12682 @@ -44,6 +45,8 @@
12683  #include <asm/uaccess.h>
12684  #include "DAC960.h"
12685  
12686 +#define DAC960_GAM_MINOR       252
12687 +
12688  
12689  static DAC960_Controller_T *DAC960_Controllers[DAC960_MaxControllers];
12690  static int DAC960_ControllerCount;
12691 @@ -71,10 +74,6 @@
12692         DAC960_Controller_T *p = disk->queue->queuedata;
12693         int drive_nr = (int)disk->private_data;
12694  
12695 -       /* bad hack for the "user" ioctls */
12696 -       if (!p->ControllerNumber && !drive_nr && (file->f_flags & O_NONBLOCK))
12697 -               return 0;
12698 -
12699         if (p->FirmwareType == DAC960_V1_Controller) {
12700                 if (p->V1.LogicalDriveInformation[drive_nr].
12701                     LogicalDriveState == DAC960_V1_LogicalDrive_Offline)
12702 @@ -101,9 +100,6 @@
12703         int drive_nr = (int)disk->private_data;
12704         struct hd_geometry g, *loc = (struct hd_geometry *)arg;
12705  
12706 -       if (file && (file->f_flags & O_NONBLOCK))
12707 -               return DAC960_UserIOCTL(inode, file, cmd, arg);
12708 -
12709         if (cmd != HDIO_GETGEO || !loc)
12710                 return -EINVAL;
12711  
12712 @@ -5569,407 +5565,6 @@
12713  }
12714  
12715  /*
12716 -  DAC960_UserIOCTL is the User IOCTL Function for the DAC960 Driver.
12717 -*/
12718 -
12719 -static int DAC960_UserIOCTL(struct inode *inode, struct file *file,
12720 -                           unsigned int Request, unsigned long Argument)
12721 -{
12722 -  int ErrorCode = 0;
12723 -  if (!capable(CAP_SYS_ADMIN)) return -EACCES;
12724 -  switch (Request)
12725 -    {
12726 -    case DAC960_IOCTL_GET_CONTROLLER_COUNT:
12727 -      return DAC960_ControllerCount;
12728 -    case DAC960_IOCTL_GET_CONTROLLER_INFO:
12729 -      {
12730 -       DAC960_ControllerInfo_T *UserSpaceControllerInfo =
12731 -         (DAC960_ControllerInfo_T *) Argument;
12732 -       DAC960_ControllerInfo_T ControllerInfo;
12733 -       DAC960_Controller_T *Controller;
12734 -       int ControllerNumber;
12735 -       if (UserSpaceControllerInfo == NULL) return -EINVAL;
12736 -       ErrorCode = get_user(ControllerNumber,
12737 -                            &UserSpaceControllerInfo->ControllerNumber);
12738 -       if (ErrorCode != 0) return ErrorCode;
12739 -       if (ControllerNumber < 0 ||
12740 -           ControllerNumber > DAC960_ControllerCount - 1)
12741 -         return -ENXIO;
12742 -       Controller = DAC960_Controllers[ControllerNumber];
12743 -       if (Controller == NULL) return -ENXIO;
12744 -       memset(&ControllerInfo, 0, sizeof(DAC960_ControllerInfo_T));
12745 -       ControllerInfo.ControllerNumber = ControllerNumber;
12746 -       ControllerInfo.FirmwareType = Controller->FirmwareType;
12747 -       ControllerInfo.Channels = Controller->Channels;
12748 -       ControllerInfo.Targets = Controller->Targets;
12749 -       ControllerInfo.PCI_Bus = Controller->Bus;
12750 -       ControllerInfo.PCI_Device = Controller->Device;
12751 -       ControllerInfo.PCI_Function = Controller->Function;
12752 -       ControllerInfo.IRQ_Channel = Controller->IRQ_Channel;
12753 -       ControllerInfo.PCI_Address = Controller->PCI_Address;
12754 -       strcpy(ControllerInfo.ModelName, Controller->ModelName);
12755 -       strcpy(ControllerInfo.FirmwareVersion, Controller->FirmwareVersion);
12756 -       return (copy_to_user(UserSpaceControllerInfo, &ControllerInfo,
12757 -                            sizeof(DAC960_ControllerInfo_T)) ? -EFAULT : 0);
12758 -      }
12759 -    case DAC960_IOCTL_V1_EXECUTE_COMMAND:
12760 -      {
12761 -       DAC960_V1_UserCommand_T *UserSpaceUserCommand =
12762 -         (DAC960_V1_UserCommand_T *) Argument;
12763 -       DAC960_V1_UserCommand_T UserCommand;
12764 -       DAC960_Controller_T *Controller;
12765 -       DAC960_Command_T *Command = NULL;
12766 -       DAC960_V1_CommandOpcode_T CommandOpcode;
12767 -       DAC960_V1_CommandStatus_T CommandStatus;
12768 -       DAC960_V1_DCDB_T DCDB;
12769 -       DAC960_V1_DCDB_T *DCDB_IOBUF = NULL;
12770 -       dma_addr_t      DCDB_IOBUFDMA;
12771 -       unsigned long flags;
12772 -       int ControllerNumber, DataTransferLength;
12773 -       unsigned char *DataTransferBuffer = NULL;
12774 -       dma_addr_t DataTransferBufferDMA;
12775 -       if (UserSpaceUserCommand == NULL) return -EINVAL;
12776 -       if (copy_from_user(&UserCommand, UserSpaceUserCommand,
12777 -                                  sizeof(DAC960_V1_UserCommand_T))) {
12778 -               ErrorCode = -EFAULT;
12779 -               goto Failure1a;
12780 -       }
12781 -       ControllerNumber = UserCommand.ControllerNumber;
12782 -       if (ControllerNumber < 0 ||
12783 -           ControllerNumber > DAC960_ControllerCount - 1)
12784 -         return -ENXIO;
12785 -       Controller = DAC960_Controllers[ControllerNumber];
12786 -       if (Controller == NULL) return -ENXIO;
12787 -       if (Controller->FirmwareType != DAC960_V1_Controller) return -EINVAL;
12788 -       CommandOpcode = UserCommand.CommandMailbox.Common.CommandOpcode;
12789 -       DataTransferLength = UserCommand.DataTransferLength;
12790 -       if (CommandOpcode & 0x80) return -EINVAL;
12791 -       if (CommandOpcode == DAC960_V1_DCDB)
12792 -         {
12793 -           if (copy_from_user(&DCDB, UserCommand.DCDB,
12794 -                              sizeof(DAC960_V1_DCDB_T))) {
12795 -               ErrorCode = -EFAULT;
12796 -               goto Failure1a;
12797 -           }
12798 -           if (DCDB.Channel >= DAC960_V1_MaxChannels) return -EINVAL;
12799 -           if (!((DataTransferLength == 0 &&
12800 -                  DCDB.Direction
12801 -                  == DAC960_V1_DCDB_NoDataTransfer) ||
12802 -                 (DataTransferLength > 0 &&
12803 -                  DCDB.Direction
12804 -                  == DAC960_V1_DCDB_DataTransferDeviceToSystem) ||
12805 -                 (DataTransferLength < 0 &&
12806 -                  DCDB.Direction
12807 -                  == DAC960_V1_DCDB_DataTransferSystemToDevice)))
12808 -             return -EINVAL;
12809 -           if (((DCDB.TransferLengthHigh4 << 16) | DCDB.TransferLength)
12810 -               != abs(DataTransferLength))
12811 -             return -EINVAL;
12812 -           DCDB_IOBUF = pci_alloc_consistent(Controller->PCIDevice,
12813 -                       sizeof(DAC960_V1_DCDB_T), &DCDB_IOBUFDMA);
12814 -           if (DCDB_IOBUF == NULL)
12815 -                       return -ENOMEM;
12816 -         }
12817 -       if (DataTransferLength > 0)
12818 -         {
12819 -           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
12820 -                               DataTransferLength, &DataTransferBufferDMA);
12821 -           if (DataTransferBuffer == NULL) {
12822 -               ErrorCode = -ENOMEM;
12823 -               goto Failure1;
12824 -           }
12825 -           memset(DataTransferBuffer, 0, DataTransferLength);
12826 -         }
12827 -       else if (DataTransferLength < 0)
12828 -         {
12829 -           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
12830 -                               -DataTransferLength, &DataTransferBufferDMA);
12831 -           if (DataTransferBuffer == NULL) {
12832 -               ErrorCode = -ENOMEM;
12833 -               goto Failure1;
12834 -           }
12835 -           if (copy_from_user(DataTransferBuffer,
12836 -                              UserCommand.DataTransferBuffer,
12837 -                              -DataTransferLength)) {
12838 -               ErrorCode = -EFAULT;
12839 -               goto Failure1;
12840 -           }
12841 -         }
12842 -       if (CommandOpcode == DAC960_V1_DCDB)
12843 -         {
12844 -           spin_lock_irqsave(&Controller->queue_lock, flags);
12845 -           while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
12846 -             DAC960_WaitForCommand(Controller);
12847 -           while (Controller->V1.DirectCommandActive[DCDB.Channel]
12848 -                                                    [DCDB.TargetID])
12849 -             {
12850 -               spin_unlock_irq(&Controller->queue_lock);
12851 -               __wait_event(Controller->CommandWaitQueue,
12852 -                            !Controller->V1.DirectCommandActive
12853 -                                            [DCDB.Channel][DCDB.TargetID]);
12854 -               spin_lock_irq(&Controller->queue_lock);
12855 -             }
12856 -           Controller->V1.DirectCommandActive[DCDB.Channel]
12857 -                                             [DCDB.TargetID] = true;
12858 -           spin_unlock_irqrestore(&Controller->queue_lock, flags);
12859 -           DAC960_V1_ClearCommand(Command);
12860 -           Command->CommandType = DAC960_ImmediateCommand;
12861 -           memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
12862 -                  sizeof(DAC960_V1_CommandMailbox_T));
12863 -           Command->V1.CommandMailbox.Type3.BusAddress = DCDB_IOBUFDMA;
12864 -           DCDB.BusAddress = DataTransferBufferDMA;
12865 -           memcpy(DCDB_IOBUF, &DCDB, sizeof(DAC960_V1_DCDB_T));
12866 -         }
12867 -       else
12868 -         {
12869 -           spin_lock_irqsave(&Controller->queue_lock, flags);
12870 -           while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
12871 -             DAC960_WaitForCommand(Controller);
12872 -           spin_unlock_irqrestore(&Controller->queue_lock, flags);
12873 -           DAC960_V1_ClearCommand(Command);
12874 -           Command->CommandType = DAC960_ImmediateCommand;
12875 -           memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
12876 -                  sizeof(DAC960_V1_CommandMailbox_T));
12877 -           if (DataTransferBuffer != NULL)
12878 -             Command->V1.CommandMailbox.Type3.BusAddress =
12879 -               DataTransferBufferDMA;
12880 -         }
12881 -       DAC960_ExecuteCommand(Command);
12882 -       CommandStatus = Command->V1.CommandStatus;
12883 -       spin_lock_irqsave(&Controller->queue_lock, flags);
12884 -       DAC960_DeallocateCommand(Command);
12885 -       spin_unlock_irqrestore(&Controller->queue_lock, flags);
12886 -       if (DataTransferLength > 0)
12887 -         {
12888 -           if (copy_to_user(UserCommand.DataTransferBuffer,
12889 -                            DataTransferBuffer, DataTransferLength)) {
12890 -               ErrorCode = -EFAULT;
12891 -               goto Failure1;
12892 -            }
12893 -         }
12894 -       if (CommandOpcode == DAC960_V1_DCDB)
12895 -         {
12896 -           /*
12897 -             I don't believe Target or Channel in the DCDB_IOBUF
12898 -             should be any different from the contents of DCDB.
12899 -            */
12900 -           Controller->V1.DirectCommandActive[DCDB.Channel]
12901 -                                             [DCDB.TargetID] = false;
12902 -           if (copy_to_user(UserCommand.DCDB, DCDB_IOBUF,
12903 -                            sizeof(DAC960_V1_DCDB_T))) {
12904 -               ErrorCode = -EFAULT;
12905 -               goto Failure1;
12906 -           }
12907 -         }
12908 -       ErrorCode = CommandStatus;
12909 -      Failure1:
12910 -       if (DataTransferBuffer != NULL)
12911 -         pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
12912 -                       DataTransferBuffer, DataTransferBufferDMA);
12913 -       if (DCDB_IOBUF != NULL)
12914 -         pci_free_consistent(Controller->PCIDevice, sizeof(DAC960_V1_DCDB_T),
12915 -                       DCDB_IOBUF, DCDB_IOBUFDMA);
12916 -      Failure1a:
12917 -       return ErrorCode;
12918 -      }
12919 -    case DAC960_IOCTL_V2_EXECUTE_COMMAND:
12920 -      {
12921 -       DAC960_V2_UserCommand_T *UserSpaceUserCommand =
12922 -         (DAC960_V2_UserCommand_T *) Argument;
12923 -       DAC960_V2_UserCommand_T UserCommand;
12924 -       DAC960_Controller_T *Controller;
12925 -       DAC960_Command_T *Command = NULL;
12926 -       DAC960_V2_CommandMailbox_T *CommandMailbox;
12927 -       DAC960_V2_CommandStatus_T CommandStatus;
12928 -       unsigned long flags;
12929 -       int ControllerNumber, DataTransferLength;
12930 -       int DataTransferResidue, RequestSenseLength;
12931 -       unsigned char *DataTransferBuffer = NULL;
12932 -       dma_addr_t DataTransferBufferDMA;
12933 -       unsigned char *RequestSenseBuffer = NULL;
12934 -       dma_addr_t RequestSenseBufferDMA;
12935 -       if (UserSpaceUserCommand == NULL) return -EINVAL;
12936 -       if (copy_from_user(&UserCommand, UserSpaceUserCommand,
12937 -                          sizeof(DAC960_V2_UserCommand_T))) {
12938 -               ErrorCode = -EFAULT;
12939 -               goto Failure2a;
12940 -       }
12941 -       ControllerNumber = UserCommand.ControllerNumber;
12942 -       if (ControllerNumber < 0 ||
12943 -           ControllerNumber > DAC960_ControllerCount - 1)
12944 -         return -ENXIO;
12945 -       Controller = DAC960_Controllers[ControllerNumber];
12946 -       if (Controller == NULL) return -ENXIO;
12947 -       if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
12948 -       DataTransferLength = UserCommand.DataTransferLength;
12949 -       if (DataTransferLength > 0)
12950 -         {
12951 -           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
12952 -                               DataTransferLength, &DataTransferBufferDMA);
12953 -           if (DataTransferBuffer == NULL) return -ENOMEM;
12954 -           memset(DataTransferBuffer, 0, DataTransferLength);
12955 -         }
12956 -       else if (DataTransferLength < 0)
12957 -         {
12958 -           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
12959 -                               -DataTransferLength, &DataTransferBufferDMA);
12960 -           if (DataTransferBuffer == NULL) return -ENOMEM;
12961 -           if (copy_from_user(DataTransferBuffer,
12962 -                              UserCommand.DataTransferBuffer,
12963 -                              -DataTransferLength)) {
12964 -               ErrorCode = -EFAULT;
12965 -               goto Failure2;
12966 -           }
12967 -         }
12968 -       RequestSenseLength = UserCommand.RequestSenseLength;
12969 -       if (RequestSenseLength > 0)
12970 -         {
12971 -           RequestSenseBuffer = pci_alloc_consistent(Controller->PCIDevice,
12972 -                       RequestSenseLength, &RequestSenseBufferDMA);
12973 -           if (RequestSenseBuffer == NULL)
12974 -             {
12975 -               ErrorCode = -ENOMEM;
12976 -               goto Failure2;
12977 -             }
12978 -           memset(RequestSenseBuffer, 0, RequestSenseLength);
12979 -         }
12980 -       spin_lock_irqsave(&Controller->queue_lock, flags);
12981 -       while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
12982 -         DAC960_WaitForCommand(Controller);
12983 -       spin_unlock_irqrestore(&Controller->queue_lock, flags);
12984 -       DAC960_V2_ClearCommand(Command);
12985 -       Command->CommandType = DAC960_ImmediateCommand;
12986 -       CommandMailbox = &Command->V2.CommandMailbox;
12987 -       memcpy(CommandMailbox, &UserCommand.CommandMailbox,
12988 -              sizeof(DAC960_V2_CommandMailbox_T));
12989 -       CommandMailbox->Common.CommandControlBits
12990 -                             .AdditionalScatterGatherListMemory = false;
12991 -       CommandMailbox->Common.CommandControlBits
12992 -                             .NoAutoRequestSense = true;
12993 -       CommandMailbox->Common.DataTransferSize = 0;
12994 -       CommandMailbox->Common.DataTransferPageNumber = 0;
12995 -       memset(&CommandMailbox->Common.DataTransferMemoryAddress, 0,
12996 -              sizeof(DAC960_V2_DataTransferMemoryAddress_T));
12997 -       if (DataTransferLength != 0)
12998 -         {
12999 -           if (DataTransferLength > 0)
13000 -             {
13001 -               CommandMailbox->Common.CommandControlBits
13002 -                                     .DataTransferControllerToHost = true;
13003 -               CommandMailbox->Common.DataTransferSize = DataTransferLength;
13004 -             }
13005 -           else
13006 -             {
13007 -               CommandMailbox->Common.CommandControlBits
13008 -                                     .DataTransferControllerToHost = false;
13009 -               CommandMailbox->Common.DataTransferSize = -DataTransferLength;
13010 -             }
13011 -           CommandMailbox->Common.DataTransferMemoryAddress
13012 -                                 .ScatterGatherSegments[0]
13013 -                                 .SegmentDataPointer = DataTransferBufferDMA;
13014 -           CommandMailbox->Common.DataTransferMemoryAddress
13015 -                                 .ScatterGatherSegments[0]
13016 -                                 .SegmentByteCount =
13017 -             CommandMailbox->Common.DataTransferSize;
13018 -         }
13019 -       if (RequestSenseLength > 0)
13020 -         {
13021 -           CommandMailbox->Common.CommandControlBits
13022 -                                 .NoAutoRequestSense = false;
13023 -           CommandMailbox->Common.RequestSenseSize = RequestSenseLength;
13024 -           CommandMailbox->Common.RequestSenseBusAddress =
13025 -                                                       RequestSenseBufferDMA;
13026 -         }
13027 -       DAC960_ExecuteCommand(Command);
13028 -       CommandStatus = Command->V2.CommandStatus;
13029 -       RequestSenseLength = Command->V2.RequestSenseLength;
13030 -       DataTransferResidue = Command->V2.DataTransferResidue;
13031 -       spin_lock_irqsave(&Controller->queue_lock, flags);
13032 -       DAC960_DeallocateCommand(Command);
13033 -       spin_unlock_irqrestore(&Controller->queue_lock, flags);
13034 -       if (RequestSenseLength > UserCommand.RequestSenseLength)
13035 -         RequestSenseLength = UserCommand.RequestSenseLength;
13036 -       if (copy_to_user(&UserSpaceUserCommand->DataTransferLength,
13037 -                                &DataTransferResidue,
13038 -                                sizeof(DataTransferResidue))) {
13039 -               ErrorCode = -EFAULT;
13040 -               goto Failure2;
13041 -       }
13042 -       if (copy_to_user(&UserSpaceUserCommand->RequestSenseLength,
13043 -                        &RequestSenseLength, sizeof(RequestSenseLength))) {
13044 -               ErrorCode = -EFAULT;
13045 -               goto Failure2;
13046 -       }
13047 -       if (DataTransferLength > 0)
13048 -         {
13049 -           if (copy_to_user(UserCommand.DataTransferBuffer,
13050 -                            DataTransferBuffer, DataTransferLength)) {
13051 -               ErrorCode = -EFAULT;
13052 -               goto Failure2;
13053 -           }
13054 -         }
13055 -       if (RequestSenseLength > 0)
13056 -         {
13057 -           if (copy_to_user(UserCommand.RequestSenseBuffer,
13058 -                            RequestSenseBuffer, RequestSenseLength)) {
13059 -               ErrorCode = -EFAULT;
13060 -               goto Failure2;
13061 -           }
13062 -         }
13063 -       ErrorCode = CommandStatus;
13064 -      Failure2:
13065 -         pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
13066 -               DataTransferBuffer, DataTransferBufferDMA);
13067 -       if (RequestSenseBuffer != NULL)
13068 -         pci_free_consistent(Controller->PCIDevice, RequestSenseLength,
13069 -               RequestSenseBuffer, RequestSenseBufferDMA);
13070 -      Failure2a:
13071 -       return ErrorCode;
13072 -      }
13073 -    case DAC960_IOCTL_V2_GET_HEALTH_STATUS:
13074 -      {
13075 -       DAC960_V2_GetHealthStatus_T *UserSpaceGetHealthStatus =
13076 -         (DAC960_V2_GetHealthStatus_T *) Argument;
13077 -       DAC960_V2_GetHealthStatus_T GetHealthStatus;
13078 -       DAC960_V2_HealthStatusBuffer_T HealthStatusBuffer;
13079 -       DAC960_Controller_T *Controller;
13080 -       int ControllerNumber;
13081 -       if (UserSpaceGetHealthStatus == NULL) return -EINVAL;
13082 -       if (copy_from_user(&GetHealthStatus, UserSpaceGetHealthStatus,
13083 -                          sizeof(DAC960_V2_GetHealthStatus_T)))
13084 -               return -EFAULT;
13085 -       ControllerNumber = GetHealthStatus.ControllerNumber;
13086 -       if (ControllerNumber < 0 ||
13087 -           ControllerNumber > DAC960_ControllerCount - 1)
13088 -         return -ENXIO;
13089 -       Controller = DAC960_Controllers[ControllerNumber];
13090 -       if (Controller == NULL) return -ENXIO;
13091 -       if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
13092 -       if (copy_from_user(&HealthStatusBuffer,
13093 -                          GetHealthStatus.HealthStatusBuffer,
13094 -                          sizeof(DAC960_V2_HealthStatusBuffer_T)))
13095 -               return -EFAULT;
13096 -       while (Controller->V2.HealthStatusBuffer->StatusChangeCounter
13097 -              == HealthStatusBuffer.StatusChangeCounter &&
13098 -              Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
13099 -              == HealthStatusBuffer.NextEventSequenceNumber)
13100 -         {
13101 -           interruptible_sleep_on_timeout(&Controller->HealthStatusWaitQueue,
13102 -                                          DAC960_MonitoringTimerInterval);
13103 -           if (signal_pending(current)) return -EINTR;
13104 -         }
13105 -       if (copy_to_user(GetHealthStatus.HealthStatusBuffer,
13106 -                        Controller->V2.HealthStatusBuffer,
13107 -                        sizeof(DAC960_V2_HealthStatusBuffer_T)))
13108 -               return -EFAULT;
13109 -       return 0;
13110 -      }
13111 -    }
13112 -  return -EINVAL;
13113 -}
13114 -
13115 -
13116 -/*
13117    DAC960_CheckStatusBuffer verifies that there is room to hold ByteCount
13118    additional bytes in the Combined Status Buffer and grows the buffer if
13119    necessary.  It returns true if there is enough room and false otherwise.
13120 @@ -6901,6 +6496,436 @@
13121        Controller->ControllerProcEntry = NULL;
13122  }
13123  
13124 +#ifdef DAC960_GAM_MINOR
13125 +
13126 +/*
13127 + * DAC960_gam_ioctl is the ioctl function for performing RAID operations.
13128 +*/
13129 +
13130 +static int DAC960_gam_ioctl(struct inode *inode, struct file *file,
13131 +                           unsigned int Request, unsigned long Argument)
13132 +{
13133 +  int ErrorCode = 0;
13134 +  if (!capable(CAP_SYS_ADMIN)) return -EACCES;
13135 +  switch (Request)
13136 +    {
13137 +    case DAC960_IOCTL_GET_CONTROLLER_COUNT:
13138 +      return DAC960_ControllerCount;
13139 +    case DAC960_IOCTL_GET_CONTROLLER_INFO:
13140 +      {
13141 +       DAC960_ControllerInfo_T *UserSpaceControllerInfo =
13142 +         (DAC960_ControllerInfo_T *) Argument;
13143 +       DAC960_ControllerInfo_T ControllerInfo;
13144 +       DAC960_Controller_T *Controller;
13145 +       int ControllerNumber;
13146 +       if (UserSpaceControllerInfo == NULL) return -EINVAL;
13147 +       ErrorCode = get_user(ControllerNumber,
13148 +                            &UserSpaceControllerInfo->ControllerNumber);
13149 +       if (ErrorCode != 0) return ErrorCode;
13150 +       if (ControllerNumber < 0 ||
13151 +           ControllerNumber > DAC960_ControllerCount - 1)
13152 +         return -ENXIO;
13153 +       Controller = DAC960_Controllers[ControllerNumber];
13154 +       if (Controller == NULL) return -ENXIO;
13155 +       memset(&ControllerInfo, 0, sizeof(DAC960_ControllerInfo_T));
13156 +       ControllerInfo.ControllerNumber = ControllerNumber;
13157 +       ControllerInfo.FirmwareType = Controller->FirmwareType;
13158 +       ControllerInfo.Channels = Controller->Channels;
13159 +       ControllerInfo.Targets = Controller->Targets;
13160 +       ControllerInfo.PCI_Bus = Controller->Bus;
13161 +       ControllerInfo.PCI_Device = Controller->Device;
13162 +       ControllerInfo.PCI_Function = Controller->Function;
13163 +       ControllerInfo.IRQ_Channel = Controller->IRQ_Channel;
13164 +       ControllerInfo.PCI_Address = Controller->PCI_Address;
13165 +       strcpy(ControllerInfo.ModelName, Controller->ModelName);
13166 +       strcpy(ControllerInfo.FirmwareVersion, Controller->FirmwareVersion);
13167 +       return (copy_to_user(UserSpaceControllerInfo, &ControllerInfo,
13168 +                            sizeof(DAC960_ControllerInfo_T)) ? -EFAULT : 0);
13169 +      }
13170 +    case DAC960_IOCTL_V1_EXECUTE_COMMAND:
13171 +      {
13172 +       DAC960_V1_UserCommand_T *UserSpaceUserCommand =
13173 +         (DAC960_V1_UserCommand_T *) Argument;
13174 +       DAC960_V1_UserCommand_T UserCommand;
13175 +       DAC960_Controller_T *Controller;
13176 +       DAC960_Command_T *Command = NULL;
13177 +       DAC960_V1_CommandOpcode_T CommandOpcode;
13178 +       DAC960_V1_CommandStatus_T CommandStatus;
13179 +       DAC960_V1_DCDB_T DCDB;
13180 +       DAC960_V1_DCDB_T *DCDB_IOBUF = NULL;
13181 +       dma_addr_t      DCDB_IOBUFDMA;
13182 +       unsigned long flags;
13183 +       int ControllerNumber, DataTransferLength;
13184 +       unsigned char *DataTransferBuffer = NULL;
13185 +       dma_addr_t DataTransferBufferDMA;
13186 +       if (UserSpaceUserCommand == NULL) return -EINVAL;
13187 +       if (copy_from_user(&UserCommand, UserSpaceUserCommand,
13188 +                                  sizeof(DAC960_V1_UserCommand_T))) {
13189 +               ErrorCode = -EFAULT;
13190 +               goto Failure1a;
13191 +       }
13192 +       ControllerNumber = UserCommand.ControllerNumber;
13193 +       if (ControllerNumber < 0 ||
13194 +           ControllerNumber > DAC960_ControllerCount - 1)
13195 +         return -ENXIO;
13196 +       Controller = DAC960_Controllers[ControllerNumber];
13197 +       if (Controller == NULL) return -ENXIO;
13198 +       if (Controller->FirmwareType != DAC960_V1_Controller) return -EINVAL;
13199 +       CommandOpcode = UserCommand.CommandMailbox.Common.CommandOpcode;
13200 +       DataTransferLength = UserCommand.DataTransferLength;
13201 +       if (CommandOpcode & 0x80) return -EINVAL;
13202 +       if (CommandOpcode == DAC960_V1_DCDB)
13203 +         {
13204 +           if (copy_from_user(&DCDB, UserCommand.DCDB,
13205 +                              sizeof(DAC960_V1_DCDB_T))) {
13206 +               ErrorCode = -EFAULT;
13207 +               goto Failure1a;
13208 +           }
13209 +           if (DCDB.Channel >= DAC960_V1_MaxChannels) return -EINVAL;
13210 +           if (!((DataTransferLength == 0 &&
13211 +                  DCDB.Direction
13212 +                  == DAC960_V1_DCDB_NoDataTransfer) ||
13213 +                 (DataTransferLength > 0 &&
13214 +                  DCDB.Direction
13215 +                  == DAC960_V1_DCDB_DataTransferDeviceToSystem) ||
13216 +                 (DataTransferLength < 0 &&
13217 +                  DCDB.Direction
13218 +                  == DAC960_V1_DCDB_DataTransferSystemToDevice)))
13219 +             return -EINVAL;
13220 +           if (((DCDB.TransferLengthHigh4 << 16) | DCDB.TransferLength)
13221 +               != abs(DataTransferLength))
13222 +             return -EINVAL;
13223 +           DCDB_IOBUF = pci_alloc_consistent(Controller->PCIDevice,
13224 +                       sizeof(DAC960_V1_DCDB_T), &DCDB_IOBUFDMA);
13225 +           if (DCDB_IOBUF == NULL)
13226 +                       return -ENOMEM;
13227 +         }
13228 +       if (DataTransferLength > 0)
13229 +         {
13230 +           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
13231 +                               DataTransferLength, &DataTransferBufferDMA);
13232 +           if (DataTransferBuffer == NULL) {
13233 +               ErrorCode = -ENOMEM;
13234 +               goto Failure1;
13235 +           }
13236 +           memset(DataTransferBuffer, 0, DataTransferLength);
13237 +         }
13238 +       else if (DataTransferLength < 0)
13239 +         {
13240 +           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
13241 +                               -DataTransferLength, &DataTransferBufferDMA);
13242 +           if (DataTransferBuffer == NULL) {
13243 +               ErrorCode = -ENOMEM;
13244 +               goto Failure1;
13245 +           }
13246 +           if (copy_from_user(DataTransferBuffer,
13247 +                              UserCommand.DataTransferBuffer,
13248 +                              -DataTransferLength)) {
13249 +               ErrorCode = -EFAULT;
13250 +               goto Failure1;
13251 +           }
13252 +         }
13253 +       if (CommandOpcode == DAC960_V1_DCDB)
13254 +         {
13255 +           spin_lock_irqsave(&Controller->queue_lock, flags);
13256 +           while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
13257 +             DAC960_WaitForCommand(Controller);
13258 +           while (Controller->V1.DirectCommandActive[DCDB.Channel]
13259 +                                                    [DCDB.TargetID])
13260 +             {
13261 +               spin_unlock_irq(&Controller->queue_lock);
13262 +               __wait_event(Controller->CommandWaitQueue,
13263 +                            !Controller->V1.DirectCommandActive
13264 +                                            [DCDB.Channel][DCDB.TargetID]);
13265 +               spin_lock_irq(&Controller->queue_lock);
13266 +             }
13267 +           Controller->V1.DirectCommandActive[DCDB.Channel]
13268 +                                             [DCDB.TargetID] = true;
13269 +           spin_unlock_irqrestore(&Controller->queue_lock, flags);
13270 +           DAC960_V1_ClearCommand(Command);
13271 +           Command->CommandType = DAC960_ImmediateCommand;
13272 +           memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
13273 +                  sizeof(DAC960_V1_CommandMailbox_T));
13274 +           Command->V1.CommandMailbox.Type3.BusAddress = DCDB_IOBUFDMA;
13275 +           DCDB.BusAddress = DataTransferBufferDMA;
13276 +           memcpy(DCDB_IOBUF, &DCDB, sizeof(DAC960_V1_DCDB_T));
13277 +         }
13278 +       else
13279 +         {
13280 +           spin_lock_irqsave(&Controller->queue_lock, flags);
13281 +           while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
13282 +             DAC960_WaitForCommand(Controller);
13283 +           spin_unlock_irqrestore(&Controller->queue_lock, flags);
13284 +           DAC960_V1_ClearCommand(Command);
13285 +           Command->CommandType = DAC960_ImmediateCommand;
13286 +           memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
13287 +                  sizeof(DAC960_V1_CommandMailbox_T));
13288 +           if (DataTransferBuffer != NULL)
13289 +             Command->V1.CommandMailbox.Type3.BusAddress =
13290 +               DataTransferBufferDMA;
13291 +         }
13292 +       DAC960_ExecuteCommand(Command);
13293 +       CommandStatus = Command->V1.CommandStatus;
13294 +       spin_lock_irqsave(&Controller->queue_lock, flags);
13295 +       DAC960_DeallocateCommand(Command);
13296 +       spin_unlock_irqrestore(&Controller->queue_lock, flags);
13297 +       if (DataTransferLength > 0)
13298 +         {
13299 +           if (copy_to_user(UserCommand.DataTransferBuffer,
13300 +                            DataTransferBuffer, DataTransferLength)) {
13301 +               ErrorCode = -EFAULT;
13302 +               goto Failure1;
13303 +            }
13304 +         }
13305 +       if (CommandOpcode == DAC960_V1_DCDB)
13306 +         {
13307 +           /*
13308 +             I don't believe Target or Channel in the DCDB_IOBUF
13309 +             should be any different from the contents of DCDB.
13310 +            */
13311 +           Controller->V1.DirectCommandActive[DCDB.Channel]
13312 +                                             [DCDB.TargetID] = false;
13313 +           if (copy_to_user(UserCommand.DCDB, DCDB_IOBUF,
13314 +                            sizeof(DAC960_V1_DCDB_T))) {
13315 +               ErrorCode = -EFAULT;
13316 +               goto Failure1;
13317 +           }
13318 +         }
13319 +       ErrorCode = CommandStatus;
13320 +      Failure1:
13321 +       if (DataTransferBuffer != NULL)
13322 +         pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
13323 +                       DataTransferBuffer, DataTransferBufferDMA);
13324 +       if (DCDB_IOBUF != NULL)
13325 +         pci_free_consistent(Controller->PCIDevice, sizeof(DAC960_V1_DCDB_T),
13326 +                       DCDB_IOBUF, DCDB_IOBUFDMA);
13327 +      Failure1a:
13328 +       return ErrorCode;
13329 +      }
13330 +    case DAC960_IOCTL_V2_EXECUTE_COMMAND:
13331 +      {
13332 +       DAC960_V2_UserCommand_T *UserSpaceUserCommand =
13333 +         (DAC960_V2_UserCommand_T *) Argument;
13334 +       DAC960_V2_UserCommand_T UserCommand;
13335 +       DAC960_Controller_T *Controller;
13336 +       DAC960_Command_T *Command = NULL;
13337 +       DAC960_V2_CommandMailbox_T *CommandMailbox;
13338 +       DAC960_V2_CommandStatus_T CommandStatus;
13339 +       unsigned long flags;
13340 +       int ControllerNumber, DataTransferLength;
13341 +       int DataTransferResidue, RequestSenseLength;
13342 +       unsigned char *DataTransferBuffer = NULL;
13343 +       dma_addr_t DataTransferBufferDMA;
13344 +       unsigned char *RequestSenseBuffer = NULL;
13345 +       dma_addr_t RequestSenseBufferDMA;
13346 +       if (UserSpaceUserCommand == NULL) return -EINVAL;
13347 +       if (copy_from_user(&UserCommand, UserSpaceUserCommand,
13348 +                          sizeof(DAC960_V2_UserCommand_T))) {
13349 +               ErrorCode = -EFAULT;
13350 +               goto Failure2a;
13351 +       }
13352 +       ControllerNumber = UserCommand.ControllerNumber;
13353 +       if (ControllerNumber < 0 ||
13354 +           ControllerNumber > DAC960_ControllerCount - 1)
13355 +         return -ENXIO;
13356 +       Controller = DAC960_Controllers[ControllerNumber];
13357 +       if (Controller == NULL) return -ENXIO;
13358 +       if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
13359 +       DataTransferLength = UserCommand.DataTransferLength;
13360 +       if (DataTransferLength > 0)
13361 +         {
13362 +           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
13363 +                               DataTransferLength, &DataTransferBufferDMA);
13364 +           if (DataTransferBuffer == NULL) return -ENOMEM;
13365 +           memset(DataTransferBuffer, 0, DataTransferLength);
13366 +         }
13367 +       else if (DataTransferLength < 0)
13368 +         {
13369 +           DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
13370 +                               -DataTransferLength, &DataTransferBufferDMA);
13371 +           if (DataTransferBuffer == NULL) return -ENOMEM;
13372 +           if (copy_from_user(DataTransferBuffer,
13373 +                              UserCommand.DataTransferBuffer,
13374 +                              -DataTransferLength)) {
13375 +               ErrorCode = -EFAULT;
13376 +               goto Failure2;
13377 +           }
13378 +         }
13379 +       RequestSenseLength = UserCommand.RequestSenseLength;
13380 +       if (RequestSenseLength > 0)
13381 +         {
13382 +           RequestSenseBuffer = pci_alloc_consistent(Controller->PCIDevice,
13383 +                       RequestSenseLength, &RequestSenseBufferDMA);
13384 +           if (RequestSenseBuffer == NULL)
13385 +             {
13386 +               ErrorCode = -ENOMEM;
13387 +               goto Failure2;
13388 +             }
13389 +           memset(RequestSenseBuffer, 0, RequestSenseLength);
13390 +         }
13391 +       spin_lock_irqsave(&Controller->queue_lock, flags);
13392 +       while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
13393 +         DAC960_WaitForCommand(Controller);
13394 +       spin_unlock_irqrestore(&Controller->queue_lock, flags);
13395 +       DAC960_V2_ClearCommand(Command);
13396 +       Command->CommandType = DAC960_ImmediateCommand;
13397 +       CommandMailbox = &Command->V2.CommandMailbox;
13398 +       memcpy(CommandMailbox, &UserCommand.CommandMailbox,
13399 +              sizeof(DAC960_V2_CommandMailbox_T));
13400 +       CommandMailbox->Common.CommandControlBits
13401 +                             .AdditionalScatterGatherListMemory = false;
13402 +       CommandMailbox->Common.CommandControlBits
13403 +                             .NoAutoRequestSense = true;
13404 +       CommandMailbox->Common.DataTransferSize = 0;
13405 +       CommandMailbox->Common.DataTransferPageNumber = 0;
13406 +       memset(&CommandMailbox->Common.DataTransferMemoryAddress, 0,
13407 +              sizeof(DAC960_V2_DataTransferMemoryAddress_T));
13408 +       if (DataTransferLength != 0)
13409 +         {
13410 +           if (DataTransferLength > 0)
13411 +             {
13412 +               CommandMailbox->Common.CommandControlBits
13413 +                                     .DataTransferControllerToHost = true;
13414 +               CommandMailbox->Common.DataTransferSize = DataTransferLength;
13415 +             }
13416 +           else
13417 +             {
13418 +               CommandMailbox->Common.CommandControlBits
13419 +                                     .DataTransferControllerToHost = false;
13420 +               CommandMailbox->Common.DataTransferSize = -DataTransferLength;
13421 +             }
13422 +           CommandMailbox->Common.DataTransferMemoryAddress
13423 +                                 .ScatterGatherSegments[0]
13424 +                                 .SegmentDataPointer = DataTransferBufferDMA;
13425 +           CommandMailbox->Common.DataTransferMemoryAddress
13426 +                                 .ScatterGatherSegments[0]
13427 +                                 .SegmentByteCount =
13428 +             CommandMailbox->Common.DataTransferSize;
13429 +         }
13430 +       if (RequestSenseLength > 0)
13431 +         {
13432 +           CommandMailbox->Common.CommandControlBits
13433 +                                 .NoAutoRequestSense = false;
13434 +           CommandMailbox->Common.RequestSenseSize = RequestSenseLength;
13435 +           CommandMailbox->Common.RequestSenseBusAddress =
13436 +                                                       RequestSenseBufferDMA;
13437 +         }
13438 +       DAC960_ExecuteCommand(Command);
13439 +       CommandStatus = Command->V2.CommandStatus;
13440 +       RequestSenseLength = Command->V2.RequestSenseLength;
13441 +       DataTransferResidue = Command->V2.DataTransferResidue;
13442 +       spin_lock_irqsave(&Controller->queue_lock, flags);
13443 +       DAC960_DeallocateCommand(Command);
13444 +       spin_unlock_irqrestore(&Controller->queue_lock, flags);
13445 +       if (RequestSenseLength > UserCommand.RequestSenseLength)
13446 +         RequestSenseLength = UserCommand.RequestSenseLength;
13447 +       if (copy_to_user(&UserSpaceUserCommand->DataTransferLength,
13448 +                                &DataTransferResidue,
13449 +                                sizeof(DataTransferResidue))) {
13450 +               ErrorCode = -EFAULT;
13451 +               goto Failure2;
13452 +       }
13453 +       if (copy_to_user(&UserSpaceUserCommand->RequestSenseLength,
13454 +                        &RequestSenseLength, sizeof(RequestSenseLength))) {
13455 +               ErrorCode = -EFAULT;
13456 +               goto Failure2;
13457 +       }
13458 +       if (DataTransferLength > 0)
13459 +         {
13460 +           if (copy_to_user(UserCommand.DataTransferBuffer,
13461 +                            DataTransferBuffer, DataTransferLength)) {
13462 +               ErrorCode = -EFAULT;
13463 +               goto Failure2;
13464 +           }
13465 +         }
13466 +       if (RequestSenseLength > 0)
13467 +         {
13468 +           if (copy_to_user(UserCommand.RequestSenseBuffer,
13469 +                            RequestSenseBuffer, RequestSenseLength)) {
13470 +               ErrorCode = -EFAULT;
13471 +               goto Failure2;
13472 +           }
13473 +         }
13474 +       ErrorCode = CommandStatus;
13475 +      Failure2:
13476 +         pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
13477 +               DataTransferBuffer, DataTransferBufferDMA);
13478 +       if (RequestSenseBuffer != NULL)
13479 +         pci_free_consistent(Controller->PCIDevice, RequestSenseLength,
13480 +               RequestSenseBuffer, RequestSenseBufferDMA);
13481 +      Failure2a:
13482 +       return ErrorCode;
13483 +      }
13484 +    case DAC960_IOCTL_V2_GET_HEALTH_STATUS:
13485 +      {
13486 +       DAC960_V2_GetHealthStatus_T *UserSpaceGetHealthStatus =
13487 +         (DAC960_V2_GetHealthStatus_T *) Argument;
13488 +       DAC960_V2_GetHealthStatus_T GetHealthStatus;
13489 +       DAC960_V2_HealthStatusBuffer_T HealthStatusBuffer;
13490 +       DAC960_Controller_T *Controller;
13491 +       int ControllerNumber;
13492 +       if (UserSpaceGetHealthStatus == NULL) return -EINVAL;
13493 +       if (copy_from_user(&GetHealthStatus, UserSpaceGetHealthStatus,
13494 +                          sizeof(DAC960_V2_GetHealthStatus_T)))
13495 +               return -EFAULT;
13496 +       ControllerNumber = GetHealthStatus.ControllerNumber;
13497 +       if (ControllerNumber < 0 ||
13498 +           ControllerNumber > DAC960_ControllerCount - 1)
13499 +         return -ENXIO;
13500 +       Controller = DAC960_Controllers[ControllerNumber];
13501 +       if (Controller == NULL) return -ENXIO;
13502 +       if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
13503 +       if (copy_from_user(&HealthStatusBuffer,
13504 +                          GetHealthStatus.HealthStatusBuffer,
13505 +                          sizeof(DAC960_V2_HealthStatusBuffer_T)))
13506 +               return -EFAULT;
13507 +       while (Controller->V2.HealthStatusBuffer->StatusChangeCounter
13508 +              == HealthStatusBuffer.StatusChangeCounter &&
13509 +              Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
13510 +              == HealthStatusBuffer.NextEventSequenceNumber)
13511 +         {
13512 +           interruptible_sleep_on_timeout(&Controller->HealthStatusWaitQueue,
13513 +                                          DAC960_MonitoringTimerInterval);
13514 +           if (signal_pending(current)) return -EINTR;
13515 +         }
13516 +       if (copy_to_user(GetHealthStatus.HealthStatusBuffer,
13517 +                        Controller->V2.HealthStatusBuffer,
13518 +                        sizeof(DAC960_V2_HealthStatusBuffer_T)))
13519 +               return -EFAULT;
13520 +       return 0;
13521 +      }
13522 +    }
13523 +  return -EINVAL;
13524 +}
13525 +
13526 +static struct file_operations DAC960_gam_fops = {
13527 +       .owner          = THIS_MODULE,
13528 +       .ioctl          = DAC960_gam_ioctl
13529 +};
13530 +
13531 +static struct miscdevice DAC960_gam_dev = {
13532 +       DAC960_GAM_MINOR,
13533 +       "dac960_gam",
13534 +       &DAC960_gam_fops
13535 +};
13536 +
13537 +static int DAC960_gam_init(void)
13538 +{
13539 +       int ret;
13540 +
13541 +       ret = misc_register(&DAC960_gam_dev);
13542 +       if (ret)
13543 +               printk(KERN_ERR "DAC960_gam: can't misc_register on minor %d\n", DAC960_GAM_MINOR);
13544 +       return ret;
13545 +}
13546 +
13547 +static void DAC960_gam_cleanup(void)
13548 +{
13549 +       misc_deregister(&DAC960_gam_dev);
13550 +}
13551 +
13552 +#endif /* DAC960_GAM_MINOR */
13553 +
13554  static struct DAC960_privdata DAC960_BA_privdata = {
13555         .HardwareType =         DAC960_BA_Controller,
13556         .FirmwareType   =       DAC960_V2_Controller,
13557 @@ -7000,12 +7025,23 @@
13558  
13559  static int DAC960_init_module(void)
13560  {
13561 -       return pci_module_init(&DAC960_pci_driver);
13562 +       int ret;
13563 +
13564 +       ret =  pci_module_init(&DAC960_pci_driver);
13565 +#ifdef DAC960_GAM_MINOR
13566 +       if (!ret)
13567 +               DAC960_gam_init();
13568 +#endif
13569 +       return ret;
13570  }
13571  
13572  static void DAC960_cleanup_module(void)
13573  {
13574         int i;
13575 +
13576 +#ifdef DAC960_GAM_MINOR
13577 +       DAC960_gam_cleanup();
13578 +#endif
13579  
13580         for (i = 0; i < DAC960_ControllerCount; i++) {
13581                 DAC960_Controller_T *Controller = DAC960_Controllers[i];
13582 diff -Nru a/drivers/block/DAC960.h b/drivers/block/DAC960.h
13583 --- a/drivers/block/DAC960.h    Thu Aug  7 06:13:28 2003
13584 +++ b/drivers/block/DAC960.h    Sun Aug 31 16:13:56 2003
13585 @@ -4138,8 +4138,6 @@
13586  static void DAC960_V1_QueueMonitoringCommand(DAC960_Command_T *);
13587  static void DAC960_V2_QueueMonitoringCommand(DAC960_Command_T *);
13588  static void DAC960_MonitoringTimerFunction(unsigned long);
13589 -static int DAC960_UserIOCTL(struct inode *, struct file *,
13590 -                           unsigned int, unsigned long);
13591  static void DAC960_Message(DAC960_MessageLevel_T, unsigned char *,
13592                            DAC960_Controller_T *, ...);
13593  static void DAC960_CreateProcEntries(DAC960_Controller_T *);
13594 diff -Nru a/drivers/block/acsi_slm.c b/drivers/block/acsi_slm.c
13595 --- a/drivers/block/acsi_slm.c  Sun Jun  8 04:05:16 2003
13596 +++ b/drivers/block/acsi_slm.c  Tue Aug 26 09:25:40 2003
13597 @@ -374,7 +374,7 @@
13598         if (!(page = __get_free_page( GFP_KERNEL )))
13599                 return( -ENOMEM );
13600         
13601 -       length = slm_getstats( (char *)page, MINOR(node->i_rdev) );
13602 +       length = slm_getstats( (char *)page, iminor(node) );
13603         if (length < 0) {
13604                 count = length;
13605                 goto out;
13606 @@ -622,7 +622,7 @@
13607  
13608  {
13609         struct inode *node = file->f_dentry->d_inode;
13610 -       int             device = MINOR( node->i_rdev );
13611 +       int             device = iminor(node);
13612         int             n, filled, w, h;
13613  
13614         while( SLMState == PRINTING ||
13615 @@ -694,7 +694,7 @@
13616  static int slm_ioctl( struct inode *inode, struct file *file,
13617                                           unsigned int cmd, unsigned long arg )
13618  
13619 -{      int             device = MINOR( inode->i_rdev ), err;
13620 +{      int             device = iminor(inode), err;
13621         
13622         /* I can think of setting:
13623          *  - manual feed
13624 @@ -768,7 +768,7 @@
13625  {      int device;
13626         struct slm *sip;
13627         
13628 -       device = MINOR(inode->i_rdev);
13629 +       device = iminor(inode);
13630         if (device >= N_SLM_Printers)
13631                 return( -ENXIO );
13632         sip = &slm_info[device];
13633 @@ -797,7 +797,7 @@
13634  {      int device;
13635         struct slm *sip;
13636         
13637 -       device = MINOR(inode->i_rdev);
13638 +       device = iminor(inode);
13639         sip = &slm_info[device];
13640  
13641         if (file->f_mode & 2)
13642 diff -Nru a/drivers/block/amiflop.c b/drivers/block/amiflop.c
13643 --- a/drivers/block/amiflop.c   Thu Aug  7 02:25:23 2003
13644 +++ b/drivers/block/amiflop.c   Tue Jul 29 16:35:37 2003
13645 @@ -55,24 +55,15 @@
13646  
13647  #include <linux/module.h>
13648  
13649 -#include <linux/sched.h>
13650 -#include <linux/fs.h>
13651 -#include <linux/fcntl.h>
13652 -#include <linux/kernel.h>
13653 -#include <linux/timer.h>
13654  #include <linux/fd.h>
13655  #include <linux/hdreg.h>
13656 -#include <linux/errno.h>
13657 -#include <linux/types.h>
13658  #include <linux/delay.h>
13659 -#include <linux/string.h>
13660 -#include <linux/slab.h>
13661  #include <linux/init.h>
13662  #include <linux/amifdreg.h>
13663  #include <linux/amifd.h>
13664 -#include <linux/ioport.h>
13665  #include <linux/buffer_head.h>
13666 -#include <linux/interrupt.h>
13667 +#include <linux/blkdev.h>
13668 +#include <linux/elevator.h>
13669  
13670  #include <asm/setup.h>
13671  #include <asm/uaccess.h>
13672 @@ -1446,7 +1437,7 @@
13673  static int fd_ioctl(struct inode *inode, struct file *filp,
13674                     unsigned int cmd, unsigned long param)
13675  {
13676 -       int drive = minor(inode->i_rdev) & 3;
13677 +       int drive = iminor(inode) & 3;
13678         static struct floppy_struct getprm;
13679  
13680         switch(cmd){
13681 @@ -1570,8 +1561,8 @@
13682   */
13683  static int floppy_open(struct inode *inode, struct file *filp)
13684  {
13685 -       int drive = minor(inode->i_rdev) & 3;
13686 -       int system =  (minor(inode->i_rdev) & 4) >> 2;
13687 +       int drive = iminor(inode) & 3;
13688 +       int system =  (iminor(inode) & 4) >> 2;
13689         int old_dev;
13690         unsigned long flags;
13691  
13692 @@ -1618,7 +1609,7 @@
13693  
13694  static int floppy_release(struct inode * inode, struct file * filp)
13695  {
13696 -       int drive = minor(inode->i_rdev) & 3;
13697 +       int drive = iminor(inode) & 3;
13698  
13699         if (unit[drive].dirty == 1) {
13700                 del_timer (flush_track_timer + drive);
13701 diff -Nru a/drivers/block/as-iosched.c b/drivers/block/as-iosched.c
13702 --- a/drivers/block/as-iosched.c        Fri Aug 15 00:57:28 2003
13703 +++ b/drivers/block/as-iosched.c        Sun Aug 31 16:14:29 2003
13704 @@ -709,6 +709,14 @@
13705                 return 1;
13706         }
13707  
13708 +       if (aic->seek_samples == 0 || aic->ttime_samples == 0) {
13709 +               /*
13710 +                * Process has just started IO so default to not anticipate.
13711 +                * Maybe should be smarter.
13712 +                */
13713 +               return 1;
13714 +       }
13715 +
13716         if (aic->ttime_mean > ad->antic_expire) {
13717                 /* the process thinks too much between requests */
13718                 return 1;
13719 diff -Nru a/drivers/block/ataflop.c b/drivers/block/ataflop.c
13720 --- a/drivers/block/ataflop.c   Thu Aug  7 02:25:23 2003
13721 +++ b/drivers/block/ataflop.c   Wed Jul 30 15:49:57 2003
13722 @@ -63,35 +63,16 @@
13723  
13724  #include <linux/module.h>
13725  
13726 -#include <linux/sched.h>
13727 -#include <linux/string.h>
13728 -#include <linux/fs.h>
13729 -#include <linux/fcntl.h>
13730 -#include <linux/kernel.h>
13731 -#include <linux/timer.h>
13732  #include <linux/fd.h>
13733 -#include <linux/errno.h>
13734 -#include <linux/types.h>
13735  #include <linux/delay.h>
13736 -#include <linux/mm.h>
13737 -#include <linux/slab.h>
13738  #include <linux/init.h>
13739 -#include <linux/buffer_head.h>         /* for invalidate_buffers() */
13740 -
13741 -#include <asm/setup.h>
13742 -#include <asm/system.h>
13743 -#include <asm/bitops.h>
13744 -#include <asm/irq.h>
13745 -#include <asm/pgtable.h>
13746 -#include <asm/uaccess.h>
13747 +#include <linux/blkdev.h>
13748  
13749  #include <asm/atafd.h>
13750  #include <asm/atafdreg.h>
13751 -#include <asm/atarihw.h>
13752  #include <asm/atariints.h>
13753  #include <asm/atari_stdma.h>
13754  #include <asm/atari_stram.h>
13755 -#include <linux/blkpg.h>
13756  
13757  #define        FD_MAX_UNITS 2
13758  
13759 @@ -1838,7 +1819,7 @@
13760  static int floppy_open( struct inode *inode, struct file *filp )
13761  {
13762         struct atari_floppy_struct *p = inode->i_bdev->bd_disk->private_data;
13763 -       int type  = minor(inode->i_rdev) >> 2;
13764 +       int type  = iminor(inode) >> 2;
13765  
13766         DPRINT(("fd_open: type=%d\n",type));
13767         if (p->ref && p->type != type)
13768 diff -Nru a/drivers/block/cciss.c b/drivers/block/cciss.c
13769 --- a/drivers/block/cciss.c     Thu Aug  7 06:13:28 2003
13770 +++ b/drivers/block/cciss.c     Tue Aug 26 09:25:41 2003
13771 @@ -356,11 +356,11 @@
13772   */
13773  static int cciss_open(struct inode *inode, struct file *filep)
13774  {
13775 -       int ctlr = major(inode->i_rdev) - COMPAQ_CISS_MAJOR;
13776 -       int dsk  = minor(inode->i_rdev) >> NWD_SHIFT;
13777 +       int ctlr = imajor(inode) - COMPAQ_CISS_MAJOR;
13778 +       int dsk  = iminor(inode) >> NWD_SHIFT;
13779  
13780  #ifdef CCISS_DEBUG
13781 -       printk(KERN_DEBUG "cciss_open %x (%x:%x)\n", inode->i_rdev, ctlr, dsk);
13782 +       printk(KERN_DEBUG "cciss_open %s (%x:%x)\n", inode->i_bdev->bd_disk->disk_name, ctlr, dsk);
13783  #endif /* CCISS_DEBUG */ 
13784  
13785         if (ctlr >= MAX_CTLR || hba[ctlr] == NULL)
13786 @@ -372,7 +372,7 @@
13787          * for "raw controller".
13788          */
13789         if (hba[ctlr]->drv[dsk].nr_blocks == 0) {
13790 -               if (minor(inode->i_rdev) != 0)
13791 +               if (iminor(inode) != 0)
13792                         return -ENXIO;
13793                 if (!capable(CAP_SYS_ADMIN))
13794                         return -EPERM;
13795 @@ -386,11 +386,11 @@
13796   */
13797  static int cciss_release(struct inode *inode, struct file *filep)
13798  {
13799 -       int ctlr = major(inode->i_rdev) - COMPAQ_CISS_MAJOR;
13800 -       int dsk  = minor(inode->i_rdev) >> NWD_SHIFT;
13801 +       int ctlr = imajor(inode) - COMPAQ_CISS_MAJOR;
13802 +       int dsk  = iminor(inode) >> NWD_SHIFT;
13803  
13804  #ifdef CCISS_DEBUG
13805 -       printk(KERN_DEBUG "cciss_release %x (%x:%x)\n", inode->i_rdev, ctlr, dsk);
13806 +       printk(KERN_DEBUG "cciss_release %s (%x:%x)\n", inode->i_bdev->bd_disk->disk_name, ctlr, dsk);
13807  #endif /* CCISS_DEBUG */
13808  
13809         /* fsync_dev(inode->i_rdev); */
13810 @@ -406,8 +406,8 @@
13811  static int cciss_ioctl(struct inode *inode, struct file *filep, 
13812                 unsigned int cmd, unsigned long arg)
13813  {
13814 -       int ctlr = major(inode->i_rdev) - COMPAQ_CISS_MAJOR;
13815 -       int dsk  = minor(inode->i_rdev) >> NWD_SHIFT;
13816 +       int ctlr = imajor(inode) - COMPAQ_CISS_MAJOR;
13817 +       int dsk  = iminor(inode) >> NWD_SHIFT;
13818  
13819  #ifdef CCISS_DEBUG
13820         printk(KERN_DEBUG "cciss_ioctl: Called with cmd=%x %lx\n", cmd, arg);
13821 @@ -2525,6 +2525,9 @@
13822         if (!q)
13823                 goto err_all;
13824  
13825 +       hba[i]->queue = q;
13826 +       q->queuedata = hba[i];
13827 +
13828         /* Initialize the pdev driver private data. 
13829                 have it point to hba[i].  */
13830         pci_set_drvdata(pdev, hba[i]);
13831 @@ -2545,7 +2548,6 @@
13832  
13833         cciss_procinit(i);
13834  
13835 -        q->queuedata = hba[i];
13836         blk_queue_bounce_limit(q, hba[i]->pdev->dma_mask);
13837  
13838         /* This is a hardware imposed limit. */
13839 diff -Nru a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
13840 --- a/drivers/block/cpqarray.c  Thu Aug  7 02:25:24 2003
13841 +++ b/drivers/block/cpqarray.c  Tue Aug 26 09:25:41 2003
13842 @@ -1078,7 +1078,7 @@
13843                 put_user(host->ctlr_sig, (int*)arg);
13844                 return 0;
13845         case IDAREVALIDATEVOLS:
13846 -               if (minor(inode->i_rdev) != 0)
13847 +               if (iminor(inode) != 0)
13848                         return -ENXIO;
13849                 return revalidate_allvol(host);
13850         case IDADRIVERVERSION:
13851 diff -Nru a/drivers/block/floppy.c b/drivers/block/floppy.c
13852 --- a/drivers/block/floppy.c    Fri Aug 15 10:27:03 2003
13853 +++ b/drivers/block/floppy.c    Sun Aug 31 16:14:41 2003
13854 @@ -695,23 +695,9 @@
13855         spin_unlock_irqrestore(&floppy_lock, flags);
13856  }
13857  
13858 -static int maximum(int a, int b)
13859 -{
13860 -       if (a > b)
13861 -               return a;
13862 -       else
13863 -               return b;
13864 -}
13865 -#define INFBOUND(a,b) (a)=maximum((a),(b));
13866 +#define INFBOUND(a,b) (a)=max_t(int, a, b)
13867  
13868 -static int minimum(int a, int b)
13869 -{
13870 -       if (a < b)
13871 -               return a;
13872 -       else
13873 -               return b;
13874 -}
13875 -#define SUPBOUND(a,b) (a)=minimum((a),(b));
13876 +#define SUPBOUND(a,b) (a)=min_t(int, a, b)
13877  
13878  
13879  /*
13880 @@ -1021,9 +1007,9 @@
13881  
13882  static DECLARE_WORK(floppy_work, NULL, NULL);
13883  
13884 -static void schedule_bh( void (*handler)(void*) )
13885 +static void schedule_bh(void (*handler) (void))
13886  {
13887 -       PREPARE_WORK(&floppy_work, handler, NULL);
13888 +       PREPARE_WORK(&floppy_work, (void (*)(void *))handler, NULL);
13889         schedule_work(&floppy_work);
13890  }
13891  
13892 @@ -1035,7 +1021,7 @@
13893  
13894         spin_lock_irqsave(&floppy_lock, flags);
13895         do_floppy = NULL;
13896 -       PREPARE_WORK(&floppy_work, (void*)(void*)empty, NULL);
13897 +       PREPARE_WORK(&floppy_work, (void*)empty, NULL);
13898         del_timer(&fd_timer);
13899         spin_unlock_irqrestore(&floppy_lock, flags);
13900  }
13901 @@ -1813,9 +1799,9 @@
13902                         max_sensei--;
13903                 } while ((ST0 & 0x83) != UNIT(current_drive) && inr == 2 && max_sensei);
13904         }
13905 -       if (handler) {
13906 -               schedule_bh( (void *)(void *) handler);
13907 -       } else
13908 +       if (handler)
13909 +               schedule_bh(handler);
13910 +       else
13911                 FDCS->reset = 1;
13912         is_alive("normal interrupt end");
13913  
13914 @@ -2058,26 +2044,26 @@
13915         wake_up(&command_done);
13916  }
13917  
13918 -static struct cont_t wakeup_cont={
13919 -       empty,
13920 -       do_wakeup,
13921 -       empty,
13922 -       (done_f)empty
13923 +static struct cont_t wakeup_cont = {
13924 +       .interrupt = empty,
13925 +       .redo = do_wakeup,
13926 +       .error = empty,
13927 +       .done = (done_f) empty
13928  };
13929  
13930  
13931 -static struct cont_t intr_cont={
13932 -       empty,
13933 -       process_fd_request,
13934 -       empty,
13935 -       (done_f) empty
13936 +static struct cont_t intr_cont = {
13937 +       .interrupt = empty,
13938 +       .redo = process_fd_request,
13939 +       .error = empty,
13940 +       .done = (done_f) empty
13941  };
13942  
13943  static int wait_til_done(void (*handler)(void), int interruptible)
13944  {
13945         int ret;
13946  
13947 -       schedule_bh((void *)(void *)handler);
13948 +       schedule_bh(handler);
13949  
13950         if (command_status < 2 && NO_SIGNAL) {
13951                 DECLARE_WAITQUEUE(wait, current);
13952 @@ -2281,11 +2267,12 @@
13953  #endif
13954  }
13955  
13956 -static struct cont_t format_cont={
13957 -       format_interrupt,
13958 -       redo_format,
13959 -       bad_flp_intr,
13960 -       generic_done };
13961 +static struct cont_t format_cont = {
13962 +       .interrupt = format_interrupt,
13963 +       .redo = redo_format,
13964 +       .error = bad_flp_intr,
13965 +       .done = generic_done
13966 +};
13967  
13968  static int do_format(int drive, struct format_descr *tmp_format_req)
13969  {
13970 @@ -2523,12 +2510,12 @@
13971         int size, i;
13972  
13973         max_sector = transfer_size(ssize,
13974 -                                  minimum(max_sector, max_sector_2),
13975 +                                  min(max_sector, max_sector_2),
13976                                    current_req->nr_sectors);
13977  
13978         if (current_count_sectors <= 0 && CT(COMMAND) == FD_WRITE &&
13979             buffer_max > fsector_t + current_req->nr_sectors)
13980 -               current_count_sectors = minimum(buffer_max - fsector_t,
13981 +               current_count_sectors = min_t(int, buffer_max - fsector_t,
13982                                                 current_req->nr_sectors);
13983  
13984         remaining = current_count_sectors << 9;
13985 @@ -2546,7 +2533,7 @@
13986         }
13987  #endif
13988  
13989 -       buffer_max = maximum(max_sector, buffer_max);
13990 +       buffer_max = max(max_sector, buffer_max);
13991  
13992         dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9);
13993  
13994 @@ -2697,7 +2684,7 @@
13995         if ((_floppy->rate & FD_2M) && (!TRACK) && (!HEAD)){
13996                 max_sector = 2 * _floppy->sect / 3;
13997                 if (fsector_t >= max_sector){
13998 -                       current_count_sectors = minimum(_floppy->sect - fsector_t,
13999 +                       current_count_sectors = min_t(int, _floppy->sect - fsector_t,
14000                                                         current_req->nr_sectors);
14001                         return 1;
14002                 }
14003 @@ -2987,7 +2974,7 @@
14004  
14005                 if (TESTF(FD_NEED_TWADDLE))
14006                         twaddle();
14007 -               schedule_bh( (void *)(void *) floppy_start);
14008 +               schedule_bh(floppy_start);
14009  #ifdef DEBUGT
14010                 debugt("queue fd request");
14011  #endif
14012 @@ -2996,16 +2983,17 @@
14013  #undef REPEAT
14014  }
14015  
14016 -static struct cont_t rw_cont={
14017 -       rw_interrupt,
14018 -       redo_fd_request,
14019 -       bad_flp_intr,
14020 -       request_done };
14021 +static struct cont_t rw_cont = {
14022 +       .interrupt = rw_interrupt,
14023 +       .redo = redo_fd_request,
14024 +       .error = bad_flp_intr,
14025 +       .done = request_done
14026 +};
14027  
14028  static void process_fd_request(void)
14029  {
14030         cont = &rw_cont;
14031 -       schedule_bh( (void *)(void *) redo_fd_request);
14032 +       schedule_bh(redo_fd_request);
14033  }
14034  
14035  static void do_fd_request(request_queue_t * q)
14036 @@ -3031,11 +3019,12 @@
14037         is_alive("do fd request");
14038  }
14039  
14040 -static struct cont_t poll_cont={
14041 -       success_and_wakeup,
14042 -       floppy_ready,
14043 -       generic_failure,
14044 -       generic_done };
14045 +static struct cont_t poll_cont = {
14046 +       .interrupt = success_and_wakeup,
14047 +       .redo = floppy_ready,
14048 +       .error = generic_failure,
14049 +       .done = generic_done
14050 +};
14051  
14052  static int poll_drive(int interruptible, int flag)
14053  {
14054 @@ -3066,11 +3055,12 @@
14055         printk("weird, reset interrupt called\n");
14056  }
14057  
14058 -static struct cont_t reset_cont={
14059 -       reset_intr,
14060 -       success_and_wakeup,
14061 -       generic_failure,
14062 -       generic_done };
14063 +static struct cont_t reset_cont = {
14064 +       .interrupt = reset_intr,
14065 +       .redo = success_and_wakeup,
14066 +       .error = generic_failure,
14067 +       .done = generic_done
14068 +};
14069  
14070  static int user_reset_fdc(int drive, int arg, int interruptible)
14071  {
14072 @@ -3174,11 +3164,11 @@
14073  }
14074  
14075  
14076 -static struct cont_t raw_cmd_cont={
14077 -       success_and_wakeup,
14078 -       floppy_start,
14079 -       generic_failure,
14080 -       raw_cmd_done
14081 +static struct cont_t raw_cmd_cont = {
14082 +       .interrupt = success_and_wakeup,
14083 +       .redo = floppy_start,
14084 +       .error = generic_failure,
14085 +       .done = raw_cmd_done
14086  };
14087  
14088  static inline int raw_cmd_copyout(int cmd, char *param,
14089 @@ -3781,9 +3771,9 @@
14090                 }
14091         }
14092  
14093 -       UDRS->fd_device = minor(inode->i_rdev);
14094 -       set_capacity(disks[drive], floppy_sizes[minor(inode->i_rdev)]);
14095 -       if (old_dev != -1 && old_dev != minor(inode->i_rdev)) {
14096 +       UDRS->fd_device = iminor(inode);
14097 +       set_capacity(disks[drive], floppy_sizes[iminor(inode)]);
14098 +       if (old_dev != -1 && old_dev != iminor(inode)) {
14099                 if (buffer_drive == drive)
14100                         buffer_track = -1;
14101         }
14102 @@ -3910,22 +3900,6 @@
14103         return 0;
14104  }
14105  
14106 -static int floppy_read_block_0(struct gendisk *disk)
14107 -{
14108 -       struct block_device *bdev;
14109 -       int ret;
14110 -
14111 -       bdev = bdget_disk(disk, 0);
14112 -       if (!bdev) {
14113 -               printk("No block device for %s\n", disk->disk_name);
14114 -               BUG();
14115 -       }
14116 -       bdev->bd_disk = disk;   /* ewww */
14117 -       ret = __floppy_read_block_0(bdev);
14118 -       atomic_dec(&bdev->bd_count);
14119 -       return ret;
14120 -}
14121 -
14122  /* revalidate the floppy disk, i.e. trigger format autodetection by reading
14123   * the bootblock (block 0). "Autodetection" is also needed to check whether
14124   * there is a disk in the drive at all... Thus we also do it for fixed
14125 @@ -3961,7 +3935,7 @@
14126                         UDRS->generation++;
14127                 if (NO_GEOM){
14128                         /* auto-sensing */
14129 -                       res = floppy_read_block_0(disk);
14130 +                       res = __floppy_read_block_0(opened_bdev[drive]);
14131                 } else {
14132                         if (cf)
14133                                 poll_drive(0, FD_RAW_NEED_DISK);
14134 diff -Nru a/drivers/block/floppy98.c b/drivers/block/floppy98.c
14135 --- a/drivers/block/floppy98.c  Thu Aug  7 02:25:24 2003
14136 +++ b/drivers/block/floppy98.c  Tue Aug 26 09:44:42 2003
14137 @@ -3844,9 +3844,9 @@
14138                 }
14139         }
14140  
14141 -       UDRS->fd_device = minor(inode->i_rdev);
14142 -       set_capacity(disks[drive], floppy_sizes[minor(inode->i_rdev)]);
14143 -       if (old_dev != -1 && old_dev != minor(inode->i_rdev)) {
14144 +       UDRS->fd_device = iminor(inode);
14145 +       set_capacity(disks[drive], floppy_sizes[iminor(inode)]);
14146 +       if (old_dev != -1 && old_dev != iminor(inode)) {
14147                 if (buffer_drive == drive)
14148                         buffer_track = -1;
14149         }
14150 @@ -3989,22 +3989,6 @@
14151         return 0;
14152  }
14153  
14154 -static int floppy_read_block_0(struct gendisk *disk)
14155 -{
14156 -       struct block_device *bdev;
14157 -       int ret;
14158 -
14159 -       bdev = bdget_disk(disk, 0);
14160 -       if (!bdev) {
14161 -               printk("No block device for %s\n", disk->disk_name);
14162 -               BUG();
14163 -       }
14164 -       bdev->bd_disk = disk;   /* ewww */
14165 -       ret = __floppy_read_block_0(bdev);
14166 -       atomic_dec(&bdev->bd_count);
14167 -       return ret;
14168 -}
14169 -
14170  /* revalidate the floppy disk, i.e. trigger format autodetection by reading
14171   * the bootblock (block 0). "Autodetection" is also needed to check whether
14172   * there is a disk in the drive at all... Thus we also do it for fixed
14173 @@ -4040,7 +4024,7 @@
14174                         UDRS->generation++;
14175                 if (NO_GEOM){
14176                         /* auto-sensing */
14177 -                       res = floppy_read_block_0(disk);
14178 +                       res = __floppy_read_block_0(opened_bdev[drive]);
14179                 } else {
14180                         if (cf)
14181                                 poll_drive(0, FD_RAW_NEED_DISK);
14182 diff -Nru a/drivers/block/genhd.c b/drivers/block/genhd.c
14183 --- a/drivers/block/genhd.c     Fri Aug  1 02:22:20 2003
14184 +++ b/drivers/block/genhd.c     Tue Aug 26 12:06:15 2003
14185 @@ -576,13 +576,10 @@
14186  
14187  void set_device_ro(struct block_device *bdev, int flag)
14188  {
14189 -       struct gendisk *disk = bdev->bd_disk;
14190 -       if (bdev->bd_contains != bdev) {
14191 -               int part = bdev->bd_dev - MKDEV(disk->major, disk->first_minor);
14192 -               struct hd_struct *p = disk->part[part-1];
14193 -               if (p) p->policy = flag;
14194 -       } else
14195 -               disk->policy = flag;
14196 +       if (bdev->bd_contains != bdev)
14197 +               bdev->bd_part->policy = flag;
14198 +       else
14199 +               bdev->bd_disk->policy = flag;
14200  }
14201  
14202  void set_disk_ro(struct gendisk *disk, int flag)
14203 @@ -595,17 +592,12 @@
14204  
14205  int bdev_read_only(struct block_device *bdev)
14206  {
14207 -       struct gendisk *disk;
14208         if (!bdev)
14209                 return 0;
14210 -       disk = bdev->bd_disk;
14211 -       if (bdev->bd_contains != bdev) {
14212 -               int part = bdev->bd_dev - MKDEV(disk->major, disk->first_minor);
14213 -               struct hd_struct *p = disk->part[part-1];
14214 -               if (p) return p->policy;
14215 -               return 0;
14216 -       } else
14217 -               return disk->policy;
14218 +       else if (bdev->bd_contains != bdev)
14219 +               return bdev->bd_part->policy;
14220 +       else
14221 +               return bdev->bd_disk->policy;
14222  }
14223  
14224  int invalidate_partition(struct gendisk *disk, int index)
14225 diff -Nru a/drivers/block/ioctl.c b/drivers/block/ioctl.c
14226 --- a/drivers/block/ioctl.c     Thu Jul 17 22:30:42 2003
14227 +++ b/drivers/block/ioctl.c     Tue Aug 26 12:06:15 2003
14228 @@ -8,7 +8,6 @@
14229  static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg *arg)
14230  {
14231         struct block_device *bdevp;
14232 -       int holder;
14233         struct gendisk *disk;
14234         struct blkpg_ioctl_arg a;
14235         struct blkpg_partition p;
14236 @@ -41,8 +40,11 @@
14237                                         return -EINVAL;
14238                         }
14239                         /* partition number in use? */
14240 -                       if (disk->part[part - 1])
14241 +                       down(&bdev->bd_sem);
14242 +                       if (disk->part[part - 1]) {
14243 +                               up(&bdev->bd_sem);
14244                                 return -EBUSY;
14245 +                       }
14246                         /* overlap? */
14247                         for (i = 0; i < disk->minors - 1; i++) {
14248                                 struct hd_struct *s = disk->part[i];
14249 @@ -50,22 +52,26 @@
14250                                 if (!s)
14251                                         continue;
14252                                 if (!(start+length <= s->start_sect ||
14253 -                                     start >= s->start_sect + s->nr_sects))
14254 +                                     start >= s->start_sect + s->nr_sects)) {
14255 +                                       up(&bdev->bd_sem);
14256                                         return -EBUSY;
14257 +                               }
14258                         }
14259                         /* all seems OK */
14260                         add_partition(disk, part, start, length);
14261 +                       up(&bdev->bd_sem);
14262                         return 0;
14263                 case BLKPG_DEL_PARTITION:
14264                         if (!disk->part[part-1])
14265                                 return -ENXIO;
14266                         if (disk->part[part - 1]->nr_sects == 0)
14267                                 return -ENXIO;
14268 -                       /* partition in use? Incomplete check for now. */
14269                         bdevp = bdget_disk(disk, part);
14270                         if (!bdevp)
14271                                 return -ENOMEM;
14272 -                       if (bd_claim(bdevp, &holder) < 0) {
14273 +                       down(&bdevp->bd_sem);
14274 +                       if (bdevp->bd_openers) {
14275 +                               up(&bdevp->bd_sem);
14276                                 bdput(bdevp);
14277                                 return -EBUSY;
14278                         }
14279 @@ -73,9 +79,12 @@
14280                         fsync_bdev(bdevp);
14281                         invalidate_bdev(bdevp, 0);
14282  
14283 +                       down(&bdev->bd_sem);
14284                         delete_partition(disk, part);
14285 -                       bd_release(bdevp);
14286 +                       up(&bdev->bd_sem);
14287 +                       up(&bdevp->bd_sem);
14288                         bdput(bdevp);
14289 +
14290                         return 0;
14291                 default:
14292                         return -EINVAL;
14293 diff -Nru a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c
14294 --- a/drivers/block/ll_rw_blk.c Mon Aug 18 22:28:54 2003
14295 +++ b/drivers/block/ll_rw_blk.c Mon Sep  1 04:55:34 2003
14296 @@ -136,6 +136,12 @@
14297         return ret;
14298  }
14299  
14300 +void blk_queue_activity_fn(request_queue_t *q, activity_fn *fn, void *data)
14301 +{
14302 +       q->activity_fn = fn;
14303 +       q->activity_data = data;
14304 +}
14305 +
14306  /**
14307   * blk_queue_prep_rq - set a prepare_request function for queue
14308   * @q:         queue
14309 @@ -225,6 +231,8 @@
14310         blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH);
14311  
14312         INIT_LIST_HEAD(&q->plug_list);
14313 +
14314 +       blk_queue_activity_fn(q, NULL, NULL);
14315  }
14316  
14317  /**
14318 @@ -1314,7 +1322,7 @@
14319  
14320         if (!printed) {
14321                 printed = 1;
14322 -               printk("Using %s elevator\n", chosen_elevator->elevator_name);
14323 +               printk("Using %s io scheduler\n", chosen_elevator->elevator_name);
14324         }
14325  
14326         if (elevator_init(q, chosen_elevator))
14327 @@ -1666,6 +1674,9 @@
14328  {
14329         drive_stat_acct(req, req->nr_sectors, 1);
14330  
14331 +       if (q->activity_fn)
14332 +               q->activity_fn(q->activity_data, rq_data_dir(req));
14333 +
14334         /*
14335          * elevator indicated where it wants this request to be
14336          * inserted at elevator_merge time
14337 @@ -2043,24 +2054,23 @@
14338  static inline void blk_partition_remap(struct bio *bio)
14339  {
14340         struct block_device *bdev = bio->bi_bdev;
14341 -       struct gendisk *disk = bdev->bd_disk;
14342 -       struct hd_struct *p;
14343 -       if (bdev == bdev->bd_contains)
14344 -               return;
14345  
14346 -       p = disk->part[bdev->bd_dev-MKDEV(disk->major,disk->first_minor)-1];
14347 -       switch (bio->bi_rw) {
14348 -       case READ:
14349 -               p->read_sectors += bio_sectors(bio);
14350 -               p->reads++;
14351 -               break;
14352 -       case WRITE:
14353 -               p->write_sectors += bio_sectors(bio);
14354 -               p->writes++;
14355 -               break;
14356 +       if (bdev != bdev->bd_contains) {
14357 +               struct hd_struct *p = bdev->bd_part;
14358 +
14359 +               switch (bio->bi_rw) {
14360 +               case READ:
14361 +                       p->read_sectors += bio_sectors(bio);
14362 +                       p->reads++;
14363 +                       break;
14364 +               case WRITE:
14365 +                       p->write_sectors += bio_sectors(bio);
14366 +                       p->writes++;
14367 +                       break;
14368 +               }
14369 +               bio->bi_sector += p->start_sect;
14370 +               bio->bi_bdev = bdev->bd_contains;
14371         }
14372 -       bio->bi_sector += bdev->bd_offset;
14373 -       bio->bi_bdev = bdev->bd_contains;
14374  }
14375  
14376  /**
14377 diff -Nru a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
14378 --- a/drivers/block/paride/pg.c Sun May 25 02:45:05 2003
14379 +++ b/drivers/block/paride/pg.c Tue Aug 26 09:25:41 2003
14380 @@ -527,11 +527,9 @@
14381         return -1;
14382  }
14383  
14384 -#define DEVICE_NR(dev) (minor(dev) & 0x7F)
14385 -
14386  static int pg_open(struct inode *inode, struct file *file)
14387  {
14388 -       int unit = DEVICE_NR(inode->i_rdev);
14389 +       int unit = iminor(inode) & 0x7f;
14390         struct pg *dev = &devices[unit];
14391  
14392         if ((unit >= PG_UNITS) || (!dev->present))
14393 diff -Nru a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
14394 --- a/drivers/block/paride/pt.c Sun May 25 02:45:06 2003
14395 +++ b/drivers/block/paride/pt.c Tue Aug 26 09:25:41 2003
14396 @@ -670,11 +670,11 @@
14397         return -1;
14398  }
14399  
14400 -#define DEVICE_NR(dev) (minor(dev) & 0x7F)
14401 +#define DEVICE_NR(inode)       (iminor(inode) & 0x7F)
14402  
14403  static int pt_open(struct inode *inode, struct file *file)
14404  {
14405 -       int unit = DEVICE_NR(inode->i_rdev);
14406 +       int unit = DEVICE_NR(inode);
14407  
14408         if ((unit >= PT_UNITS) || (!PT.present))
14409                 return -ENODEV;
14410 @@ -696,7 +696,7 @@
14411                 return -EROFS;
14412         }
14413  
14414 -       if (!(minor(inode->i_rdev) & 128))
14415 +       if (!(iminor(inode) & 128))
14416                 PT.flags |= PT_REWIND;
14417  
14418         PT.bufptr = kmalloc(PT_BUFSIZE, GFP_KERNEL);
14419 @@ -715,7 +715,7 @@
14420         int unit;
14421         struct mtop mtop;
14422  
14423 -       unit = DEVICE_NR(inode->i_rdev);
14424 +       unit = DEVICE_NR(inode);
14425         if (unit >= PT_UNITS)
14426                 return -EINVAL;
14427         if (!PT.present)
14428 @@ -753,7 +753,7 @@
14429  static int
14430  pt_release(struct inode *inode, struct file *file)
14431  {
14432 -       int unit = DEVICE_NR(inode->i_rdev);
14433 +       int unit = DEVICE_NR(inode);
14434  
14435         if ((unit >= PT_UNITS) || (atomic_read(&PT.available) > 1))
14436                 return -EINVAL;
14437 @@ -776,7 +776,7 @@
14438  static ssize_t pt_read(struct file *filp, char *buf, size_t count, loff_t * ppos)
14439  {
14440         struct inode *ino = filp->f_dentry->d_inode;
14441 -       int unit = DEVICE_NR(ino->i_rdev);
14442 +       int unit = DEVICE_NR(ino);
14443         char rd_cmd[12] = { ATAPI_READ_6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
14444         int k, n, r, p, s, t, b;
14445  
14446 @@ -873,7 +873,7 @@
14447  static ssize_t pt_write(struct file *filp, const char *buf, size_t count, loff_t * ppos)
14448  {
14449         struct inode *ino = filp->f_dentry->d_inode;
14450 -       int unit = DEVICE_NR(ino->i_rdev);
14451 +       int unit = DEVICE_NR(ino);
14452         char wr_cmd[12] = { ATAPI_WRITE_6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
14453         int k, n, r, p, s, t, b;
14454  
14455 diff -Nru a/drivers/block/rd.c b/drivers/block/rd.c
14456 --- a/drivers/block/rd.c        Thu Aug  7 02:25:24 2003
14457 +++ b/drivers/block/rd.c        Tue Aug 26 10:05:56 2003
14458 @@ -245,6 +245,7 @@
14459  static int rd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
14460  {
14461         int error;
14462 +       struct block_device *bdev = inode->i_bdev;
14463  
14464         if (cmd != BLKFLSBUF)
14465                 return -EINVAL;
14466 @@ -253,12 +254,12 @@
14467            it's not like with the other blockdevices where
14468            this ioctl only flushes away the buffer cache. */
14469         error = -EBUSY;
14470 -       down(&inode->i_bdev->bd_sem);
14471 -       if (inode->i_bdev->bd_openers <= 2) {
14472 -               truncate_inode_pages(inode->i_mapping, 0);
14473 +       down(&bdev->bd_sem);
14474 +       if (bdev->bd_openers <= 2) {
14475 +               truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
14476                 error = 0;
14477         }
14478 -       up(&inode->i_bdev->bd_sem);
14479 +       up(&bdev->bd_sem);
14480         return error;
14481  }
14482  
14483 @@ -269,18 +270,18 @@
14484  
14485  static int rd_open(struct inode * inode, struct file * filp)
14486  {
14487 -       unsigned unit = minor(inode->i_rdev);
14488 +       unsigned unit = iminor(inode);
14489  
14490         /*
14491          * Immunize device against invalidate_buffers() and prune_icache().
14492          */
14493         if (rd_bdev[unit] == NULL) {
14494                 struct block_device *bdev = inode->i_bdev;
14495 -               atomic_inc(&bdev->bd_count);
14496 +               inode = igrab(bdev->bd_inode);
14497                 rd_bdev[unit] = bdev;
14498                 bdev->bd_openers++;
14499                 bdev->bd_block_size = rd_blocksize;
14500 -               bdev->bd_inode->i_size = get_capacity(rd_disks[unit])<<9;
14501 +               inode->i_size = get_capacity(rd_disks[unit])<<9;
14502                 inode->i_mapping->a_ops = &ramdisk_aops;
14503                 inode->i_mapping->backing_dev_info = &rd_backing_dev_info;
14504         }
14505 diff -Nru a/drivers/block/scsi_ioctl.c b/drivers/block/scsi_ioctl.c
14506 --- a/drivers/block/scsi_ioctl.c        Thu Aug  7 11:22:15 2003
14507 +++ b/drivers/block/scsi_ioctl.c        Mon Sep  1 12:24:06 2003
14508 @@ -438,11 +438,7 @@
14509                         err = sg_emulated_host(q, (int *) arg);
14510                         break;
14511                 case SG_IO:
14512 -                       err = bd_claim(bdev, current);
14513 -                       if (err)
14514 -                               break;
14515                         err = sg_io(q, bdev, (struct sg_io_hdr *) arg);
14516 -                       bd_release(bdev);
14517                         break;
14518                 /*
14519                  * old junk scsi send command ioctl
14520 @@ -452,11 +448,7 @@
14521                         if (!arg)
14522                                 break;
14523  
14524 -                       err = bd_claim(bdev, current);
14525 -                       if (err)
14526 -                               break;
14527                         err = sg_scsi_ioctl(q, bdev, (Scsi_Ioctl_Command *)arg);
14528 -                       bd_release(bdev);
14529                         break;
14530                 case CDROMCLOSETRAY:
14531                         close = 1;
14532 diff -Nru a/drivers/block/z2ram.c b/drivers/block/z2ram.c
14533 --- a/drivers/block/z2ram.c     Thu Aug  7 02:25:24 2003
14534 +++ b/drivers/block/z2ram.c     Wed Jul 30 15:20:18 2003
14535 @@ -28,10 +28,10 @@
14536  #define DEVICE_NAME "Z2RAM"
14537  
14538  #include <linux/major.h>
14539 -#include <linux/slab.h>
14540  #include <linux/vmalloc.h>
14541  #include <linux/init.h>
14542  #include <linux/module.h>
14543 +#include <linux/blkdev.h>
14544  
14545  #include <asm/setup.h>
14546  #include <asm/bitops.h>
14547 @@ -150,7 +150,7 @@
14548         sizeof( z2ram_map[0] );
14549      int rc = -ENOMEM;
14550  
14551 -    device = minor( inode->i_rdev );
14552 +    device = iminor(inode);
14553  
14554      if ( current_device != -1 && current_device != device )
14555      {
14556 diff -Nru a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig
14557 --- a/drivers/char/agp/Kconfig  Fri Aug 15 07:33:19 2003
14558 +++ b/drivers/char/agp/Kconfig  Thu Aug 28 16:22:00 2003
14559 @@ -63,15 +63,19 @@
14560           You should say Y here if you use XFree86 3.3.6 or 4.x and want to
14561           use GLX or DRI.  If unsure, say N.
14562  
14563 +# RED-PEN this option is misnamed, it's not 8151 specific
14564  config AGP_AMD_8151
14565 -       tristate "AMD Opteron/Athlon64 on-CPU GART support"
14566 +       tristate "AMD Opteron/Athlon64 on-CPU GART support" if !GART_IOMMU
14567         depends on AGP && X86
14568 -       default GART_IOMMU
14569 +       default y if GART_IOMMU
14570         help
14571           This option gives you AGP support for the GLX component of
14572 -         XFree86 4.x using the on-CPU AGP bridge of the AMD Athlon64/Opteron CPUs.
14573 +         XFree86 4.x using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs.
14574 +         You still need an external AGP bridge like the AMD 8151, VIA
14575 +          K8T400M, SiS755. It may also support other AGP bridges when loaded
14576 +         with agp_try_unsupported=1.
14577           You should say Y here if you use XFree86 3.3.6 or 4.x and want to
14578 -         use GLX or DRI.  If unsure, say N
14579 +         use GLX or DRI.  If unsure, say Y
14580  
14581  config AGP_INTEL
14582         tristate "Intel 440LX/BX/GX, I8xx and E7x05 chipset support"
14583 diff -Nru a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h
14584 --- a/drivers/char/agp/agp.h    Fri Aug 15 06:28:58 2003
14585 +++ b/drivers/char/agp/agp.h    Thu Aug 28 18:04:31 2003
14586 @@ -167,8 +167,10 @@
14587  
14588  #define PGE_EMPTY(b, p)        (!(p) || (p) == (unsigned long) (b)->scratch_page)
14589  
14590 -/* intel register */
14591 -#define INTEL_APBASE   0x10
14592 +/* Chipset independant registers (from AGP Spec) */
14593 +#define AGP_APBASE     0x10
14594 +
14595 +/* Intel registers */
14596  #define INTEL_APSIZE   0xb4
14597  #define INTEL_ATTBASE  0xb8
14598  #define INTEL_AGPCTRL  0xb0
14599 @@ -176,7 +178,6 @@
14600  #define INTEL_ERRSTS   0x91
14601  
14602  /* Intel 460GX Registers */
14603 -#define INTEL_I460_APBASE              0x10
14604  #define INTEL_I460_BAPBASE             0x98
14605  #define INTEL_I460_GXBCTL              0xa0
14606  #define INTEL_I460_AGPSIZ              0xa2
14607 @@ -184,7 +185,7 @@
14608  #define INTEL_I460_GATT_VALID          (1UL << 24)
14609  #define INTEL_I460_GATT_COHERENT       (1UL << 25)
14610  
14611 -/* intel i830 registers */
14612 +/* Intel i830 registers */
14613  #define I830_GMCH_CTRL                 0x52
14614  #define I830_GMCH_ENABLED              0x4
14615  #define I830_GMCH_MEM_MASK             0x1
14616 @@ -218,31 +219,31 @@
14617  #define I852_GME                       0x2
14618  #define I852_GM                                0x5
14619  
14620 -/* intel 815 register */
14621 +/* Intel 815 register */
14622  #define INTEL_815_APCONT       0x51
14623  #define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF
14624  
14625 -/* intel i820 registers */
14626 +/* Intel i820 registers */
14627  #define INTEL_I820_RDCR                0x51
14628  #define INTEL_I820_ERRSTS      0xc8
14629  
14630 -/* intel i840 registers */
14631 +/* Intel i840 registers */
14632  #define INTEL_I840_MCHCFG      0x50
14633  #define INTEL_I840_ERRSTS      0xc8
14634   
14635 -/* intel i845 registers */
14636 +/* Intel i845 registers */
14637  #define INTEL_I845_AGPM                0x51
14638  #define INTEL_I845_ERRSTS      0xc8
14639  
14640 -/* intel i850 registers */
14641 +/* Intel i850 registers */
14642  #define INTEL_I850_MCHCFG      0x50
14643  #define INTEL_I850_ERRSTS      0xc8
14644  
14645 -/* intel i860 registers */
14646 +/* Intel i860 registers */
14647  #define INTEL_I860_MCHCFG      0x50
14648  #define INTEL_I860_ERRSTS      0xc8
14649  
14650 -/* intel i810 registers */
14651 +/* Intel i810 registers */
14652  #define I810_GMADDR            0x10
14653  #define I810_MMADDR            0x14
14654  #define I810_PTE_BASE          0x10000
14655 @@ -261,7 +262,6 @@
14656  #define I810_DRAM_ROW_0_SDRAM  0x00000001
14657  
14658  /* Intel 7505 registers */
14659 -#define INTEL_I7505_NAPBASELO  0x10
14660  #define INTEL_I7505_APSIZE     0x74
14661  #define INTEL_I7505_NCAPID     0x60
14662  #define INTEL_I7505_NISTAT     0x6c
14663 @@ -271,26 +271,23 @@
14664  #define INTEL_I7505_MCHCFG     0x50
14665  
14666  /* VIA register */
14667 -#define VIA_APBASE     0x10
14668  #define VIA_GARTCTRL   0x80
14669  #define VIA_APSIZE     0x84
14670  #define VIA_ATTBASE    0x88
14671  
14672  /* VIA KT400 */
14673  #define VIA_AGP3_GARTCTRL      0x90
14674 -#define VIA_AGP3_APSIZE        0x94
14675 +#define VIA_AGP3_APSIZE                0x94
14676  #define VIA_AGP3_ATTBASE       0x98
14677 -#define VIA_AGPSEL     0xfd
14678 +#define VIA_AGPSEL             0xfd
14679  
14680  /* SiS registers */
14681 -#define SIS_APBASE     0x10
14682  #define SIS_ATTBASE    0x90
14683  #define SIS_APSIZE     0x94
14684  #define SIS_TLBCNTRL   0x97
14685  #define SIS_TLBFLUSH   0x98
14686  
14687  /* AMD registers */
14688 -#define AMD_APBASE     0x10
14689  #define AMD_MMBASE     0x14
14690  #define AMD_APSIZE     0xac
14691  #define AMD_MODECNTL   0xb0
14692 @@ -300,24 +297,14 @@
14693  #define AMD_TLBFLUSH   0x0c    /* In mmio region (32-bit register) */
14694  #define AMD_CACHEENTRY 0x10    /* In mmio region (32-bit register) */
14695  
14696 -#define AMD_8151_APSIZE        0xb4
14697 -#define AMD_8151_GARTBLOCK     0xb8
14698 -
14699 -#define AMD_X86_64_GARTAPERTURECTL     0x90
14700 -#define AMD_X86_64_GARTAPERTUREBASE    0x94
14701 -#define AMD_X86_64_GARTTABLEBASE       0x98
14702 -#define AMD_X86_64_GARTCACHECTL                0x9c
14703 -#define AMD_X86_64_GARTEN      1<<0
14704 -
14705 -#define AMD_8151_VMAPERTURE            0x10
14706 -#define AMD_8151_AGP_CTL               0xb0
14707 -#define AMD_8151_APERTURESIZE  0xb4
14708 -#define AMD_8151_GARTPTR               0xb8
14709 -#define AMD_8151_GTLBEN        1<<7
14710 -#define AMD_8151_APEREN        1<<8
14711 +/* AMD64 registers */
14712 +#define AMD64_GARTAPERTURECTL  0x90
14713 +#define AMD64_GARTAPERTUREBASE 0x94
14714 +#define AMD64_GARTTABLEBASE    0x98
14715 +#define AMD64_GARTCACHECTL             0x9c
14716 +#define AMD64_GARTEN           1<<0
14717  
14718  /* ALi registers */
14719 -#define ALI_APBASE                     0x10
14720  #define ALI_AGPCTRL                    0xb8
14721  #define ALI_ATTBASE                    0xbc
14722  #define ALI_TLBCTRL                    0xc0
14723 @@ -327,19 +314,17 @@
14724  #define ALI_CACHE_FLUSH_EN             0x100
14725  
14726  /* ATI register */
14727 -#define ATI_APBASE                  0x10
14728 -#define ATI_GART_MMBASE_ADDR        0x14
14729 -#define ATI_RS100_APSIZE            0xac
14730 -#define ATI_RS300_APSIZE            0xf8
14731 -#define ATI_RS100_IG_AGPMODE        0xb0
14732 -#define ATI_RS300_IG_AGPMODE        0xfc
14733 -
14734 -#define ATI_GART_FEATURE_ID         0x00
14735 -#define ATI_GART_BASE               0x04
14736 -#define ATI_GART_CACHE_SZBASE       0x08
14737 -#define ATI_GART_CACHE_CNTRL        0x0c
14738 -#define ATI_GART_CACHE_ENTRY_CNTRL  0x10
14739 -
14740 +#define ATI_GART_MMBASE_ADDR   0x14
14741 +#define ATI_RS100_APSIZE       0xac
14742 +#define ATI_RS300_APSIZE       0xf8
14743 +#define ATI_RS100_IG_AGPMODE   0xb0
14744 +#define ATI_RS300_IG_AGPMODE   0xfc
14745 +
14746 +#define ATI_GART_FEATURE_ID            0x00
14747 +#define ATI_GART_BASE                  0x04
14748 +#define ATI_GART_CACHE_SZBASE          0x08
14749 +#define ATI_GART_CACHE_CNTRL           0x0c
14750 +#define ATI_GART_CACHE_ENTRY_CNTRL     0x10
14751  
14752  /* Serverworks Registers */
14753  #define SVWRKS_APSIZE          0x10
14754 @@ -369,6 +354,17 @@
14755  #define HP_ZX1_PDIR_BASE       0x320
14756  #define HP_ZX1_CACHE_FLUSH     0x428
14757  
14758 +/* NVIDIA registers */
14759 +#define NVIDIA_0_APSIZE                0x80
14760 +#define NVIDIA_1_WBC           0xf0
14761 +#define NVIDIA_2_GARTCTRL      0xd0
14762 +#define NVIDIA_2_APBASE                0xd8
14763 +#define NVIDIA_2_APLIMIT       0xdc
14764 +#define NVIDIA_2_ATTBASE(i)    (0xe0 + (i) * 4)
14765 +#define NVIDIA_3_APBASE                0x50
14766 +#define NVIDIA_3_APLIMIT       0x54
14767 +
14768 +
14769  struct agp_device_ids {
14770         unsigned short device_id; /* first, to make table easier to read */
14771         enum chipset_type chipset;
14772 @@ -405,6 +401,9 @@
14773  void global_cache_flush(void);
14774  void get_agp_version(struct agp_bridge_data *bridge);
14775  unsigned long agp_generic_mask_memory(unsigned long addr, int type);
14776 +
14777 +extern int agp_off;
14778 +extern int agp_try_unsupported_boot;
14779  
14780  /* Standard agp registers */
14781  #define AGPSTAT                        0x4
14782 diff -Nru a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c
14783 --- a/drivers/char/agp/ali-agp.c        Mon Aug 18 10:39:21 2003
14784 +++ b/drivers/char/agp/ali-agp.c        Thu Aug 28 16:44:18 2003
14785 @@ -76,7 +76,7 @@
14786         pci_write_config_dword(agp_bridge->dev, ALI_TLBCTRL, ((temp & 0xffffff00) | 0x00000010));
14787  
14788         /* address to map to */
14789 -       pci_read_config_dword(agp_bridge->dev, ALI_APBASE, &temp);
14790 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
14791         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
14792  
14793  #if 0
14794 diff -Nru a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c
14795 --- a/drivers/char/agp/amd-k7-agp.c     Mon Aug 18 10:39:21 2003
14796 +++ b/drivers/char/agp/amd-k7-agp.c     Thu Aug 28 16:44:18 2003
14797 @@ -148,7 +148,7 @@
14798          * used to program the agp master not the cpu
14799          */
14800  
14801 -       pci_read_config_dword(agp_bridge->dev, AMD_APBASE, &temp);
14802 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
14803         addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
14804         agp_bridge->gart_bus_addr = addr;
14805  
14806 diff -Nru a/drivers/char/agp/amd-k8-agp.c b/drivers/char/agp/amd-k8-agp.c
14807 --- a/drivers/char/agp/amd-k8-agp.c     Thu Jul 31 08:58:45 2003
14808 +++ b/drivers/char/agp/amd-k8-agp.c     Thu Aug 28 18:04:31 2003
14809 @@ -8,12 +8,6 @@
14810   * work is done in the northbridge(s).
14811   */
14812  
14813 -/*
14814 - * On x86-64 the AGP driver needs to be initialized early by the IOMMU 
14815 - * code.  When you use this driver as a template for a new K8 AGP bridge
14816 - * driver don't forget to change arch/x86_64/kernel/pci-gart.c too -AK.
14817 - */
14818 -
14819  #include <linux/module.h>
14820  #include <linux/pci.h>
14821  #include <linux/init.h>
14822 @@ -21,7 +15,11 @@
14823  #include "agp.h"
14824  
14825  /* Will need to be increased if hammer ever goes >8-way. */
14826 +#ifdef CONFIG_SMP
14827  #define MAX_HAMMER_GARTS   8
14828 +#else
14829 +#define MAX_HAMMER_GARTS   1
14830 +#endif
14831  
14832  /* PTE bits. */
14833  #define GPTE_VALID     1
14834 @@ -39,6 +37,8 @@
14835  static int nr_garts;
14836  static struct pci_dev * hammers[MAX_HAMMER_GARTS];
14837  
14838 +static int __initdata agp_try_unsupported;
14839 +
14840  static int gart_iterator;
14841  #define for_each_nb() for(gart_iterator=0;gart_iterator<nr_garts;gart_iterator++)
14842  
14843 @@ -46,9 +46,9 @@
14844  {
14845         u32 tmp;
14846  
14847 -       pci_read_config_dword (dev, AMD_X86_64_GARTCACHECTL, &tmp);
14848 +       pci_read_config_dword (dev, AMD64_GARTCACHECTL, &tmp);
14849         tmp |= INVGART;
14850 -       pci_write_config_dword (dev, AMD_X86_64_GARTCACHECTL, tmp);
14851 +       pci_write_config_dword (dev, AMD64_GARTCACHECTL, tmp);
14852  }
14853  
14854  static void amd_x86_64_tlbflush(struct agp_memory *temp)
14855 @@ -135,7 +135,7 @@
14856         if (dev==NULL)
14857                 return 0;
14858  
14859 -       pci_read_config_dword(dev, AMD_X86_64_GARTAPERTURECTL, &temp);
14860 +       pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &temp);
14861         temp = (temp & 0xe);
14862         values = A_SIZE_32(x86_64_aperture_sizes);
14863  
14864 @@ -162,7 +162,7 @@
14865         u64 addr, aper_base;
14866  
14867         /* Address to map to */
14868 -       pci_read_config_dword (hammer, AMD_X86_64_GARTAPERTUREBASE, &tmp);
14869 +       pci_read_config_dword (hammer, AMD64_GARTAPERTUREBASE, &tmp);
14870         aperturebase = tmp << 25;
14871         aper_base = (aperturebase & PCI_BASE_ADDRESS_MEM_MASK);
14872  
14873 @@ -171,13 +171,13 @@
14874         addr >>= 12;
14875         tmp = (u32) addr<<4;
14876         tmp &= ~0xf;
14877 -       pci_write_config_dword (hammer, AMD_X86_64_GARTTABLEBASE, tmp);
14878 +       pci_write_config_dword (hammer, AMD64_GARTTABLEBASE, tmp);
14879  
14880         /* Enable GART translation for this hammer. */
14881 -       pci_read_config_dword(hammer, AMD_X86_64_GARTAPERTURECTL, &tmp);
14882 +       pci_read_config_dword(hammer, AMD64_GARTAPERTURECTL, &tmp);
14883         tmp |= GARTEN;
14884         tmp &= ~(DISGARTCPU | DISGARTIO);
14885 -       pci_write_config_dword(hammer, AMD_X86_64_GARTAPERTURECTL, tmp);
14886 +       pci_write_config_dword(hammer, AMD64_GARTAPERTURECTL, tmp);
14887  
14888         /* keep CPU's coherent. */
14889         flush_x86_64_tlb (hammer);
14890 @@ -216,9 +216,9 @@
14891  
14892         for_each_nb() {
14893                 /* disable gart translation */
14894 -               pci_read_config_dword (hammers[gart_iterator], AMD_X86_64_GARTAPERTURECTL, &tmp);
14895 -               tmp &= ~(AMD_X86_64_GARTEN);
14896 -               pci_write_config_dword (hammers[gart_iterator], AMD_X86_64_GARTAPERTURECTL, tmp);
14897 +               pci_read_config_dword (hammers[gart_iterator], AMD64_GARTAPERTURECTL, &tmp);
14898 +               tmp &= ~AMD64_GARTEN;
14899 +               pci_write_config_dword (hammers[gart_iterator], AMD64_GARTAPERTURECTL, tmp);
14900         }
14901  }
14902  
14903 @@ -246,24 +246,123 @@
14904         .agp_destroy_page       = agp_generic_destroy_page,
14905  };
14906  
14907 +/* Some basic sanity checks for the aperture. */
14908 +static int __init aperture_valid(u64 aper, u32 size)
14909 +{ 
14910 +       static int not_first_call; 
14911 +       u32 pfn, c;
14912 +       if (aper == 0) { 
14913 +               printk(KERN_ERR "No aperture\n");
14914 +               return 0; 
14915 +       }
14916 +       if (size < 32*1024*1024) {
14917 +               printk(KERN_ERR "Aperture too small (%d MB)\n", size>>20);
14918 +               return 0;
14919 +       }
14920 +       if (aper + size > 0xffffffff) { 
14921 +               printk(KERN_ERR "Aperture out of bounds\n"); 
14922 +               return 0;
14923 +       } 
14924 +       pfn = aper >> PAGE_SHIFT;
14925 +       for (c = 0; c < size/PAGE_SIZE; c++) { 
14926 +               if (!pfn_valid(pfn + c))
14927 +                       break;
14928 +               if (!PageReserved(pfn_to_page(pfn + c))) { 
14929 +                       printk(KERN_ERR "Aperture pointing to RAM\n");
14930 +                       return 0;
14931 +               }
14932 +       }
14933  
14934 -#ifdef CONFIG_SMP
14935 -static int cache_nbs (void)
14936 +       /* Request the Aperture. This catches cases when someone else
14937 +          already put a mapping in there - happens with some very broken BIOS 
14938 +
14939 +          Maybe better to use pci_assign_resource/pci_enable_device instead trusting
14940 +          the bridges? */
14941 +       if (!not_first_call && request_mem_region(aper, size, "aperture") < 0) { 
14942 +               printk(KERN_ERR "Aperture conflicts with PCI mapping.\n"); 
14943 +               return 0;
14944 +       }
14945 +
14946 +       not_first_call = 1;
14947 +       return 1;
14948 +} 
14949 +
14950 +/* 
14951 + * W*s centric BIOS sometimes only set up the aperture in the AGP
14952 + * bridge, not the northbridge. On AMD64 this is handled early 
14953 + * in aperture.c, but when GART_IOMMU is not enabled or we run
14954 + * on a 32bit kernel this needs to be redone. 
14955 + * Unfortunately it is impossible to fix the aperture here because it's too late
14956 + * to allocate that much memory. But at least error out cleanly instead of
14957 + * crashing.
14958 + */ 
14959 +static __init int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp, 
14960 +                                                                u16 cap)
14961 +{
14962 +       u32 aper_low, aper_hi;
14963 +       u64 aper, nb_aper;
14964 +       int order = 0;
14965 +       u32 nb_order, nb_base;
14966 +       u16 apsize;
14967 +
14968 +       pci_read_config_dword(nb, 0x90, &nb_order); 
14969 +       nb_order = (nb_order >> 1) & 7;
14970 +       pci_read_config_dword(nb, 0x94, &nb_base); 
14971 +       nb_aper = nb_base << 25;        
14972 +       if (aperture_valid(nb_aper, (32*1024*1024)<<nb_order)) { 
14973 +               return 0;
14974 +       }
14975 +
14976 +       /* Northbridge seems to contain crap. Try the AGP bridge. */
14977 +
14978 +       pci_read_config_word(agp, cap+0x14, &apsize); 
14979 +       if (apsize == 0xffff) 
14980 +               return -1; 
14981 +
14982 +       apsize &= 0xfff;
14983 +       /* Some BIOS use weird encodings not in the AGPv3 table. */
14984 +       if (apsize & 0xff) 
14985 +               apsize |= 0xf00; 
14986 +       order = 7 - hweight16(apsize); 
14987 +
14988 +       pci_read_config_dword(agp, 0x10, &aper_low);
14989 +       pci_read_config_dword(agp, 0x14, &aper_hi);
14990 +       aper = (aper_low & ~((1<<22)-1)) | ((u64)aper_hi << 32); 
14991 +       printk(KERN_INFO "Aperture from AGP @ %Lx size %u MB\n", aper, 32 << order);
14992 +       if (order < 0 || !aperture_valid(aper, (32*1024*1024)<<order))
14993 +               return -1; 
14994 +       
14995 +       pci_write_config_dword(nb, 0x90, order << 1); 
14996 +       pci_write_config_dword(nb, 0x94, aper >> 25); 
14997 +
14998 +       return 0;
14999 +} 
15000 +
15001 +static __init int cache_nbs (struct pci_dev *pdev, u32 cap_ptr)
15002  {
15003         struct pci_dev *loop_dev = NULL;
15004         int i = 0;
15005  
15006         /* cache pci_devs of northbridges. */
15007 -       while ((loop_dev = pci_find_device(PCI_VENDOR_ID_AMD, 0x1103, loop_dev)) != NULL) {
15008 +       while ((loop_dev = pci_find_device(PCI_VENDOR_ID_AMD, 0x1103, loop_dev)) 
15009 +                       != NULL) {
15010 +               if (fix_northbridge(loop_dev, pdev, cap_ptr) < 0) { 
15011 +                       printk("No usable aperture found.\n");
15012 +#ifdef __x86_64__ 
15013 +                       /* should port this to i386 */
15014 +                       printk("Consider rebooting with iommu=memaper=2 to get a good aperture.\n");
15015 +#endif 
15016 +                       return -1;  
15017 +               }
15018                 hammers[i++] = loop_dev;
15019                 nr_garts = i;
15020 -               if (i == MAX_HAMMER_GARTS)
15021 +               if (i == MAX_HAMMER_GARTS) { 
15022 +                       printk(KERN_INFO "Too many northbridges for AGP\n");
15023                         return -1;
15024 +               }
15025         }
15026 -       return 0;
15027 +       return i == 0 ? -1 : 0;
15028  }
15029 -#endif
15030 -
15031  
15032  static int __init agp_amdk8_probe(struct pci_dev *pdev,
15033                                   const struct pci_device_id *ent)
15034 @@ -277,7 +376,7 @@
15035         if (!cap_ptr)
15036                 return -ENODEV;
15037  
15038 -       printk(KERN_INFO PFX "Detected Opteron/Athlon64 on-CPU GART\n");
15039 +       /* Could check for AGPv3 here */
15040  
15041         bridge = agp_alloc_bridge();
15042         if (!bridge)
15043 @@ -311,6 +410,9 @@
15044                         bridge->major_version = 3;
15045                         bridge->minor_version = 0;
15046                 }
15047 +       } else {
15048 +               printk(KERN_INFO PFX "Detected AGP bridge %x\n",
15049 +                       pdev->devfn);
15050         }
15051  
15052         bridge->driver = &amd_8151_driver;
15053 @@ -320,22 +422,10 @@
15054         /* Fill in the mode register */
15055         pci_read_config_dword(pdev, bridge->capndx+PCI_AGP_STATUS, &bridge->mode);
15056  
15057 -#ifdef CONFIG_SMP
15058 -       if (cache_nbs() == -1) {
15059 +       if (cache_nbs(pdev, cap_ptr) == -1) {
15060                 agp_put_bridge(bridge);
15061 -               return -ENOMEM;
15062 -       }
15063 -#else
15064 -       {
15065 -       struct pci_dev *loop_dev = NULL;
15066 -       while ((loop_dev = pci_find_device(PCI_VENDOR_ID_AMD, 0x1103, loop_dev)) != NULL) {
15067 -               /* For UP, we only care about the first GART. */
15068 -               hammers[0] = loop_dev;
15069 -               nr_garts = 1;
15070 -               break;
15071 -       }
15072 +               return -ENODEV;
15073         }
15074 -#endif
15075  
15076         pci_set_drvdata(pdev, bridge);
15077         return agp_add_bridge(bridge);
15078 @@ -345,6 +435,8 @@
15079  {
15080         struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
15081  
15082 +       release_mem_region(virt_to_phys(bridge->gatt_table_real), 
15083 +                          x86_64_aperture_sizes[bridge->aperture_size_idx].size); 
15084         agp_remove_bridge(bridge);
15085         agp_put_bridge(bridge);
15086  }
15087 @@ -358,11 +450,21 @@
15088         .subvendor      = PCI_ANY_ID,
15089         .subdevice      = PCI_ANY_ID,
15090         },
15091 +       /* VIA K8T800 */
15092         {
15093         .class          = (PCI_CLASS_BRIDGE_HOST << 8),
15094         .class_mask     = ~0,
15095         .vendor         = PCI_VENDOR_ID_VIA,
15096 -       .device         = PCI_DEVICE_ID_VIA_K8T400M_0,
15097 +       .device         = PCI_DEVICE_ID_VIA_8385_0,
15098 +       .subvendor      = PCI_ANY_ID,
15099 +       .subdevice      = PCI_ANY_ID,
15100 +       },
15101 +       /* VIA K8M800 / K8N800 */
15102 +       {
15103 +       .class          = (PCI_CLASS_BRIDGE_HOST << 8),
15104 +       .class_mask     = ~0,
15105 +       .vendor         = PCI_VENDOR_ID_VIA,
15106 +       .device         = PCI_DEVICE_ID_VIA_8380_0,
15107         .subvendor      = PCI_ANY_ID,
15108         .subdevice      = PCI_ANY_ID,
15109         },
15110 @@ -386,10 +488,43 @@
15111         .remove         = agp_amdk8_remove,
15112  };
15113  
15114 +
15115  /* Not static due to IOMMU code calling it early. */
15116  int __init agp_amdk8_init(void)
15117  {
15118 -       return pci_module_init(&agp_amdk8_pci_driver);
15119 +       int err = 0;
15120 +       if (agp_off)
15121 +               return -EINVAL;
15122 +       if (pci_module_init(&agp_amdk8_pci_driver) == 0) { 
15123 +               struct pci_dev *dev;
15124 +               if (!agp_try_unsupported && !agp_try_unsupported_boot) { 
15125 +                       printk(KERN_INFO "No supported AGP bridge found.\n");
15126 +#ifdef MODULE                  
15127 +                       printk(KERN_INFO "You can try agp_try_unsupported=1\n");
15128 +#else
15129 +                       printk(KERN_INFO "You can boot with agp=try_unsupported\n");
15130 +#endif                 
15131 +                       return -ENODEV;
15132 +               }
15133 +
15134 +               /* First check that we have at least one K8 NB */
15135 +               if (!pci_find_device(PCI_VENDOR_ID_AMD, 0x1103, NULL))
15136 +                       return -ENODEV;
15137 +
15138 +               /* Look for any AGP bridge */
15139 +               dev = NULL;
15140 +               err = -ENODEV;
15141 +               while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev))) {
15142 +                       if (!pci_find_capability(dev, PCI_CAP_ID_AGP))
15143 +                               continue;
15144 +                       /* Only one bridge supported right now */       
15145 +                       if (agp_amdk8_probe(dev, NULL) == 0) {
15146 +                               err = 0;
15147 +                               break;
15148 +                       }       
15149 +               }               
15150 +       }
15151 +       return err;
15152  }
15153  
15154  static void __exit agp_amdk8_cleanup(void)
15155 @@ -404,6 +539,6 @@
15156  module_exit(agp_amdk8_cleanup);
15157  #endif
15158  
15159 -MODULE_AUTHOR("Dave Jones <davej@codemonkey.org.uk>");
15160 +MODULE_AUTHOR("Dave Jones <davej@codemonkey.org.uk>, Andi Kleen");
15161 +MODULE_PARM(agp_try_unsupported, "1i");
15162  MODULE_LICENSE("GPL and additional rights");
15163 -
15164 diff -Nru a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
15165 --- a/drivers/char/agp/ati-agp.c        Mon Aug 18 10:39:21 2003
15166 +++ b/drivers/char/agp/ati-agp.c        Thu Aug 28 16:44:18 2003
15167 @@ -1,5 +1,5 @@
15168  /*
15169 - * ALi AGPGART routines.
15170 + * ATi AGPGART routines.
15171   */
15172  
15173  #include <linux/types.h>
15174 @@ -212,7 +212,7 @@
15175  
15176         /* address to map too */
15177          /*
15178 -       pci_read_config_dword(agp_bridge.dev, ATI_APBASE, &temp);
15179 +       pci_read_config_dword(agp_bridge.dev, AGP_APBASE, &temp);
15180         agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15181         printk(KERN_INFO "IGP320 gart_bus_addr: %x\n", agp_bridge.gart_bus_addr);
15182          */
15183 @@ -355,7 +355,7 @@
15184          * This is a bus address even on the alpha, b/c its
15185          * used to program the agp master not the cpu
15186          */
15187 -       pci_read_config_dword(agp_bridge->dev, ATI_APBASE, &temp);
15188 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15189         addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15190         agp_bridge->gart_bus_addr = addr;
15191  
15192 diff -Nru a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
15193 --- a/drivers/char/agp/backend.c        Wed Aug 13 10:20:16 2003
15194 +++ b/drivers/char/agp/backend.c        Thu Aug 28 16:22:00 2003
15195 @@ -301,9 +301,14 @@
15196  }
15197  EXPORT_SYMBOL_GPL(agp_remove_bridge);
15198  
15199 +int agp_off;
15200 +int agp_try_unsupported_boot;
15201 +EXPORT_SYMBOL(agp_off);
15202 +EXPORT_SYMBOL(agp_try_unsupported_boot);
15203  
15204  static int __init agp_init(void)
15205  {
15206 +       if (!agp_off) 
15207         printk(KERN_INFO "Linux agpgart interface v%d.%d (c) Dave Jones\n",
15208                AGPGART_VERSION_MAJOR, AGPGART_VERSION_MINOR);
15209         return 0;
15210 @@ -313,6 +318,15 @@
15211  {
15212  }
15213  
15214 +static __init int agp_setup(char *s)
15215 +{
15216 +       if (!strcmp(s,"off"))
15217 +               agp_off = 1;
15218 +       if (!strcmp(s,"try_unsupported"))
15219 +               agp_try_unsupported_boot = 1;
15220 +       return 1;       
15221 +}
15222 +__setup("agp=", agp_setup);
15223  
15224  MODULE_AUTHOR("Dave Jones <davej@codemonkey.org.uk>");
15225  MODULE_DESCRIPTION("AGP GART driver");
15226 diff -Nru a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
15227 --- a/drivers/char/agp/frontend.c       Sun Jul 13 05:36:05 2003
15228 +++ b/drivers/char/agp/frontend.c       Tue Aug 26 09:25:41 2003
15229 @@ -698,7 +698,7 @@
15230  
15231  static int agp_open(struct inode *inode, struct file *file)
15232  {
15233 -       int minor = minor(inode->i_rdev);
15234 +       int minor = iminor(inode);
15235         struct agp_file_private *priv;
15236         struct agp_client *client;
15237         int rc = -ENXIO;
15238 diff -Nru a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
15239 --- a/drivers/char/agp/generic.c        Wed Aug 13 01:35:50 2003
15240 +++ b/drivers/char/agp/generic.c        Wed Aug 27 11:06:10 2003
15241 @@ -577,12 +577,12 @@
15242                         agp_device_command(command, TRUE);
15243                         return;
15244                 } else {
15245 -                   /* Disable calibration cycle in RX91<1> when not in AGP3.0 mode of operation.*/            
15246 +                   /* Disable calibration cycle in RX91<1> when not in AGP3.0 mode of operation.*/
15247                     command &= ~(7<<10) ;
15248                     pci_read_config_dword(agp_bridge->dev, agp_bridge->capndx+AGPCTRL, &temp);
15249                     temp |= (1<<9);
15250                     pci_write_config_dword(agp_bridge->dev, agp_bridge->capndx+AGPCTRL, temp);
15251 -                   
15252 +
15253                     printk (KERN_INFO PFX "Device is in legacy mode,"
15254                                 " falling back to 2.x\n");
15255                 }
15256 diff -Nru a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
15257 --- a/drivers/char/agp/intel-agp.c      Fri Aug 15 07:25:05 2003
15258 +++ b/drivers/char/agp/intel-agp.c      Thu Aug 28 16:44:18 2003
15259 @@ -618,7 +618,7 @@
15260         pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
15261  
15262         /* address to map to */
15263 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15264 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15265         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15266  
15267         /* attbase - aperture base */
15268 @@ -657,7 +657,7 @@
15269                         current_size->size_value); 
15270  
15271         /* address to map to */
15272 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15273 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15274         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15275  
15276         pci_read_config_dword(agp_bridge->dev, INTEL_ATTBASE, &addr);
15277 @@ -708,7 +708,7 @@
15278         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 
15279  
15280         /* address to map to */
15281 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15282 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15283         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15284  
15285         /* attbase - aperture base */
15286 @@ -739,7 +739,7 @@
15287         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 
15288  
15289         /* address to map to */
15290 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15291 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15292         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15293  
15294         /* attbase - aperture base */
15295 @@ -768,7 +768,7 @@
15296         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 
15297  
15298         /* address to map to */
15299 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15300 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15301         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15302  
15303         /* attbase - aperture base */
15304 @@ -797,7 +797,7 @@
15305         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); 
15306  
15307         /* address to map to */
15308 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15309 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15310         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15311  
15312         /* attbase - aperture base */
15313 @@ -826,7 +826,7 @@
15314         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
15315  
15316         /* address to map to */
15317 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15318 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15319         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15320  
15321         /* attbase - aperture base */
15322 @@ -855,7 +855,7 @@
15323         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
15324  
15325         /* address to map to */
15326 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15327 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15328         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15329  
15330         /* attbase - aperture base */
15331 @@ -884,7 +884,7 @@
15332         pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
15333  
15334         /* address to map to */
15335 -       pci_read_config_dword(agp_bridge->dev, INTEL_APBASE, &temp);
15336 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15337         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15338  
15339         /* attbase - aperture base */
15340 diff -Nru a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
15341 --- a/drivers/char/agp/nvidia-agp.c     Fri Aug 15 07:22:22 2003
15342 +++ b/drivers/char/agp/nvidia-agp.c     Thu Aug 28 16:56:50 2003
15343 @@ -13,18 +13,6 @@
15344  #include <linux/mm.h>
15345  #include "agp.h"
15346  
15347 -
15348 -/* registers */
15349 -#define NVIDIA_0_APBASE                0x10
15350 -#define NVIDIA_0_APSIZE                0x80
15351 -#define NVIDIA_1_WBC           0xf0
15352 -#define NVIDIA_2_GARTCTRL      0xd0
15353 -#define NVIDIA_2_APBASE                0xd8
15354 -#define NVIDIA_2_APLIMIT       0xdc
15355 -#define NVIDIA_2_ATTBASE(i)    (0xe0 + (i) * 4)
15356 -#define NVIDIA_3_APBASE                0x50
15357 -#define NVIDIA_3_APLIMIT       0x54
15358 -
15359  static struct _nvidia_private {
15360         struct pci_dev *dev_1;
15361         struct pci_dev *dev_2;
15362 @@ -73,7 +61,7 @@
15363                 current_size->size_value);
15364  
15365      /* address to map to */
15366 -       pci_read_config_dword(agp_bridge->dev, NVIDIA_0_APBASE, &apbase);
15367 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &apbase);
15368         apbase &= PCI_BASE_ADDRESS_MEM_MASK;
15369         agp_bridge->gart_bus_addr = apbase;
15370         aplimit = apbase + (current_size->size * 1024 * 1024) - 1;
15371 diff -Nru a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c
15372 --- a/drivers/char/agp/sis-agp.c        Mon Aug 18 10:39:21 2003
15373 +++ b/drivers/char/agp/sis-agp.c        Thu Aug 28 16:44:18 2003
15374 @@ -43,7 +43,7 @@
15375  
15376         current_size = A_SIZE_8(agp_bridge->current_size);
15377         pci_write_config_byte(agp_bridge->dev, SIS_TLBCNTRL, 0x05);
15378 -       pci_read_config_dword(agp_bridge->dev, SIS_APBASE, &temp);
15379 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15380         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15381         pci_write_config_dword(agp_bridge->dev, SIS_ATTBASE,
15382                                agp_bridge->gatt_bus_addr);
15383 diff -Nru a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c
15384 --- a/drivers/char/agp/via-agp.c        Wed Aug 13 01:41:04 2003
15385 +++ b/drivers/char/agp/via-agp.c        Thu Aug 28 17:14:45 2003
15386 @@ -39,7 +39,7 @@
15387         pci_write_config_byte(agp_bridge->dev, VIA_APSIZE,
15388                               current_size->size_value);
15389         /* address to map too */
15390 -       pci_read_config_dword(agp_bridge->dev, VIA_APBASE, &temp);
15391 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15392         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15393  
15394         /* GART control register */
15395 @@ -114,7 +114,7 @@
15396         current_size = A_SIZE_16(agp_bridge->current_size);
15397  
15398         /* address to map too */
15399 -       pci_read_config_dword(agp_bridge->dev, VIA_APBASE, &temp);
15400 +       pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
15401         agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
15402  
15403         /* attbase - aperture GATT base */
15404 @@ -215,52 +215,52 @@
15405  {
15406         {
15407                 .device_id      = PCI_DEVICE_ID_VIA_82C597_0,
15408 -               .chipset_name   = "VP3",
15409 +               .chipset_name   = "Apollo VP3",
15410         },
15411  
15412         {
15413                 .device_id      = PCI_DEVICE_ID_VIA_82C598_0,
15414 -               .chipset_name   = "MVP3",
15415 +               .chipset_name   = "Apollo MVP3",
15416         },
15417  
15418         {
15419                 .device_id      = PCI_DEVICE_ID_VIA_8501_0,
15420 -               .chipset_name   = "MVP4",
15421 +               .chipset_name   = "Apollo MVP4",
15422         },
15423  
15424         /* VT8601 */
15425         {
15426                 .device_id      = PCI_DEVICE_ID_VIA_8601_0,
15427 -               .chipset_name   = "PLE133 ProMedia",
15428 +               .chipset_name   = "Apollo ProMedia/PLE133Ta",
15429         },
15430  
15431         /* VT82C693A / VT28C694T */
15432         {
15433 -               .device_id      = PCI_DEVICE_ID_VIA_82C691,
15434 +               .device_id      = PCI_DEVICE_ID_VIA_82C691_0,
15435                 .chipset_name   = "Apollo Pro 133",
15436         },
15437  
15438         {
15439                 .device_id      = PCI_DEVICE_ID_VIA_8371_0,
15440 -               .chipset_name   = "Apollo Pro KX133",
15441 +               .chipset_name   = "KX133",
15442         },
15443  
15444         /* VT8633 */
15445         {
15446                 .device_id      = PCI_DEVICE_ID_VIA_8633_0,
15447 -               .chipset_name   = "Apollo Pro 266",
15448 +               .chipset_name   = "Pro 266",
15449         },
15450  
15451         /* VT8361 */
15452         {
15453                 .device_id      = PCI_DEVICE_ID_VIA_8361,
15454 -               .chipset_name   = "Apollo KLE133",
15455 +               .chipset_name   = "KLE133",
15456         },
15457  
15458         /* VT8365 / VT8362 */
15459         {
15460                 .device_id      = PCI_DEVICE_ID_VIA_8363_0,
15461 -               .chipset_name   = "Apollo Pro KT133/KM133/TwisterK",
15462 +               .chipset_name   = "Twister-K/KT133x/KM133",
15463         },
15464  
15465         /* VT8753A */
15466 @@ -272,79 +272,79 @@
15467         /* VT8366 */
15468         {
15469                 .device_id      = PCI_DEVICE_ID_VIA_8367_0,
15470 -               .chipset_name   = "Apollo Pro KT266/KT333",
15471 +               .chipset_name   = "KT266/KY266x/KT333",
15472         },
15473  
15474         /* VT8633 (for CuMine/ Celeron) */
15475         {
15476                 .device_id      = PCI_DEVICE_ID_VIA_8653_0,
15477 -               .chipset_name   = "Apollo Pro 266T",
15478 +               .chipset_name   = "Pro266T",
15479         },
15480  
15481         /* KM266 / PM266 */
15482         {
15483 -               .device_id      = PCI_DEVICE_ID_VIA_KM266,
15484 -               .chipset_name   = "KM266/PM266",
15485 +               .device_id      = PCI_DEVICE_ID_VIA_XM266,
15486 +               .chipset_name   = "PM266/KM266",
15487         },
15488  
15489         /* CLE266 */
15490         {
15491 -               .device_id      = PCI_DEVICE_ID_VIA_CLE266,
15492 +               .device_id      = PCI_DEVICE_ID_VIA_862X_0,
15493                 .chipset_name   = "CLE266",
15494         },
15495  
15496         {
15497                 .device_id      = PCI_DEVICE_ID_VIA_8377_0,
15498 -               .chipset_name   = "Apollo Pro KT400",
15499 +               .chipset_name   = "KT400/KT400A/KT600",
15500         },
15501  
15502 -       /* VT8604 / VT8605 / VT8603 / TwisterT
15503 +       /* VT8604 / VT8605 / VT8603
15504          * (Apollo Pro133A chipset with S3 Savage4) */
15505         {
15506 -               .device_id      = PCI_DEVICE_ID_VIA_82C694X_0,
15507 -               .chipset_name   = "Apollo ProSavage PM133/PL133/PN133/Twister"
15508 +               .device_id      = PCI_DEVICE_ID_VIA_8605_0,
15509 +               .chipset_name   = "ProSavage PM133/PL133/PN133"
15510         },
15511  
15512 -       /* VT8752*/
15513 +       /* P4M266x/P4N266 */
15514         {
15515 -               .device_id      = PCI_DEVICE_ID_VIA_8752,
15516 -               .chipset_name   = "ProSavage DDR P4M266",
15517 +               .device_id      = PCI_DEVICE_ID_VIA_8703_51_0,
15518 +               .chipset_name   = "P4M266x/P4N266",
15519         },
15520  
15521 -       /* KN266/PN266 */
15522 +       /* VT8754 */
15523         {
15524 -               .device_id      = PCI_DEVICE_ID_VIA_KN266,
15525 -               .chipset_name   = "KN266/PN266",
15526 +               .device_id      = PCI_DEVICE_ID_VIA_8754C_0,
15527 +               .chipset_name   = "PT800",
15528         },
15529  
15530 -       /* VT8754 */
15531 +       /* P4X600 */
15532         {
15533 -               .device_id      = PCI_DEVICE_ID_VIA_8754,
15534 -               .chipset_name   = "Apollo P4X333/P4X400"
15535 +               .device_id      = PCI_DEVICE_ID_VIA_8763_0,
15536 +               .chipset_name   = "P4X600"
15537         },
15538  
15539 -       /* P4N333 */
15540 +       /* KM400 */
15541         {
15542 -               .device_id      = PCI_DEVICE_ID_VIA_P4N333,
15543 -               .chipset_name   = "P4N333",
15544 +               .device_id      = PCI_DEVICE_ID_VIA_8378_0,
15545 +               .chipset_name   = "KM400/KM400A",
15546         },
15547  
15548 -       /* P4X600 */
15549 +       /* PT880 */
15550         {
15551 -               .device_id      = PCI_DEVICE_ID_VIA_P4X600,
15552 -               .chipset_name   = "P4X600",
15553 +               .device_id      = PCI_DEVICE_ID_VIA_PT880,
15554 +               .chipset_name   = "PT880",
15555         },
15556  
15557 -       /* KM400 */
15558 +       /* PT890 */
15559         {
15560 -               .device_id      = PCI_DEVICE_ID_VIA_KM400,
15561 -               .chipset_name   = "KM400",
15562 +               .device_id      = PCI_DEVICE_ID_VIA_8783_0,
15563 +               .chipset_name   = "PT890",
15564         },
15565  
15566 -       /* P4M400 */
15567 +       /* PM800/PN800/PM880/PN880 */
15568         {
15569 -               .device_id      = PCI_DEVICE_ID_VIA_P4M400,
15570 -               .chipset_name   = "P4M400",
15571 +               .device_id      = PCI_DEVICE_ID_VIA_PX8X0_0,
15572 +               .chipset_name   = "PM800/PN800/PM880/PN880",
15573         },
15574  
15575         { }, /* dummy final entry, always present */
15576 diff -Nru a/drivers/char/busmouse.c b/drivers/char/busmouse.c
15577 --- a/drivers/char/busmouse.c   Fri Jul 11 23:17:17 2003
15578 +++ b/drivers/char/busmouse.c   Tue Aug 26 09:25:41 2003
15579 @@ -51,7 +51,7 @@
15580  
15581  #define NR_MICE                        15
15582  #define FIRST_MOUSE            0
15583 -#define DEV_TO_MOUSE(dev)      MINOR_TO_MOUSE(minor(dev))
15584 +#define DEV_TO_MOUSE(inode)    MINOR_TO_MOUSE(iminor(inode))
15585  #define MINOR_TO_MOUSE(minor)  ((minor) - FIRST_MOUSE)
15586  
15587  /*
15588 @@ -190,7 +190,7 @@
15589         unsigned int mousedev;
15590         int ret;
15591  
15592 -       mousedev = DEV_TO_MOUSE(inode->i_rdev);
15593 +       mousedev = DEV_TO_MOUSE(inode);
15594         if (mousedev >= NR_MICE)
15595                 return -EINVAL;
15596  
15597 diff -Nru a/drivers/char/cyclades.c b/drivers/char/cyclades.c
15598 --- a/drivers/char/cyclades.c   Fri Aug  1 02:20:44 2003
15599 +++ b/drivers/char/cyclades.c   Sun Aug 31 16:14:39 2003
15600 @@ -1050,14 +1050,14 @@
15601      udelay(5000L);
15602  
15603      /* Enable the Tx interrupts on the CD1400 */
15604 -    save_flags(flags); cli();
15605 +    local_irq_save(flags);
15606         cy_writeb((u_long)address + (CyCAR<<index), 0);
15607         cyy_issue_cmd(address, CyCHAN_CTL|CyENB_XMTR, index);
15608  
15609         cy_writeb((u_long)address + (CyCAR<<index), 0);
15610         cy_writeb((u_long)address + (CySRER<<index), 
15611                 cy_readb(address + (CySRER<<index)) | CyTxRdy);
15612 -    restore_flags(flags);
15613 +    local_irq_restore(flags);
15614  
15615      /* Wait ... */
15616      udelay(5000L);
15617 @@ -5665,7 +5665,7 @@
15618  cy_cleanup_module(void)
15619  {
15620      int i;
15621 -    int e1;
15622 +    int e1, e2;
15623      unsigned long flags;
15624  
15625  #ifndef CONFIG_CYZ_INTR
15626 @@ -5675,13 +5675,10 @@
15627      }
15628  #endif /* CONFIG_CYZ_INTR */
15629  
15630 -    save_flags(flags); cli();
15631 -
15632      if ((e1 = tty_unregister_driver(cy_serial_driver)))
15633              printk("cyc: failed to unregister Cyclades serial driver(%d)\n",
15634                 e1);
15635  
15636 -    restore_flags(flags);
15637      put_tty_driver(cy_serial_driver);
15638  
15639      for (i = 0; i < NR_CARDS; i++) {
15640 diff -Nru a/drivers/char/drm/drm_drv.h b/drivers/char/drm/drm_drv.h
15641 --- a/drivers/char/drm/drm_drv.h        Thu Aug  7 15:37:26 2003
15642 +++ b/drivers/char/drm/drm_drv.h        Tue Aug 26 09:25:41 2003
15643 @@ -795,7 +795,7 @@
15644         int i;
15645  
15646         for (i = 0; i < DRM(numdevs); i++) {
15647 -               if (minor(inode->i_rdev) == DRM(minor)[i]) {
15648 +               if (iminor(inode) == DRM(minor)[i]) {
15649                         dev = &(DRM(device)[i]);
15650                         break;
15651                 }
15652 diff -Nru a/drivers/char/drm/drm_fops.h b/drivers/char/drm/drm_fops.h
15653 --- a/drivers/char/drm/drm_fops.h       Thu Jul 10 23:18:01 2003
15654 +++ b/drivers/char/drm/drm_fops.h       Tue Aug 26 09:25:41 2003
15655 @@ -51,7 +51,7 @@
15656   */
15657  int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
15658  {
15659 -       int          minor = minor(inode->i_rdev);
15660 +       int          minor = iminor(inode);
15661         drm_file_t   *priv;
15662  
15663         if (filp->f_flags & O_EXCL)   return -EBUSY; /* No exclusive opens */
15664 diff -Nru a/drivers/char/drm/drm_stub.h b/drivers/char/drm/drm_stub.h
15665 --- a/drivers/char/drm/drm_stub.h       Thu Jul 10 23:18:01 2003
15666 +++ b/drivers/char/drm/drm_stub.h       Tue Aug 26 09:25:41 2003
15667 @@ -62,7 +62,7 @@
15668   */
15669  static int DRM(stub_open)(struct inode *inode, struct file *filp)
15670  {
15671 -       int                    minor = minor(inode->i_rdev);
15672 +       int                    minor = iminor(inode);
15673         int                    err   = -ENODEV;
15674         struct file_operations *old_fops;
15675  
15676 diff -Nru a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
15677 --- a/drivers/char/dsp56k.c     Wed May  7 08:47:29 2003
15678 +++ b/drivers/char/dsp56k.c     Tue Aug 26 09:25:41 2003
15679 @@ -207,7 +207,7 @@
15680                            loff_t *ppos)
15681  {
15682         struct inode *inode = file->f_dentry->d_inode;
15683 -       int dev = minor(inode->i_rdev) & 0x0f;
15684 +       int dev = iminor(inode) & 0x0f;
15685  
15686         switch(dev)
15687         {
15688 @@ -270,7 +270,7 @@
15689                             loff_t *ppos)
15690  {
15691         struct inode *inode = file->f_dentry->d_inode;
15692 -       int dev = minor(inode->i_rdev) & 0x0f;
15693 +       int dev = iminor(inode) & 0x0f;
15694  
15695         switch(dev)
15696         {
15697 @@ -331,7 +331,7 @@
15698  static int dsp56k_ioctl(struct inode *inode, struct file *file,
15699                         unsigned int cmd, unsigned long arg)
15700  {
15701 -       int dev = minor(inode->i_rdev) & 0x0f;
15702 +       int dev = iminor(inode) & 0x0f;
15703  
15704         switch(dev)
15705         {
15706 @@ -424,7 +424,7 @@
15707  #if 0
15708  static unsigned int dsp56k_poll(struct file *file, poll_table *wait)
15709  {
15710 -       int dev = minor(file->f_dentry->d_inode->i_rdev) & 0x0f;
15711 +       int dev = iminor(file->f_dentry->d_inode) & 0x0f;
15712  
15713         switch(dev)
15714         {
15715 @@ -441,7 +441,7 @@
15716  
15717  static int dsp56k_open(struct inode *inode, struct file *file)
15718  {
15719 -       int dev = minor(inode->i_rdev) & 0x0f;
15720 +       int dev = iminor(inode) & 0x0f;
15721  
15722         switch(dev)
15723         {
15724 @@ -472,7 +472,7 @@
15725  
15726  static int dsp56k_release(struct inode *inode, struct file *file)
15727  {
15728 -       int dev = minor(inode->i_rdev) & 0x0f;
15729 +       int dev = iminor(inode) & 0x0f;
15730  
15731         switch(dev)
15732         {
15733 diff -Nru a/drivers/char/dtlk.c b/drivers/char/dtlk.c
15734 --- a/drivers/char/dtlk.c       Fri Jul 11 06:34:28 2003
15735 +++ b/drivers/char/dtlk.c       Tue Aug 26 09:25:41 2003
15736 @@ -125,7 +125,7 @@
15737  static ssize_t dtlk_read(struct file *file, char *buf,
15738                          size_t count, loff_t * ppos)
15739  {
15740 -       unsigned int minor = minor(file->f_dentry->d_inode->i_rdev);
15741 +       unsigned int minor = iminor(file->f_dentry->d_inode);
15742         char ch;
15743         int i = 0, retries;
15744  
15745 @@ -185,7 +185,7 @@
15746         if (ppos != &file->f_pos)
15747                 return -ESPIPE;
15748  
15749 -       if (minor(file->f_dentry->d_inode->i_rdev) != DTLK_MINOR)
15750 +       if (iminor(file->f_dentry->d_inode) != DTLK_MINOR)
15751                 return -EINVAL;
15752  
15753         while (1) {
15754 @@ -304,7 +304,7 @@
15755  {
15756         TRACE_TEXT("(dtlk_open");
15757  
15758 -       switch (minor(inode->i_rdev)) {
15759 +       switch (iminor(inode)) {
15760         case DTLK_MINOR:
15761                 if (dtlk_busy)
15762                         return -EBUSY;
15763 @@ -319,7 +319,7 @@
15764  {
15765         TRACE_TEXT("(dtlk_release");
15766  
15767 -       switch (minor(inode->i_rdev)) {
15768 +       switch (iminor(inode)) {
15769         case DTLK_MINOR:
15770                 break;
15771  
15772 diff -Nru a/drivers/char/ftape/lowlevel/fdc-io.c b/drivers/char/ftape/lowlevel/fdc-io.c
15773 --- a/drivers/char/ftape/lowlevel/fdc-io.c      Tue Jul 15 10:01:29 2003
15774 +++ b/drivers/char/ftape/lowlevel/fdc-io.c      Sun Aug 31 16:13:58 2003
15775 @@ -1305,7 +1305,7 @@
15776         } else {
15777                 TRACE(ft_t_bug, "Unexpected ftape interrupt");
15778         }
15779 -       return IRQ_RETVAL(handled);
15780 +       TRACE_EXIT IRQ_RETVAL(handled);
15781  }
15782  
15783  int fdc_grab_irq_and_dma(void)
15784 diff -Nru a/drivers/char/ftape/zftape/zftape-init.c b/drivers/char/ftape/zftape/zftape-init.c
15785 --- a/drivers/char/ftape/zftape/zftape-init.c   Tue Jul 15 10:01:29 2003
15786 +++ b/drivers/char/ftape/zftape/zftape-init.c   Tue Aug 26 09:25:41 2003
15787 @@ -110,11 +110,11 @@
15788         int result;
15789         TRACE_FUN(ft_t_flow);
15790  
15791 -       TRACE(ft_t_flow, "called for minor %d", minor(ino->i_rdev));
15792 +       TRACE(ft_t_flow, "called for minor %d", iminor(ino));
15793         if ( test_and_set_bit(0,&busy_flag) ) {
15794                 TRACE_ABORT(-EBUSY, ft_t_warn, "failed: already busy");
15795         }
15796 -       if ((minor(ino->i_rdev) & ~(ZFT_MINOR_OP_MASK | FTAPE_NO_REWIND))
15797 +       if ((iminor(ino) & ~(ZFT_MINOR_OP_MASK | FTAPE_NO_REWIND))
15798              > 
15799             FTAPE_SEL_D) {
15800                 clear_bit(0,&busy_flag);
15801 @@ -122,7 +122,7 @@
15802         }
15803         orig_sigmask = current->blocked;
15804         sigfillset(&current->blocked);
15805 -       result = _zft_open(minor(ino->i_rdev), filep->f_flags & O_ACCMODE);
15806 +       result = _zft_open(iminor(ino), filep->f_flags & O_ACCMODE);
15807         if (result < 0) {
15808                 current->blocked = orig_sigmask; /* restore mask */
15809                 clear_bit(0,&busy_flag);
15810 @@ -144,7 +144,7 @@
15811         int result;
15812         TRACE_FUN(ft_t_flow);
15813  
15814 -       if ( !test_bit(0,&busy_flag) || minor(ino->i_rdev) != zft_unit) {
15815 +       if ( !test_bit(0,&busy_flag) || iminor(ino) != zft_unit) {
15816                 TRACE(ft_t_err, "failed: not busy or wrong unit");
15817                 TRACE_EXIT 0;
15818         }
15819 @@ -167,7 +167,7 @@
15820         sigset_t old_sigmask;
15821         TRACE_FUN(ft_t_flow);
15822  
15823 -       if ( !test_bit(0,&busy_flag) || minor(ino->i_rdev) != zft_unit || ft_failure) {
15824 +       if ( !test_bit(0,&busy_flag) || iminor(ino) != zft_unit || ft_failure) {
15825                 TRACE_ABORT(-EIO, ft_t_err,
15826                             "failed: not busy, failure or wrong unit");
15827         }
15828 @@ -188,7 +188,7 @@
15829         TRACE_FUN(ft_t_flow);
15830  
15831         if ( !test_bit(0,&busy_flag) || 
15832 -           minor(filep->f_dentry->d_inode->i_rdev) != zft_unit || 
15833 +           iminor(filep->f_dentry->d_inode) != zft_unit || 
15834             ft_failure)
15835         {
15836                 TRACE_ABORT(-EIO, ft_t_err,
15837 @@ -217,7 +217,7 @@
15838         TRACE_FUN(ft_t_flow);
15839  
15840         TRACE(ft_t_data_flow, "called with count: %ld", (unsigned long)req_len);
15841 -       if (!test_bit(0,&busy_flag)  || minor(ino->i_rdev) != zft_unit || ft_failure) {
15842 +       if (!test_bit(0,&busy_flag)  || iminor(ino) != zft_unit || ft_failure) {
15843                 TRACE_ABORT(-EIO, ft_t_err,
15844                             "failed: not busy, failure or wrong unit");
15845         }
15846 @@ -240,7 +240,7 @@
15847         TRACE_FUN(ft_t_flow);
15848  
15849         TRACE(ft_t_flow, "called with count: %ld", (unsigned long)req_len);
15850 -       if (!test_bit(0,&busy_flag) || minor(ino->i_rdev) != zft_unit || ft_failure) {
15851 +       if (!test_bit(0,&busy_flag) || iminor(ino) != zft_unit || ft_failure) {
15852                 TRACE_ABORT(-EIO, ft_t_err,
15853                             "failed: not busy, failure or wrong unit");
15854         }
15855 diff -Nru a/drivers/char/ip2main.c b/drivers/char/ip2main.c
15856 --- a/drivers/char/ip2main.c    Mon Jul 14 06:47:09 2003
15857 +++ b/drivers/char/ip2main.c    Tue Aug 26 09:25:41 2003
15858 @@ -2733,7 +2733,7 @@
15859  ssize_t
15860  ip2_ipl_read(struct file *pFile, char *pData, size_t count, loff_t *off )
15861  {
15862 -       unsigned int minor = minor( pFile->f_dentry->d_inode->i_rdev );
15863 +       unsigned int minor = iminor(pFile->f_dentry->d_inode);
15864         int rc = 0;
15865  
15866  #ifdef IP2DEBUG_IPL
15867 @@ -2863,7 +2863,7 @@
15868  static int
15869  ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg )
15870  {
15871 -       unsigned int iplminor = minor(pInode->i_rdev);
15872 +       unsigned int iplminor = iminor(pInode);
15873         int rc = 0;
15874         ULONG *pIndex = (ULONG*)arg;
15875         i2eBordStrPtr pB = i2BoardPtrTable[iplminor / 4];
15876 @@ -2998,7 +2998,7 @@
15877  static int
15878  ip2_ipl_open( struct inode *pInode, struct file *pFile )
15879  {
15880 -       unsigned int iplminor = minor(pInode->i_rdev);
15881 +       unsigned int iplminor = iminor(pInode);
15882         i2eBordStrPtr pB;
15883         i2ChanStrPtr  pCh;
15884  
15885 diff -Nru a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
15886 --- a/drivers/char/ipmi/ipmi_devintf.c  Wed May  7 08:47:29 2003
15887 +++ b/drivers/char/ipmi/ipmi_devintf.c  Tue Aug 26 09:25:41 2003
15888 @@ -110,7 +110,7 @@
15889  
15890  static int ipmi_open(struct inode *inode, struct file *file)
15891  {
15892 -       int                      if_num = minor(inode->i_rdev);
15893 +       int                      if_num = iminor(inode);
15894         int                      rv;
15895         struct ipmi_file_private *priv;
15896  
15897 diff -Nru a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
15898 --- a/drivers/char/ipmi/ipmi_watchdog.c Mon Aug 11 04:34:37 2003
15899 +++ b/drivers/char/ipmi/ipmi_watchdog.c Tue Aug 26 09:25:41 2003
15900 @@ -645,7 +645,7 @@
15901  
15902  static int ipmi_open(struct inode *ino, struct file *filep)
15903  {
15904 -        switch (minor(ino->i_rdev))
15905 +        switch (iminor(ino))
15906          {
15907                  case WATCHDOG_MINOR:
15908                      if (ipmi_wdog_open)
15909 @@ -688,7 +688,7 @@
15910  
15911  static int ipmi_close(struct inode *ino, struct file *filep)
15912  {
15913 -       if (minor(ino->i_rdev)==WATCHDOG_MINOR)
15914 +       if (iminor(ino)==WATCHDOG_MINOR)
15915         {
15916  #ifndef CONFIG_WATCHDOG_NOWAYOUT       
15917                 ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
15918 diff -Nru a/drivers/char/istallion.c b/drivers/char/istallion.c
15919 --- a/drivers/char/istallion.c  Mon Jun 23 18:43:58 2003
15920 +++ b/drivers/char/istallion.c  Tue Aug 26 09:25:41 2003
15921 @@ -4805,7 +4805,7 @@
15922                         (int) fp, (int) buf, count, (int) offp);
15923  #endif
15924  
15925 -       brdnr = minor(fp->f_dentry->d_inode->i_rdev);
15926 +       brdnr = iminor(fp->f_dentry->d_inode);
15927         if (brdnr >= stli_nrbrds)
15928                 return(-ENODEV);
15929         brdp = stli_brds[brdnr];
15930 @@ -4860,7 +4860,7 @@
15931                         (int) fp, (int) buf, count, (int) offp);
15932  #endif
15933  
15934 -       brdnr = minor(fp->f_dentry->d_inode->i_rdev);
15935 +       brdnr = iminor(fp->f_dentry->d_inode);
15936         if (brdnr >= stli_nrbrds)
15937                 return(-ENODEV);
15938         brdp = stli_brds[brdnr];
15939 @@ -5201,7 +5201,7 @@
15940   *     Now handle the board specific ioctls. These all depend on the
15941   *     minor number of the device they were called from.
15942   */
15943 -       brdnr = minor(ip->i_rdev);
15944 +       brdnr = iminor(ip);
15945         if (brdnr >= STL_MAXBRDS)
15946                 return(-ENODEV);
15947         brdp = stli_brds[brdnr];
15948 diff -Nru a/drivers/char/ite_gpio.c b/drivers/char/ite_gpio.c
15949 --- a/drivers/char/ite_gpio.c   Thu Mar  6 14:03:51 2003
15950 +++ b/drivers/char/ite_gpio.c   Tue Aug 26 09:25:41 2003
15951 @@ -238,7 +238,7 @@
15952  
15953  static int ite_gpio_open(struct inode *inode, struct file *file)
15954  {
15955 -       unsigned int minor = minor(inode->i_rdev); 
15956 +       unsigned int minor = iminor(inode); 
15957         if (minor != GPIO_MINOR)
15958                 return -ENODEV;
15959  
15960 diff -Nru a/drivers/char/lcd.c b/drivers/char/lcd.c
15961 --- a/drivers/char/lcd.c        Wed May 29 12:05:13 2002
15962 +++ b/drivers/char/lcd.c        Sun Aug 31 16:14:08 2003
15963 @@ -551,9 +551,9 @@
15964   */
15965  
15966  static struct file_operations lcd_fops = {
15967 -       read:           lcd_read,
15968 -       ioctl:          lcd_ioctl,
15969 -       open:           lcd_open,
15970 +       .read           = lcd_read,
15971 +       .ioctl          = lcd_ioctl,
15972 +       .open           = lcd_open,
15973  };
15974  
15975  static struct miscdevice lcd_dev=
15976 diff -Nru a/drivers/char/lp.c b/drivers/char/lp.c
15977 --- a/drivers/char/lp.c Wed May  7 08:47:29 2003
15978 +++ b/drivers/char/lp.c Tue Aug 26 09:25:41 2003
15979 @@ -292,7 +292,7 @@
15980  static ssize_t lp_write(struct file * file, const char * buf,
15981                         size_t count, loff_t *ppos)
15982  {
15983 -       unsigned int minor = minor(file->f_dentry->d_inode->i_rdev);
15984 +       unsigned int minor = iminor(file->f_dentry->d_inode);
15985         struct parport *port = lp_table[minor].dev->port;
15986         char *kbuf = lp_table[minor].lp_buffer;
15987         ssize_t retv = 0;
15988 @@ -408,7 +408,7 @@
15989  static ssize_t lp_read(struct file * file, char * buf,
15990                        size_t count, loff_t *ppos)
15991  {
15992 -       unsigned int minor=minor(file->f_dentry->d_inode->i_rdev);
15993 +       unsigned int minor=iminor(file->f_dentry->d_inode);
15994         struct parport *port = lp_table[minor].dev->port;
15995         ssize_t retval = 0;
15996         char *kbuf = lp_table[minor].lp_buffer;
15997 @@ -483,7 +483,7 @@
15998  
15999  static int lp_open(struct inode * inode, struct file * file)
16000  {
16001 -       unsigned int minor = minor(inode->i_rdev);
16002 +       unsigned int minor = iminor(inode);
16003  
16004         if (minor >= LP_NO)
16005                 return -ENXIO;
16006 @@ -540,7 +540,7 @@
16007  
16008  static int lp_release(struct inode * inode, struct file * file)
16009  {
16010 -       unsigned int minor = minor(inode->i_rdev);
16011 +       unsigned int minor = iminor(inode);
16012  
16013         lp_claim_parport_or_block (&lp_table[minor]);
16014         parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT);
16015 @@ -555,7 +555,7 @@
16016  static int lp_ioctl(struct inode *inode, struct file *file,
16017                     unsigned int cmd, unsigned long arg)
16018  {
16019 -       unsigned int minor = minor(inode->i_rdev);
16020 +       unsigned int minor = iminor(inode);
16021         int status;
16022         int retval = 0;
16023  
16024 diff -Nru a/drivers/char/lp_old98.c b/drivers/char/lp_old98.c
16025 --- a/drivers/char/lp_old98.c   Thu Apr 24 03:30:40 2003
16026 +++ b/drivers/char/lp_old98.c   Tue Aug 26 09:25:41 2003
16027 @@ -219,7 +219,7 @@
16028  
16029  static int lp_old98_open(struct inode * inode, struct file * file)
16030  {
16031 -       if (minor(inode->i_rdev) != 0)
16032 +       if (iminor(inode) != 0)
16033                 return -ENXIO;
16034  
16035         if (lp.flags & LP_BUSY)
16036 diff -Nru a/drivers/char/mem.c b/drivers/char/mem.c
16037 --- a/drivers/char/mem.c        Tue Jun 10 23:33:17 2003
16038 +++ b/drivers/char/mem.c        Tue Aug 26 09:25:41 2003
16039 @@ -607,7 +607,7 @@
16040  
16041  static int memory_open(struct inode * inode, struct file * filp)
16042  {
16043 -       switch (minor(inode->i_rdev)) {
16044 +       switch (iminor(inode)) {
16045                 case 1:
16046                         filp->f_op = &mem_fops;
16047                         break;
16048 diff -Nru a/drivers/char/misc.c b/drivers/char/misc.c
16049 --- a/drivers/char/misc.c       Sat May 17 12:39:13 2003
16050 +++ b/drivers/char/misc.c       Tue Aug 26 09:25:41 2003
16051 @@ -100,7 +100,7 @@
16052  
16053  static int misc_open(struct inode * inode, struct file * file)
16054  {
16055 -       int minor = minor(inode->i_rdev);
16056 +       int minor = iminor(inode);
16057         struct miscdevice *c;
16058         int err = -ENODEV;
16059         struct file_operations *old_fops, *new_fops = NULL;
16060 diff -Nru a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c
16061 --- a/drivers/char/n_hdlc.c     Fri May 30 19:53:01 2003
16062 +++ b/drivers/char/n_hdlc.c     Sun Aug 31 16:14:27 2003
16063 @@ -182,9 +182,9 @@
16064  
16065  /* TTY callbacks */
16066  
16067 -static int n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
16068 +static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
16069                            __u8 *buf, size_t nr);
16070 -static int n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
16071 +static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
16072                             const __u8 *buf, size_t nr);
16073  static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file,
16074                             unsigned int cmd, unsigned long arg);
16075 @@ -572,7 +572,7 @@
16076   *     
16077   * Returns the number of bytes returned or error code.
16078   */
16079 -static int n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
16080 +static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
16081                            __u8 *buf, size_t nr)
16082  {
16083         struct n_hdlc *n_hdlc = tty2n_hdlc(tty);
16084 @@ -649,7 +649,7 @@
16085   *             
16086   * Returns the number of bytes written (or error code).
16087   */
16088 -static int n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
16089 +static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
16090                             const __u8 *data, size_t count)
16091  {
16092         struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
16093 @@ -658,7 +658,7 @@
16094         struct n_hdlc_buf *tbuf;
16095  
16096         if (debuglevel >= DEBUG_LEVEL_INFO)     
16097 -               printk("%s(%d)n_hdlc_tty_write() called count=%d\n",
16098 +               printk("%s(%d)n_hdlc_tty_write() called count=%Zd\n",
16099                         __FILE__,__LINE__,count);
16100                 
16101         /* Verify pointers */
16102 @@ -673,7 +673,7 @@
16103                 if (debuglevel & DEBUG_LEVEL_INFO)
16104                         printk (KERN_WARNING
16105                                 "n_hdlc_tty_write: truncating user packet "
16106 -                               "from %lu to %d\n", (unsigned long) count,
16107 +                               "from %lu to %Zd\n", (unsigned long) count,
16108                                 maxframe );
16109                 count = maxframe;
16110         }
16111 diff -Nru a/drivers/char/pcxx.c b/drivers/char/pcxx.c
16112 --- a/drivers/char/pcxx.c       Wed Aug 20 14:20:10 2003
16113 +++ b/drivers/char/pcxx.c       Sun Aug 31 16:14:07 2003
16114 @@ -121,7 +121,7 @@
16115  MODULE_PARM(altpin,      "1-4i");
16116  MODULE_PARM(numports,    "1-4i");
16117  
16118 -#endif MODULE
16119 +#endif /* MODULE */
16120  
16121  static int numcards = 1;
16122  static int nbdevs = 0;
16123 diff -Nru a/drivers/char/ppdev.c b/drivers/char/ppdev.c
16124 --- a/drivers/char/ppdev.c      Wed May  7 08:47:29 2003
16125 +++ b/drivers/char/ppdev.c      Tue Aug 26 09:25:41 2003
16126 @@ -104,7 +104,7 @@
16127  static ssize_t pp_read (struct file * file, char * buf, size_t count,
16128                         loff_t * ppos)
16129  {
16130 -       unsigned int minor = minor (file->f_dentry->d_inode->i_rdev);
16131 +       unsigned int minor = iminor(file->f_dentry->d_inode);
16132         struct pp_struct *pp = file->private_data;
16133         char * kbuffer;
16134         ssize_t bytes_read = 0;
16135 @@ -187,7 +187,7 @@
16136  static ssize_t pp_write (struct file * file, const char * buf, size_t count,
16137                          loff_t * ppos)
16138  {
16139 -       unsigned int minor = minor (file->f_dentry->d_inode->i_rdev);
16140 +       unsigned int minor = iminor(file->f_dentry->d_inode);
16141         struct pp_struct *pp = file->private_data;
16142         char * kbuffer;
16143         ssize_t bytes_written = 0;
16144 @@ -330,7 +330,7 @@
16145  static int pp_ioctl(struct inode *inode, struct file *file,
16146                     unsigned int cmd, unsigned long arg)
16147  {
16148 -       unsigned int minor = minor(inode->i_rdev);
16149 +       unsigned int minor = iminor(inode);
16150         struct pp_struct *pp = file->private_data;
16151         struct parport * port;
16152  
16153 @@ -638,7 +638,7 @@
16154  
16155  static int pp_open (struct inode * inode, struct file * file)
16156  {
16157 -       unsigned int minor = minor (inode->i_rdev);
16158 +       unsigned int minor = iminor(inode);
16159         struct pp_struct *pp;
16160  
16161         if (minor >= PARPORT_MAX)
16162 @@ -667,7 +667,7 @@
16163  
16164  static int pp_release (struct inode * inode, struct file * file)
16165  {
16166 -       unsigned int minor = minor (inode->i_rdev);
16167 +       unsigned int minor = iminor(inode);
16168         struct pp_struct *pp = file->private_data;
16169         int compat_negot;
16170  
16171 diff -Nru a/drivers/char/random.c b/drivers/char/random.c
16172 --- a/drivers/char/random.c     Wed Aug  6 10:59:31 2003
16173 +++ b/drivers/char/random.c     Sun Aug 31 16:13:54 2003
16174 @@ -269,9 +269,9 @@
16175  
16176  /*
16177   * The minimum number of bits of entropy before we wake up a read on
16178 - * /dev/random.  Should always be at least 8, or at least 1 byte.
16179 + * /dev/random.  Should be enough to do a significant reseed.
16180   */
16181 -static int random_read_wakeup_thresh = 8;
16182 +static int random_read_wakeup_thresh = 64;
16183  
16184  /*
16185   * If the entropy count falls under this number of bits, then we
16186 @@ -483,9 +483,9 @@
16187         unsigned        add_ptr;
16188         int             entropy_count;
16189         int             input_rotate;
16190 -       int             extract_count;
16191         struct poolinfo poolinfo;
16192         __u32           *pool;
16193 +       spinlock_t lock;
16194  };
16195  
16196  /*
16197 @@ -502,7 +502,7 @@
16198  
16199         poolwords = (size + 3) / 4; /* Convert bytes->words */
16200         /* The pool size must be a multiple of 16 32-bit words */
16201 -       poolwords = ((poolwords + 15) / 16) * 16; 
16202 +       poolwords = ((poolwords + 15) / 16) * 16;
16203  
16204         for (p = poolinfo_table; p->poolwords; p++) {
16205                 if (poolwords == p->poolwords)
16206 @@ -524,6 +524,7 @@
16207                 return -ENOMEM;
16208         }
16209         memset(r->pool, 0, POOLBYTES);
16210 +       r->lock = SPIN_LOCK_UNLOCKED;
16211         *ret_bucket = r;
16212         return 0;
16213  }
16214 @@ -534,7 +535,6 @@
16215         r->add_ptr = 0;
16216         r->entropy_count = 0;
16217         r->input_rotate = 0;
16218 -       r->extract_count = 0;
16219         memset(r->pool, 0, r->poolinfo.POOLBYTES);
16220  }
16221  #ifdef CONFIG_SYSCTL
16222 @@ -565,6 +565,9 @@
16223         int new_rotate;
16224         int wordmask = r->poolinfo.poolwords - 1;
16225         __u32 w;
16226 +       unsigned long flags;
16227 +
16228 +       spin_lock_irqsave(&r->lock, flags);
16229  
16230         while (nwords--) {
16231                 w = rotate_left(r->input_rotate, *in++);
16232 @@ -589,6 +592,8 @@
16233                 w ^= r->pool[i];
16234                 r->pool[i] = (w >> 3) ^ twist_table[w & 7];
16235         }
16236 +
16237 +       spin_unlock_irqrestore(&r->lock, flags);
16238  }
16239  
16240  /*
16241 @@ -596,6 +601,10 @@
16242   */
16243  static void credit_entropy_store(struct entropy_store *r, int nbits)
16244  {
16245 +       unsigned long flags;
16246 +
16247 +       spin_lock_irqsave(&r->lock, flags);
16248 +
16249         if (r->entropy_count + nbits < 0) {
16250                 DEBUG_ENT("negative entropy/overflow (%d+%d)\n",
16251                           r->entropy_count, nbits);
16252 @@ -605,11 +614,15 @@
16253         } else {
16254                 r->entropy_count += nbits;
16255                 if (nbits)
16256 -                       DEBUG_ENT("%s added %d bits, now %d\n",
16257 +                       DEBUG_ENT("%04d %04d : added %d bits to %s\n",
16258 +                                 random_state->entropy_count,
16259 +                                 sec_random_state->entropy_count,
16260 +                                 nbits,
16261                                   r == sec_random_state ? "secondary" :
16262 -                                 r == random_state ? "primary" : "unknown",
16263 -                                 nbits, r->entropy_count);
16264 +                                 r == random_state ? "primary" : "unknown");
16265         }
16266 +
16267 +       spin_unlock_irqrestore(&r->lock, flags);
16268  }
16269  
16270  /**********************************************************************
16271 @@ -620,27 +633,33 @@
16272   *
16273   **********************************************************************/
16274  
16275 -static __u32   *batch_entropy_pool;
16276 -static int     *batch_entropy_credit;
16277 -static int     batch_max;
16278 +struct sample {
16279 +       __u32 data[2];
16280 +       int credit;
16281 +};
16282 +
16283 +static struct sample *batch_entropy_pool, *batch_entropy_copy;
16284  static int     batch_head, batch_tail;
16285 +static spinlock_t batch_lock = SPIN_LOCK_UNLOCKED;
16286 +
16287 +static int     batch_max;
16288  static void batch_entropy_process(void *private_);
16289  static DECLARE_WORK(batch_work, batch_entropy_process, NULL);
16290  
16291  /* note: the size must be a power of 2 */
16292  static int __init batch_entropy_init(int size, struct entropy_store *r)
16293  {
16294 -       batch_entropy_pool = kmalloc(2*size*sizeof(__u32), GFP_KERNEL);
16295 +       batch_entropy_pool = kmalloc(size*sizeof(struct sample), GFP_KERNEL);
16296         if (!batch_entropy_pool)
16297                 return -1;
16298 -       batch_entropy_credit =kmalloc(size*sizeof(int), GFP_KERNEL);
16299 -       if (!batch_entropy_credit) {
16300 +       batch_entropy_copy = kmalloc(size*sizeof(struct sample), GFP_KERNEL);
16301 +       if (!batch_entropy_copy) {
16302                 kfree(batch_entropy_pool);
16303                 return -1;
16304         }
16305         batch_head = batch_tail = 0;
16306 -       batch_max = size;
16307         batch_work.data = r;
16308 +       batch_max = size;
16309         return 0;
16310  }
16311  
16312 @@ -652,27 +671,33 @@
16313   */
16314  void batch_entropy_store(u32 a, u32 b, int num)
16315  {
16316 -       int     new;
16317 +       int new;
16318 +       unsigned long flags;
16319  
16320         if (!batch_max)
16321                 return;
16322 -       
16323 -       batch_entropy_pool[2*batch_head] = a;
16324 -       batch_entropy_pool[(2*batch_head) + 1] = b;
16325 -       batch_entropy_credit[batch_head] = num;
16326  
16327 -       new = (batch_head+1) & (batch_max-1);
16328 -       if ((unsigned)(new - batch_tail) >= (unsigned)(batch_max / 2)) {
16329 +       spin_lock_irqsave(&batch_lock, flags);
16330 +
16331 +       batch_entropy_pool[batch_head].data[0] = a;
16332 +       batch_entropy_pool[batch_head].data[1] = b;
16333 +       batch_entropy_pool[batch_head].credit = num;
16334 +
16335 +       if (((batch_head - batch_tail) & (batch_max-1)) >= (batch_max / 2)) {
16336                 /*
16337                  * Schedule it for the next timer tick:
16338                  */
16339                 schedule_delayed_work(&batch_work, 1);
16340 -               batch_head = new;
16341 -       } else if (new == batch_tail) {
16342 +       }
16343 +
16344 +       new = (batch_head+1) & (batch_max-1);
16345 +       if (new == batch_tail) {
16346                 DEBUG_ENT("batch entropy buffer full\n");
16347         } else {
16348                 batch_head = new;
16349         }
16350 +
16351 +       spin_unlock_irqrestore(&batch_lock, flags);
16352  }
16353  
16354  /*
16355 @@ -684,20 +709,34 @@
16356  {
16357         struct entropy_store *r = (struct entropy_store *) private_, *p;
16358         int max_entropy = r->poolinfo.POOLBITS;
16359 +       unsigned head, tail;
16360  
16361 -       if (!batch_max)
16362 -               return;
16363 +       /* Mixing into the pool is expensive, so copy over the batch
16364 +        * data and release the batch lock. The pool is at least half
16365 +        * full, so don't worry too much about copying only the used
16366 +        * part.
16367 +        */
16368 +       spin_lock_irq(&batch_lock);
16369 +
16370 +       memcpy(batch_entropy_copy, batch_entropy_pool,
16371 +              batch_max*sizeof(struct sample));
16372 +
16373 +       head = batch_head;
16374 +       tail = batch_tail;
16375 +       batch_tail = batch_head;
16376 +
16377 +       spin_unlock_irq(&batch_lock);
16378  
16379         p = r;
16380 -       while (batch_head != batch_tail) {
16381 +       while (head != tail) {
16382                 if (r->entropy_count >= max_entropy) {
16383                         r = (r == sec_random_state) ?   random_state :
16384                                                         sec_random_state;
16385                         max_entropy = r->poolinfo.POOLBITS;
16386                 }
16387 -               add_entropy_words(r, batch_entropy_pool + 2*batch_tail, 2);
16388 -               credit_entropy_store(r, batch_entropy_credit[batch_tail]);
16389 -               batch_tail = (batch_tail+1) & (batch_max-1);
16390 +               add_entropy_words(r, batch_entropy_copy[tail].data, 2);
16391 +               credit_entropy_store(r, batch_entropy_copy[tail].credit);
16392 +               tail = (tail+1) & (batch_max-1);
16393         }
16394         if (p->entropy_count >= random_read_wakeup_thresh)
16395                 wake_up_interruptible(&random_read_wait);
16396 @@ -1216,6 +1255,7 @@
16397  
16398  #define EXTRACT_ENTROPY_USER           1
16399  #define EXTRACT_ENTROPY_SECONDARY      2
16400 +#define EXTRACT_ENTROPY_LIMIT          4
16401  #define TMP_BUF_SIZE                   (HASH_BUFFER_SIZE + HASH_EXTRA_SIZE)
16402  #define SEC_XFER_SIZE                  (TMP_BUF_SIZE*4)
16403  
16404 @@ -1224,36 +1264,28 @@
16405  
16406  /*
16407   * This utility inline function is responsible for transfering entropy
16408 - * from the primary pool to the secondary extraction pool.  We pull
16409 - * randomness under two conditions; one is if there isn't enough entropy
16410 - * in the secondary pool.  The other is after we have extracted 1024 bytes,
16411 - * at which point we do a "catastrophic reseeding".
16412 + * from the primary pool to the secondary extraction pool. We make
16413 + * sure we pull enough for a 'catastrophic reseed'.
16414   */
16415  static inline void xfer_secondary_pool(struct entropy_store *r,
16416                                        size_t nbytes, __u32 *tmp)
16417  {
16418         if (r->entropy_count < nbytes * 8 &&
16419             r->entropy_count < r->poolinfo.POOLBITS) {
16420 -               int nwords = min_t(int,
16421 -                                  r->poolinfo.poolwords - r->entropy_count/32,
16422 -                                  sizeof(tmp) / 4);
16423 +               int bytes = max_t(int, random_read_wakeup_thresh / 8,
16424 +                               min_t(int, nbytes, TMP_BUF_SIZE));
16425  
16426 -               DEBUG_ENT("xfer %d from primary to %s (have %d, need %d)\n",
16427 -                         nwords * 32,
16428 +               DEBUG_ENT("%04d %04d : going to reseed %s with %d bits "
16429 +                         "(%d of %d requested)\n",
16430 +                         random_state->entropy_count,
16431 +                         sec_random_state->entropy_count,
16432                           r == sec_random_state ? "secondary" : "unknown",
16433 -                         r->entropy_count, nbytes * 8);
16434 +                         bytes * 8, nbytes * 8, r->entropy_count);
16435  
16436 -               extract_entropy(random_state, tmp, nwords * 4, 0);
16437 -               add_entropy_words(r, tmp, nwords);
16438 -               credit_entropy_store(r, nwords * 32);
16439 -       }
16440 -       if (r->extract_count > 1024) {
16441 -               DEBUG_ENT("reseeding %s with %d from primary\n",
16442 -                         r == sec_random_state ? "secondary" : "unknown",
16443 -                         sizeof(tmp) * 8);
16444 -               extract_entropy(random_state, tmp, sizeof(tmp), 0);
16445 -               add_entropy_words(r, tmp, sizeof(tmp) / 4);
16446 -               r->extract_count = 0;
16447 +               bytes=extract_entropy(random_state, tmp, bytes,
16448 +                                     EXTRACT_ENTROPY_LIMIT);
16449 +               add_entropy_words(r, tmp, bytes);
16450 +               credit_entropy_store(r, bytes*8);
16451         }
16452  }
16453  
16454 @@ -1276,8 +1308,8 @@
16455         ssize_t ret, i;
16456         __u32 tmp[TMP_BUF_SIZE];
16457         __u32 x;
16458 +       unsigned long cpuflags;
16459  
16460 -       add_timer_randomness(&extract_timer_state, nbytes);
16461  
16462         /* Redundant, but just in case... */
16463         if (r->entropy_count > r->poolinfo.POOLBITS)
16464 @@ -1286,10 +1318,18 @@
16465         if (flags & EXTRACT_ENTROPY_SECONDARY)
16466                 xfer_secondary_pool(r, nbytes, tmp);
16467  
16468 -       DEBUG_ENT("%s has %d bits, want %d bits\n",
16469 +       /* Hold lock while accounting */
16470 +       spin_lock_irqsave(&r->lock, cpuflags);
16471 +
16472 +       DEBUG_ENT("%04d %04d : trying to extract %d bits from %s\n",
16473 +                 random_state->entropy_count,
16474 +                 sec_random_state->entropy_count,
16475 +                 nbytes * 8,
16476                   r == sec_random_state ? "secondary" :
16477 -                 r == random_state ? "primary" : "unknown",
16478 -                 r->entropy_count, nbytes * 8);
16479 +                 r == random_state ? "primary" : "unknown");
16480 +
16481 +       if (flags & EXTRACT_ENTROPY_LIMIT && nbytes >= r->entropy_count / 8)
16482 +               nbytes = r->entropy_count / 8;
16483  
16484         if (r->entropy_count / 8 >= nbytes)
16485                 r->entropy_count -= nbytes*8;
16486 @@ -1299,8 +1339,16 @@
16487         if (r->entropy_count < random_write_wakeup_thresh)
16488                 wake_up_interruptible(&random_write_wait);
16489  
16490 -       r->extract_count += nbytes;
16491 -       
16492 +       DEBUG_ENT("%04d %04d : debiting %d bits from %s%s\n",
16493 +                 random_state->entropy_count,
16494 +                 sec_random_state->entropy_count,
16495 +                 nbytes * 8,
16496 +                 r == sec_random_state ? "secondary" :
16497 +                 r == random_state ? "primary" : "unknown",
16498 +                 flags & EXTRACT_ENTROPY_LIMIT ? "" : " (unlimited)");
16499 +
16500 +       spin_unlock_irqrestore(&r->lock, cpuflags);
16501 +
16502         ret = 0;
16503         while (nbytes) {
16504                 /*
16505 @@ -1312,7 +1360,16 @@
16506                                         ret = -ERESTARTSYS;
16507                                 break;
16508                         }
16509 +
16510 +                       DEBUG_ENT("%04d %04d : extract feeling sleepy (%d bytes left)\n",
16511 +                                 random_state->entropy_count,
16512 +                                 sec_random_state->entropy_count, nbytes);
16513 +
16514                         schedule();
16515 +
16516 +                       DEBUG_ENT("%04d %04d : extract woke up\n",
16517 +                                 random_state->entropy_count,
16518 +                                 sec_random_state->entropy_count);
16519                 }
16520  
16521                 /* Hash the pool to get the output */
16522 @@ -1361,7 +1418,6 @@
16523                 nbytes -= i;
16524                 buf += i;
16525                 ret += i;
16526 -               add_timer_randomness(&extract_timer_state, nbytes);
16527         }
16528  
16529         /* Wipe data just returned from memory */
16530 @@ -1488,15 +1544,27 @@
16531         if (nbytes == 0)
16532                 return 0;
16533  
16534 -       add_wait_queue(&random_read_wait, &wait);
16535         while (nbytes > 0) {
16536 -               set_current_state(TASK_INTERRUPTIBLE);
16537 -               
16538                 n = nbytes;
16539                 if (n > SEC_XFER_SIZE)
16540                         n = SEC_XFER_SIZE;
16541 -               if (n > random_state->entropy_count / 8)
16542 -                       n = random_state->entropy_count / 8;
16543 +
16544 +               DEBUG_ENT("%04d %04d : reading %d bits, p: %d s: %d\n",
16545 +                         random_state->entropy_count,
16546 +                         sec_random_state->entropy_count,
16547 +                         n*8, random_state->entropy_count,
16548 +                         sec_random_state->entropy_count);
16549 +
16550 +               n = extract_entropy(sec_random_state, buf, n,
16551 +                                   EXTRACT_ENTROPY_USER |
16552 +                                   EXTRACT_ENTROPY_LIMIT |
16553 +                                   EXTRACT_ENTROPY_SECONDARY);
16554 +
16555 +               DEBUG_ENT("%04d %04d : read got %d bits (%d still needed)\n",
16556 +                         random_state->entropy_count,
16557 +                         sec_random_state->entropy_count,
16558 +                         n*8, (nbytes-n)*8);
16559 +
16560                 if (n == 0) {
16561                         if (file->f_flags & O_NONBLOCK) {
16562                                 retval = -EAGAIN;
16563 @@ -1506,12 +1574,27 @@
16564                                 retval = -ERESTARTSYS;
16565                                 break;
16566                         }
16567 -                       schedule();
16568 +
16569 +                       DEBUG_ENT("%04d %04d : sleeping?\n",
16570 +                                 random_state->entropy_count,
16571 +                                 sec_random_state->entropy_count);
16572 +
16573 +                       set_current_state(TASK_INTERRUPTIBLE);
16574 +                       add_wait_queue(&random_read_wait, &wait);
16575 +
16576 +                       if (sec_random_state->entropy_count / 8 == 0)
16577 +                               schedule();
16578 +
16579 +                       set_current_state(TASK_RUNNING);
16580 +                       remove_wait_queue(&random_read_wait, &wait);
16581 +
16582 +                       DEBUG_ENT("%04d %04d : waking up\n",
16583 +                                 random_state->entropy_count,
16584 +                                 sec_random_state->entropy_count);
16585 +
16586                         continue;
16587                 }
16588 -               n = extract_entropy(sec_random_state, buf, n,
16589 -                                   EXTRACT_ENTROPY_USER |
16590 -                                   EXTRACT_ENTROPY_SECONDARY);
16591 +
16592                 if (n < 0) {
16593                         retval = n;
16594                         break;
16595 @@ -1522,8 +1605,6 @@
16596                 break;          /* This break makes the device work */
16597                                 /* like a named pipe */
16598         }
16599 -       current->state = TASK_RUNNING;
16600 -       remove_wait_queue(&random_read_wait, &wait);
16601  
16602         /*
16603          * If we gave the user some bytes, update the access time.
16604 @@ -1595,8 +1676,9 @@
16605  random_ioctl(struct inode * inode, struct file * file,
16606              unsigned int cmd, unsigned long arg)
16607  {
16608 -       int *p, size, ent_count;
16609 +       int *p, *tmp, size, ent_count;
16610         int retval;
16611 +       unsigned long flags;
16612         
16613         switch (cmd) {
16614         case RNDGETENTCNT:
16615 @@ -1621,17 +1703,36 @@
16616                 if (!capable(CAP_SYS_ADMIN))
16617                         return -EPERM;
16618                 p = (int *) arg;
16619 -               ent_count = random_state->entropy_count;
16620 -               if (put_user(ent_count, p++) ||
16621 -                   get_user(size, p) ||
16622 +               if (get_user(size, p) ||
16623                     put_user(random_state->poolinfo.poolwords, p++))
16624                         return -EFAULT;
16625                 if (size < 0)
16626 -                       return -EINVAL;
16627 +                       return -EFAULT;
16628                 if (size > random_state->poolinfo.poolwords)
16629                         size = random_state->poolinfo.poolwords;
16630 -               if (copy_to_user(p, random_state->pool, size * sizeof(__u32)))
16631 +
16632 +               /* prepare to atomically snapshot pool */
16633 +
16634 +               tmp = kmalloc(size * sizeof(__u32), GFP_KERNEL);
16635 +
16636 +               if (!tmp)
16637                         return -EFAULT;
16638 +
16639 +               spin_lock_irqsave(&random_state->lock, flags);
16640 +               ent_count = random_state->entropy_count;
16641 +               memcpy(tmp, random_state->pool, size * sizeof(__u32));
16642 +               spin_unlock_irqrestore(&random_state->lock, flags);
16643 +
16644 +               if (!copy_to_user(p, tmp, size * sizeof(__u32))) {
16645 +                       kfree(tmp);
16646 +                       return -EFAULT;
16647 +               }
16648 +
16649 +               kfree(tmp);
16650 +
16651 +               if(put_user(ent_count, p++))
16652 +                       return -EFAULT;
16653 +
16654                 return 0;
16655         case RNDADDENTROPY:
16656                 if (!capable(CAP_SYS_ADMIN))
16657 diff -Nru a/drivers/char/raw.c b/drivers/char/raw.c
16658 --- a/drivers/char/raw.c        Fri Jun 20 13:16:17 2003
16659 +++ b/drivers/char/raw.c        Sun Aug 31 16:14:45 2003
16660 @@ -43,7 +43,7 @@
16661   */
16662  static int raw_open(struct inode *inode, struct file *filp)
16663  {
16664 -       const int minor = minor(inode->i_rdev);
16665 +       const int minor = iminor(inode);
16666         struct block_device *bdev;
16667         int err;
16668  
16669 @@ -60,23 +60,25 @@
16670         bdev = raw_devices[minor].binding;
16671         err = -ENODEV;
16672         if (bdev) {
16673 -               err = bd_claim(bdev, raw_open);
16674 +               err = blkdev_get(bdev, filp->f_mode, 0, BDEV_RAW);
16675                 if (err)
16676                         goto out;
16677 -               atomic_inc(&bdev->bd_count);
16678 -               err = blkdev_get(bdev, filp->f_mode, 0, BDEV_RAW);
16679 +               igrab(bdev->bd_inode);
16680 +               err = bd_claim(bdev, raw_open);
16681 +               if (err) {
16682 +                       blkdev_put(bdev, BDEV_RAW);
16683 +                       goto out;
16684 +               }
16685 +               err = set_blocksize(bdev, bdev_hardsect_size(bdev));
16686                 if (err) {
16687                         bd_release(bdev);
16688 +                       blkdev_put(bdev, BDEV_RAW);
16689                         goto out;
16690 -               } else {
16691 -                       err = set_blocksize(bdev, bdev_hardsect_size(bdev));
16692 -                       if (err == 0) {
16693 -                               filp->f_flags |= O_DIRECT;
16694 -                               if (++raw_devices[minor].inuse == 1)
16695 -                                       filp->f_dentry->d_inode->i_mapping =
16696 -                                               bdev->bd_inode->i_mapping;
16697 -                       }
16698                 }
16699 +               filp->f_flags |= O_DIRECT;
16700 +               if (++raw_devices[minor].inuse == 1)
16701 +                       filp->f_dentry->d_inode->i_mapping =
16702 +                               bdev->bd_inode->i_mapping;
16703         }
16704         filp->private_data = bdev;
16705  out:
16706 @@ -90,7 +92,7 @@
16707   */
16708  static int raw_release(struct inode *inode, struct file *filp)
16709  {
16710 -       const int minor= minor(inode->i_rdev);
16711 +       const int minor= iminor(inode);
16712         struct block_device *bdev;
16713  
16714         down(&raw_mutex);
16715 diff -Nru a/drivers/char/rtc.c b/drivers/char/rtc.c
16716 --- a/drivers/char/rtc.c        Tue Aug 12 13:25:18 2003
16717 +++ b/drivers/char/rtc.c        Sun Aug 31 16:15:40 2003
16718 @@ -44,10 +44,12 @@
16719   *      1.11    Takashi Iwai: Kernel access functions
16720   *                           rtc_register/rtc_unregister/rtc_control
16721   *      1.11a   Daniele Bellucci: Audit create_proc_read_entry in rtc_init
16722 + *     1.12    Venkatesh Pallipadi: Hooks for emulating rtc on HPET base-timer
16723 + *             CONFIG_HPET_EMULATE_RTC
16724   *
16725   */
16726  
16727 -#define RTC_VERSION            "1.11a"
16728 +#define RTC_VERSION            "1.12"
16729  
16730  #define RTC_IO_EXTENT  0x8
16731  
16732 @@ -80,6 +82,10 @@
16733  #include <asm/uaccess.h>
16734  #include <asm/system.h>
16735  
16736 +#if defined(__i386__)
16737 +#include <asm/hpet.h>
16738 +#endif
16739 +
16740  #ifdef __sparc__
16741  #include <linux/pci.h>
16742  #include <asm/ebus.h>
16743 @@ -95,6 +101,17 @@
16744  static int rtc_has_irq = 1;
16745  #endif
16746  
16747 +#ifndef CONFIG_HPET_EMULATE_RTC
16748 +#define is_hpet_enabled()                      0
16749 +#define hpet_set_alarm_time(hrs, min, sec)     0
16750 +#define hpet_set_periodic_freq(arg)            0
16751 +#define hpet_mask_rtc_irq_bit(arg)             0
16752 +#define hpet_set_rtc_irq_bit(arg)              0
16753 +#define hpet_rtc_timer_init()                  do { } while (0)
16754 +#define hpet_rtc_dropped_irq()                         0
16755 +static inline irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs) {return 0;}
16756 +#endif
16757 +
16758  /*
16759   *     We sponge a minor off of the misc major. No need slurping
16760   *     up another valuable major dev number for this. If you add
16761 @@ -120,7 +137,7 @@
16762  static unsigned int rtc_poll(struct file *file, poll_table *wait);
16763  #endif
16764  
16765 -static void get_rtc_time (struct rtc_time *rtc_tm);
16766 +void get_rtc_time (struct rtc_time *rtc_tm);
16767  static void get_rtc_alm_time (struct rtc_time *alm_tm);
16768  #if RTC_IRQ
16769  static void rtc_dropped_irq(unsigned long data);
16770 @@ -182,7 +199,7 @@
16771   *     (See ./arch/XXXX/kernel/time.c for the set_rtc_mmss() function.)
16772   */
16773  
16774 -static irqreturn_t rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
16775 +irqreturn_t rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
16776  {
16777         /*
16778          *      Can be an alarm interrupt, update complete interrupt,
16779 @@ -194,7 +211,16 @@
16780         spin_lock (&rtc_lock);
16781         rtc_irq_data += 0x100;
16782         rtc_irq_data &= ~0xff;
16783 -       rtc_irq_data |= (CMOS_READ(RTC_INTR_FLAGS) & 0xF0);
16784 +       if (is_hpet_enabled()) {
16785 +               /*
16786 +                * In this case it is HPET RTC interrupt handler
16787 +                * calling us, with the interrupt information
16788 +                * passed as arg1, instead of irq.
16789 +                */
16790 +               rtc_irq_data |= (unsigned long)irq & 0xF0;
16791 +       } else {
16792 +               rtc_irq_data |= (CMOS_READ(RTC_INTR_FLAGS) & 0xF0);
16793 +       }
16794  
16795         if (rtc_status & RTC_TIMER_ON)
16796                 mod_timer(&rtc_irq_timer, jiffies + HZ/rtc_freq + 2*HZ/100);
16797 @@ -429,6 +455,12 @@
16798                 sec = alm_tm.tm_sec;
16799  
16800                 spin_lock_irq(&rtc_lock);
16801 +               if (hpet_set_alarm_time(hrs, min, sec)) {
16802 +                       /*
16803 +                        * Fallthru and set alarm time in CMOS too,
16804 +                        * so that we will get proper value in RTC_ALM_READ
16805 +                        */
16806 +               }
16807                 if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) ||
16808                     RTC_ALWAYS_BCD)
16809                 {
16810 @@ -582,6 +614,10 @@
16811                         return -EINVAL;
16812  
16813                 spin_lock_irq(&rtc_lock);
16814 +               if (hpet_set_periodic_freq(arg)) {
16815 +                       spin_unlock_irq(&rtc_lock);
16816 +                       return 0;
16817 +               }
16818                 rtc_freq = arg;
16819  
16820                 val = CMOS_READ(RTC_FREQ_SELECT) & 0xf0;
16821 @@ -667,13 +703,14 @@
16822          */
16823  
16824         spin_lock_irq(&rtc_lock);
16825 -       tmp = CMOS_READ(RTC_CONTROL);
16826 -       tmp &=  ~RTC_PIE;
16827 -       tmp &=  ~RTC_AIE;
16828 -       tmp &=  ~RTC_UIE;
16829 -       CMOS_WRITE(tmp, RTC_CONTROL);
16830 -       CMOS_READ(RTC_INTR_FLAGS);
16831 -
16832 +       if (!hpet_mask_rtc_irq_bit(RTC_PIE | RTC_AIE | RTC_UIE)) {
16833 +               tmp = CMOS_READ(RTC_CONTROL);
16834 +               tmp &=  ~RTC_PIE;
16835 +               tmp &=  ~RTC_AIE;
16836 +               tmp &=  ~RTC_UIE;
16837 +               CMOS_WRITE(tmp, RTC_CONTROL);
16838 +               CMOS_READ(RTC_INTR_FLAGS);
16839 +       }
16840         if (rtc_status & RTC_TIMER_ON) {
16841                 rtc_status &= ~RTC_TIMER_ON;
16842                 del_timer(&rtc_irq_timer);
16843 @@ -765,12 +802,14 @@
16844         rtc_callback = NULL;
16845         
16846         /* disable controls */
16847 -       tmp = CMOS_READ(RTC_CONTROL);
16848 -       tmp &= ~RTC_PIE;
16849 -       tmp &= ~RTC_AIE;
16850 -       tmp &= ~RTC_UIE;
16851 -       CMOS_WRITE(tmp, RTC_CONTROL);
16852 -       CMOS_READ(RTC_INTR_FLAGS);
16853 +       if (!hpet_mask_rtc_irq_bit(RTC_PIE | RTC_AIE | RTC_UIE)) {
16854 +               tmp = CMOS_READ(RTC_CONTROL);
16855 +               tmp &= ~RTC_PIE;
16856 +               tmp &= ~RTC_AIE;
16857 +               tmp &= ~RTC_UIE;
16858 +               CMOS_WRITE(tmp, RTC_CONTROL);
16859 +               CMOS_READ(RTC_INTR_FLAGS);
16860 +       }
16861         if (rtc_status & RTC_TIMER_ON) {
16862                 rtc_status &= ~RTC_TIMER_ON;
16863                 del_timer(&rtc_irq_timer);
16864 @@ -822,6 +861,10 @@
16865         &rtc_fops
16866  };
16867  
16868 +#if RTC_IRQ
16869 +static irqreturn_t (*rtc_int_handler_ptr)(int irq, void *dev_id, struct pt_regs *regs);
16870 +#endif
16871 +
16872  static int __init rtc_init(void)
16873  {
16874  #if defined(__alpha__) || defined(__mips__)
16875 @@ -889,12 +932,20 @@
16876         }
16877  
16878  #if RTC_IRQ
16879 -       if (request_irq(RTC_IRQ, rtc_interrupt, SA_INTERRUPT, "rtc", NULL)) {
16880 +       if (is_hpet_enabled()) {
16881 +               rtc_int_handler_ptr = hpet_rtc_interrupt;
16882 +       } else {
16883 +               rtc_int_handler_ptr = rtc_interrupt;
16884 +       }
16885 +
16886 +       if(request_irq(RTC_IRQ, rtc_int_handler_ptr, SA_INTERRUPT, "rtc", NULL)) {
16887                 /* Yeah right, seeing as irq 8 doesn't even hit the bus. */
16888                 printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ);
16889                 release_region(RTC_PORT(0), RTC_IO_EXTENT);
16890                 return -EIO;
16891         }
16892 +       hpet_rtc_timer_init();
16893 +
16894  #endif
16895  
16896  #endif /* __sparc__ vs. others */
16897 @@ -965,10 +1016,12 @@
16898         init_timer(&rtc_irq_timer);
16899         rtc_irq_timer.function = rtc_dropped_irq;
16900         spin_lock_irq(&rtc_lock);
16901 -       /* Initialize periodic freq. to CMOS reset default, which is 1024Hz */
16902 -       CMOS_WRITE(((CMOS_READ(RTC_FREQ_SELECT) & 0xF0) | 0x06), RTC_FREQ_SELECT);
16903 -       spin_unlock_irq(&rtc_lock);
16904         rtc_freq = 1024;
16905 +       if (!hpet_set_periodic_freq(rtc_freq)) {
16906 +               /* Initialize periodic freq. to CMOS reset default, which is 1024Hz */
16907 +               CMOS_WRITE(((CMOS_READ(RTC_FREQ_SELECT) & 0xF0) | 0x06), RTC_FREQ_SELECT);
16908 +       }
16909 +       spin_unlock_irq(&rtc_lock);
16910  no_irq2:
16911  #endif
16912  
16913 @@ -1019,6 +1072,11 @@
16914  
16915         spin_lock_irq (&rtc_lock);
16916  
16917 +       if (hpet_rtc_dropped_irq()) {
16918 +               spin_unlock_irq(&rtc_lock);
16919 +               return;
16920 +       }
16921 +
16922         /* Just in case someone disabled the timer from behind our back... */
16923         if (rtc_status & RTC_TIMER_ON)
16924                 mod_timer(&rtc_irq_timer, jiffies + HZ/rtc_freq + 2*HZ/100);
16925 @@ -1148,7 +1206,7 @@
16926         return uip;
16927  }
16928  
16929 -static void get_rtc_time(struct rtc_time *rtc_tm)
16930 +void get_rtc_time(struct rtc_time *rtc_tm)
16931  {
16932         unsigned long uip_watchdog = jiffies;
16933         unsigned char ctrl;
16934 @@ -1254,6 +1312,10 @@
16935         unsigned char val;
16936  
16937         spin_lock_irq(&rtc_lock);
16938 +       if (hpet_mask_rtc_irq_bit(bit)) {
16939 +               spin_unlock_irq(&rtc_lock);
16940 +               return;
16941 +       }
16942         val = CMOS_READ(RTC_CONTROL);
16943         val &=  ~bit;
16944         CMOS_WRITE(val, RTC_CONTROL);
16945 @@ -1268,6 +1330,10 @@
16946         unsigned char val;
16947  
16948         spin_lock_irq(&rtc_lock);
16949 +       if (hpet_set_rtc_irq_bit(bit)) {
16950 +               spin_unlock_irq(&rtc_lock);
16951 +               return;
16952 +       }
16953         val = CMOS_READ(RTC_CONTROL);
16954         val |= bit;
16955         CMOS_WRITE(val, RTC_CONTROL);
16956 diff -Nru a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c
16957 --- a/drivers/char/scx200_gpio.c        Sat Dec  7 08:54:07 2002
16958 +++ b/drivers/char/scx200_gpio.c        Tue Aug 26 09:25:41 2003
16959 @@ -29,7 +29,7 @@
16960  static ssize_t scx200_gpio_write(struct file *file, const char *data, 
16961                                  size_t len, loff_t *ppos)
16962  {
16963 -       unsigned m = minor(file->f_dentry->d_inode->i_rdev);
16964 +       unsigned m = iminor(file->f_dentry->d_inode);
16965         size_t i;
16966  
16967         if (ppos != &file->f_pos)
16968 @@ -80,7 +80,7 @@
16969  static ssize_t scx200_gpio_read(struct file *file, char *buf,
16970                                 size_t len, loff_t *ppos)
16971  {
16972 -       unsigned m = minor(file->f_dentry->d_inode->i_rdev);
16973 +       unsigned m = iminor(file->f_dentry->d_inode);
16974         int value;
16975  
16976         if (ppos != &file->f_pos)
16977 @@ -95,7 +95,7 @@
16978  
16979  static int scx200_gpio_open(struct inode *inode, struct file *file)
16980  {
16981 -       unsigned m = minor(inode->i_rdev);
16982 +       unsigned m = iminor(inode);
16983         if (m > 63)
16984                 return -EINVAL;
16985         return 0;
16986 diff -Nru a/drivers/char/sonypi.c b/drivers/char/sonypi.c
16987 --- a/drivers/char/sonypi.c     Fri Jun 13 07:30:24 2003
16988 +++ b/drivers/char/sonypi.c     Fri Aug  1 05:36:14 2003
16989 @@ -308,7 +308,7 @@
16990         int i, j;
16991  
16992         v1 = inb_p(sonypi_device.ioport1);
16993 -       v2 = inb_p(sonypi_device.ioport2);
16994 +       v2 = inb_p(sonypi_device.ioport1 + sonypi_device.evtype_offset);
16995  
16996         for (i = 0; sonypi_eventtypes[i].model; i++) {
16997                 if (sonypi_device.model != sonypi_eventtypes[i].model)
16998 @@ -670,11 +670,13 @@
16999         if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2) {
17000                 ioport_list = sonypi_type2_ioport_list;
17001                 sonypi_device.region_size = SONYPI_TYPE2_REGION_SIZE;
17002 +               sonypi_device.evtype_offset = SONYPI_TYPE2_EVTYPE_OFFSET;
17003                 irq_list = sonypi_type2_irq_list;
17004         }
17005         else {
17006                 ioport_list = sonypi_type1_ioport_list;
17007                 sonypi_device.region_size = SONYPI_TYPE1_REGION_SIZE;
17008 +               sonypi_device.evtype_offset = SONYPI_TYPE1_EVTYPE_OFFSET;
17009                 irq_list = sonypi_type1_irq_list;
17010         }
17011  
17012 diff -Nru a/drivers/char/sonypi.h b/drivers/char/sonypi.h
17013 --- a/drivers/char/sonypi.h     Tue Jun 10 03:03:28 2003
17014 +++ b/drivers/char/sonypi.h     Mon Sep  1 03:37:24 2003
17015 @@ -56,12 +56,14 @@
17016  #define SONYPI_BASE                    0x50
17017  #define SONYPI_G10A                    (SONYPI_BASE+0x14)
17018  #define SONYPI_TYPE1_REGION_SIZE       0x08
17019 +#define SONYPI_TYPE1_EVTYPE_OFFSET     0x04
17020  
17021  /* type2 series specifics */
17022  #define SONYPI_SIRQ                    0x9b
17023  #define SONYPI_SLOB                    0x9c
17024  #define SONYPI_SHIB                    0x9d
17025  #define SONYPI_TYPE2_REGION_SIZE       0x20
17026 +#define SONYPI_TYPE2_EVTYPE_OFFSET     0x12
17027  
17028  /* battery / brightness addresses */
17029  #define SONYPI_BAT_FLAGS       0x81
17030 @@ -167,6 +169,7 @@
17031  #define SONYPI_THUMBPHRASE_MASK                        0x00000200
17032  #define SONYPI_MEYE_MASK                       0x00000400
17033  #define SONYPI_MEMORYSTICK_MASK                        0x00000800
17034 +#define SONYPI_BATTERY_MASK                    0x00001000
17035  
17036  struct sonypi_event {
17037         u8      data;
17038 @@ -293,6 +296,13 @@
17039         { 0, 0 }
17040  };
17041  
17042 +/* The set of possible battery events */
17043 +static struct sonypi_event sonypi_batteryev[] = {
17044 +       { 0x20, SONYPI_EVENT_BATTERY_INSERT },
17045 +       { 0x30, SONYPI_EVENT_BATTERY_REMOVE },
17046 +       { 0, 0 }
17047 +};
17048 +
17049  struct sonypi_eventtypes {
17050         int                     model;
17051         u8                      data;
17052 @@ -307,19 +317,22 @@
17053         { SONYPI_DEVICE_MODEL_TYPE1, 0x20, SONYPI_FNKEY_MASK, sonypi_fnkeyev },
17054         { SONYPI_DEVICE_MODEL_TYPE1, 0x30, SONYPI_BLUETOOTH_MASK, sonypi_blueev },
17055         { SONYPI_DEVICE_MODEL_TYPE1, 0x40, SONYPI_PKEY_MASK, sonypi_pkeyev },
17056 +       { SONYPI_DEVICE_MODEL_TYPE1, 0x30, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev },
17057 +       { SONYPI_DEVICE_MODEL_TYPE1, 0x40, SONYPI_BATTERY_MASK, sonypi_batteryev },
17058  
17059         { SONYPI_DEVICE_MODEL_TYPE2, 0, 0xffffffff, sonypi_releaseev },
17060         { SONYPI_DEVICE_MODEL_TYPE2, 0x38, SONYPI_LID_MASK, sonypi_lidev },
17061 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_JOGGER_MASK, sonypi_joggerev },
17062 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_CAPTURE_MASK, sonypi_captureev },
17063 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_FNKEY_MASK, sonypi_fnkeyev },
17064 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_BLUETOOTH_MASK, sonypi_blueev },
17065 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x11, SONYPI_JOGGER_MASK, sonypi_joggerev },
17066 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x61, SONYPI_CAPTURE_MASK, sonypi_captureev },
17067 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x21, SONYPI_FNKEY_MASK, sonypi_fnkeyev },
17068 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_BLUETOOTH_MASK, sonypi_blueev },
17069         { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_PKEY_MASK, sonypi_pkeyev },
17070 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_BACK_MASK, sonypi_backev },
17071 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x11, SONYPI_BACK_MASK, sonypi_backev },
17072         { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_HELP_MASK, sonypi_helpev },
17073         { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_ZOOM_MASK, sonypi_zoomev },
17074         { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_THUMBPHRASE_MASK, sonypi_thumbphraseev },
17075 -       { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev },
17076 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev },
17077 +       { SONYPI_DEVICE_MODEL_TYPE2, 0x41, SONYPI_BATTERY_MASK, sonypi_batteryev },
17078  
17079         { 0, 0, 0, 0 }
17080  };
17081 @@ -354,6 +367,7 @@
17082         u16 ioport1;
17083         u16 ioport2;
17084         u16 region_size;
17085 +       u16 evtype_offset;
17086         int camera_power;
17087         int bluetooth_power;
17088         struct semaphore lock;
17089 diff -Nru a/drivers/char/stallion.c b/drivers/char/stallion.c
17090 --- a/drivers/char/stallion.c   Wed Jul 30 04:37:51 2003
17091 +++ b/drivers/char/stallion.c   Sun Aug 24 05:39:23 2003
17092 @@ -3078,7 +3078,7 @@
17093                 (int) fp, cmd, (int) arg);
17094  #endif
17095  
17096 -       brdnr = minor(ip->i_rdev);
17097 +       brdnr = iminor(ip);
17098         if (brdnr >= STL_MAXBRDS)
17099                 return(-ENODEV);
17100         rc = 0;
17101 @@ -4234,7 +4234,7 @@
17102         misr = inb(ioaddr + EREG_DATA);
17103         if (misr & MISR_DCD) {
17104                 set_bit(ASYI_DCDCHANGE, &portp->istate);
17105 -               schedule_task(&portp->tqueue);
17106 +               schedule_work(&portp->tqueue);
17107                 portp->stats.modem++;
17108         }
17109  
17110 @@ -5031,7 +5031,7 @@
17111         if ((len == 0) || ((len < STL_TXBUFLOW) &&
17112             (test_bit(ASYI_TXLOW, &portp->istate) == 0))) {
17113                 set_bit(ASYI_TXLOW, &portp->istate);
17114 -               schedule_task(&portp->tqueue); 
17115 +               schedule_work(&portp->tqueue); 
17116         }
17117  
17118         if (len == 0) {
17119 @@ -5248,7 +5248,7 @@
17120                 ipr = stl_sc26198getreg(portp, IPR);
17121                 if (ipr & IPR_DCDCHANGE) {
17122                         set_bit(ASYI_DCDCHANGE, &portp->istate);
17123 -                       schedule_task(&portp->tqueue); 
17124 +                       schedule_work(&portp->tqueue); 
17125                         portp->stats.modem++;
17126                 }
17127                 break;
17128 diff -Nru a/drivers/char/tipar.c b/drivers/char/tipar.c
17129 --- a/drivers/char/tipar.c      Wed May  7 08:47:30 2003
17130 +++ b/drivers/char/tipar.c      Tue Aug 26 09:25:41 2003
17131 @@ -248,7 +248,7 @@
17132  static int
17133  tipar_open(struct inode *inode, struct file *file)
17134  {
17135 -       unsigned int minor = minor(inode->i_rdev) - TIPAR_MINOR;
17136 +       unsigned int minor = iminor(inode) - TIPAR_MINOR;
17137  
17138         if (minor > tp_count - 1)
17139                 return -ENXIO;
17140 @@ -266,7 +266,7 @@
17141  static int
17142  tipar_close(struct inode *inode, struct file *file)
17143  {
17144 -       unsigned int minor = minor(inode->i_rdev) - TIPAR_MINOR;
17145 +       unsigned int minor = iminor(inode) - TIPAR_MINOR;
17146  
17147         if (minor > tp_count - 1)
17148                 return -ENXIO;
17149 @@ -279,8 +279,7 @@
17150  static ssize_t
17151  tipar_write(struct file *file, const char *buf, size_t count, loff_t * ppos)
17152  {
17153 -       unsigned int minor =
17154 -           minor(file->f_dentry->d_inode->i_rdev) - TIPAR_MINOR;
17155 +       unsigned int minor = iminor(file->f_dentry->d_inode) - TIPAR_MINOR;
17156         ssize_t n;
17157  
17158         parport_claim_or_block(table[minor].dev);
17159 @@ -308,8 +307,7 @@
17160  tipar_read(struct file *file, char *buf, size_t count, loff_t * ppos)
17161  {
17162         int b = 0;
17163 -       unsigned int minor =
17164 -           minor(file->f_dentry->d_inode->i_rdev) - TIPAR_MINOR;
17165 +       unsigned int minor = iminor(file->f_dentry->d_inode) - TIPAR_MINOR;
17166         ssize_t retval = 0;
17167         ssize_t n = 0;
17168  
17169 diff -Nru a/drivers/char/tpqic02.c b/drivers/char/tpqic02.c
17170 --- a/drivers/char/tpqic02.c    Wed May  7 08:47:30 2003
17171 +++ b/drivers/char/tpqic02.c    Tue Aug 26 09:25:41 2003
17172 @@ -169,7 +169,7 @@
17173  static volatile unsigned dma_mode;     /* !=0 also means DMA in use */
17174  static flag need_rewind = YES;
17175  
17176 -static kdev_t current_tape_dev;
17177 +static int current_type;
17178  static int extra_blocks_left = BLOCKS_BEYOND_EW;
17179  static struct timer_list tp_timer;
17180  
17181 @@ -677,7 +677,7 @@
17182          * exception flag from previous exception which we are trying to clear.
17183          */
17184  
17185 -       if (TP_DIAGS(current_tape_dev))
17186 +       if (TP_DIAGS(current_type))
17187                 printk(TPQIC02_NAME ": reading status bytes: ");
17188  
17189         for (q = stp; q < stp + size; q++) {
17190 @@ -693,7 +693,7 @@
17191  
17192                 *q = inb_p(QIC02_DATA_PORT);    /* read status byte */
17193  
17194 -               if (TP_DIAGS(current_tape_dev))
17195 +               if (TP_DIAGS(current_type))
17196                         printk("[%1d]=0x%x  ", q - stp, (unsigned) (*q) & 0xff);
17197  
17198                 outb_p(ctlbits | QIC02_CTL_REQUEST, QIC02_CTL_PORT);    /* set request */
17199 @@ -714,7 +714,7 @@
17200                 cpu_relax();
17201         /* wait for ready */
17202  
17203 -       if (TP_DIAGS(current_tape_dev))
17204 +       if (TP_DIAGS(current_type))
17205                 printk("\n");
17206  
17207         return TE_OK;
17208 @@ -1614,7 +1614,7 @@
17209  
17210         if (status_expect_int) {
17211  #ifdef WANT_EXTRA_FULL_DEBUGGING
17212 -               if (TP_DIAGS(current_tape_dev))
17213 +               if (TP_DIAGS(current_type))
17214                         printk("@");
17215  #endif
17216                 stat = inb(QIC02_STAT_PORT);    /* Knock, knock */
17217 @@ -1726,7 +1726,7 @@
17218  
17219  static ssize_t qic02_tape_read(struct file *filp, char *buf, size_t count, loff_t * ppos)
17220  {
17221 -       kdev_t dev = filp->f_dentry->d_inode->i_rdev;
17222 +       int type = iminor(filp->f_dentry->d_inode);
17223         unsigned short flags = filp->f_flags;
17224         unsigned long bytes_todo, bytes_done, total_bytes_done = 0;
17225         int stat;
17226 @@ -1736,8 +1736,8 @@
17227                 return -ENXIO;
17228         }
17229  
17230 -       if (TP_DIAGS(current_tape_dev))
17231 -               printk(TPQIC02_NAME ": request READ, minor=%x, buf=%p, count=%lx, pos=%Lx, flags=%x\n", minor(dev), buf,
17232 +       if (TP_DIAGS(current_type))
17233 +               printk(TPQIC02_NAME ": request READ, minor=%x, buf=%p, count=%lx, pos=%Lx, flags=%x\n", type, buf,
17234                        (long) count, filp->f_pos, flags);
17235  
17236         if (count % TAPE_BLKSIZE) {     /* Only allow mod 512 bytes at a time. */
17237 @@ -1904,7 +1904,7 @@
17238   */
17239  static ssize_t qic02_tape_write(struct file *filp, const char *buf, size_t count, loff_t * ppos)
17240  {
17241 -       kdev_t dev = filp->f_dentry->d_inode->i_rdev;
17242 +       int type = iminor(filp->f_dentry->d_inode);
17243         unsigned short flags = filp->f_flags;
17244         unsigned long bytes_todo, bytes_done, total_bytes_done = 0;
17245  
17246 @@ -1913,9 +1913,9 @@
17247                 return -ENXIO;
17248         }
17249  
17250 -       if (TP_DIAGS(current_tape_dev)) {
17251 +       if (TP_DIAGS(current_type)) {
17252                 printk(TPQIC02_NAME ": request WRITE, minor=%x, buf=%p, count=%lx, pos=%Lx, flags=%x\n",
17253 -                      minor(dev), buf, (long) count, filp->f_pos, flags);
17254 +                      type, buf, (long) count, filp->f_pos, flags);
17255         }
17256  
17257         if (count % TAPE_BLKSIZE) {     /* only allow mod 512 bytes at a time */
17258 @@ -2070,17 +2070,18 @@
17259  static int qic02_tape_open_no_use_count(struct inode *inode,
17260                                         struct file *filp)
17261  {
17262 -       kdev_t dev = inode->i_rdev;
17263 +       int type = iminor(inode);
17264         unsigned short flags = filp->f_flags;
17265         unsigned short dens = 0;
17266         int s;
17267  
17268  
17269 -       if (TP_DIAGS(dev)) {
17270 -               printk("qic02_tape_open: dev=%s, flags=%x     ", cdevname(dev), flags);
17271 +       if (TP_DIAGS(type)) {
17272 +               printk("qic02_tape_open: dev=tpqic2(%d), flags=%x     ",
17273 +                       type, flags);
17274         }
17275  
17276 -       if (minor(dev) == 255) {        /* special case for resetting */
17277 +       if (type == 255) {      /* special case for resetting */
17278                 if (capable(CAP_SYS_ADMIN)) {
17279                         return (tape_reset(1) == TE_OK) ? -EAGAIN : -ENXIO;
17280                 } else {
17281 @@ -2162,7 +2163,7 @@
17282          */
17283  
17284         /* not allowed to do QCMD_DENS_* unless tape is rewound */
17285 -       if ((TP_DENS(dev) != 0) && (TP_DENS(current_tape_dev) != TP_DENS(dev))) {
17286 +       if ((TP_DENS(type) != 0) && (TP_DENS(current_type) != TP_DENS(type))) {
17287                 /* force rewind if minor bits have changed,
17288                  * i.e. user wants to use tape in different format.
17289                  * [assuming single drive operation]
17290 @@ -2175,7 +2176,7 @@
17291                 /* density bits still the same, but TP_DIAGS bit 
17292                  * may have changed.
17293                  */
17294 -               current_tape_dev = dev;
17295 +               current_type = type;
17296         }
17297  
17298         if (need_rewind == YES) {
17299 @@ -2212,14 +2213,14 @@
17300          * so we must have done a rewind by now. If not, just skip over.
17301          * Only give set density command when minor bits have changed.
17302          */
17303 -       if (TP_DENS(current_tape_dev) == TP_DENS(dev)) {
17304 +       if (TP_DENS(current_type) == TP_DENS(type)) {
17305                 return 0;
17306         }
17307  
17308 -       current_tape_dev = dev;
17309 +       current_type = type;
17310         need_rewind = NO;
17311         if (TP_HAVE_DENS) {
17312 -               dens = TP_DENS(dev);
17313 +               dens = TP_DENS(type);
17314         }
17315  
17316         if (dens < sizeof(format_names) / sizeof(char *))
17317 @@ -2227,7 +2228,7 @@
17318         else
17319                 tpqputs(TPQD_REWIND, "Wait for retensioning...");
17320  
17321 -       switch (TP_DENS(dev)) {
17322 +       switch (TP_DENS(type)) {
17323         case 0:         /* Minor 0 is for drives without set-density support */
17324                 s = 0;
17325                 break;
17326 @@ -2254,7 +2255,7 @@
17327         }
17328         if (s != 0) {
17329                 status_dead = YES;      /* force reset */
17330 -               current_tape_dev = NODEV;/* earlier 0xff80 */
17331 +               current_type = 0;/* earlier 0xff80 */
17332                 return -EIO;
17333         }
17334  
17335 @@ -2264,10 +2265,10 @@
17336  
17337  static int qic02_tape_release(struct inode *inode, struct file *filp)
17338  {
17339 -       kdev_t dev = inode->i_rdev;
17340 +       int type = iminor(inode);
17341  
17342 -       if (TP_DIAGS(dev)) {
17343 -               printk("qic02_tape_release: dev=%s\n", cdevname(dev));
17344 +       if (TP_DIAGS(type)) {
17345 +               printk("qic02_tape_release: dev=tpqic2(%d)\n", type);
17346         }
17347  
17348         if (status_zombie == NO) {      /* don't rewind in zombie mode */
17349 @@ -2283,7 +2284,7 @@
17350                 /* Rewind only if minor number requires it AND 
17351                  * read/writes have been done. ************* IS THIS CORRECT??????????
17352                  */
17353 -               if ((TP_REWCLOSE(dev)) && (status_bytes_rd | status_bytes_wr)) {
17354 +               if (TP_REWCLOSE(type) && (status_bytes_rd | status_bytes_wr)) {
17355                         tpqputs(TPQD_REWIND, "release: Doing rewind...");
17356                         (void) do_qic_cmd(QCMD_REWIND, TIM_R);
17357                 }
17358 @@ -2398,7 +2399,7 @@
17359         struct mtpos ioctl_tell;
17360  
17361  
17362 -       if (TP_DIAGS(current_tape_dev))
17363 +       if (TP_DIAGS(current_type))
17364                 printk(TPQIC02_NAME ": ioctl(%4x, %4lx)\n", iocmd, ioarg);
17365  
17366         if (!inode)
17367 @@ -2459,7 +2460,7 @@
17368                  * ---      tape at the beginning of the current file.
17369                  */
17370  
17371 -               if (TP_DIAGS(current_tape_dev))
17372 +               if (TP_DIAGS(current_type))
17373                         printk("OP op=%4x, count=%4x\n", operation.mt_op, operation.mt_count);
17374  
17375                 if (operation.mt_count < 0)
17376 @@ -2492,7 +2493,7 @@
17377                 return 0;
17378  
17379         } else if (c == _IOC_NR(MTIOCGET)) {
17380 -               if (TP_DIAGS(current_tape_dev))
17381 +               if (TP_DIAGS(current_type))
17382                         printk("GET ");
17383  
17384                 CHECK_IOC_SIZE(mtget);
17385 @@ -2507,7 +2508,7 @@
17386                         return -EFAULT;
17387                 return 0;
17388         } else if (TP_HAVE_TELL && (c == _IOC_NR(MTIOCPOS))) {
17389 -               if (TP_DIAGS(current_tape_dev))
17390 +               if (TP_DIAGS(current_type))
17391                         printk("POS ");
17392  
17393                 CHECK_IOC_SIZE(mtpos);
17394 @@ -2664,7 +2665,7 @@
17395                 return -ENODEV;
17396         }
17397  
17398 -       current_tape_dev = mk_kdev(QIC02_TAPE_MAJOR, 0);
17399 +       current_type = 0;
17400  
17401  #ifndef CONFIG_QIC02_DYNCONF
17402         printk(TPQIC02_NAME ": IRQ %d, DMA %d, IO 0x%x, IFC %s, %s, %s\n",
17403 diff -Nru a/drivers/char/tty_io.c b/drivers/char/tty_io.c
17404 --- a/drivers/char/tty_io.c     Fri Aug  1 02:22:20 2003
17405 +++ b/drivers/char/tty_io.c     Sun Aug 31 16:15:47 2003
17406 @@ -177,7 +177,7 @@
17407  
17408  EXPORT_SYMBOL(tty_name);
17409  
17410 -inline int tty_paranoia_check(struct tty_struct *tty, kdev_t device,
17411 +inline int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
17412                               const char *routine)
17413  {
17414  #ifdef TTY_PARANOIA_CHECK
17415 @@ -187,11 +187,11 @@
17416                 "Warning: null TTY for (%s) in %s\n";
17417  
17418         if (!tty) {
17419 -               printk(badtty, cdevname(device), routine);
17420 +               printk(badtty, cdevname(inode->i_rdev), routine);
17421                 return 1;
17422         }
17423         if (tty->magic != TTY_MAGIC) {
17424 -               printk(badmagic, cdevname(device), routine);
17425 +               printk(badmagic, cdevname(inode->i_rdev), routine);
17426                 return 1;
17427         }
17428  #endif
17429 @@ -646,7 +646,7 @@
17430  
17431         tty = (struct tty_struct *)file->private_data;
17432         inode = file->f_dentry->d_inode;
17433 -       if (tty_paranoia_check(tty, inode->i_rdev, "tty_read"))
17434 +       if (tty_paranoia_check(tty, inode, "tty_read"))
17435                 return -EIO;
17436         if (!tty || (test_bit(TTY_IO_ERROR, &tty->flags)))
17437                 return -EIO;
17438 @@ -763,7 +763,7 @@
17439         }
17440  
17441         tty = (struct tty_struct *)file->private_data;
17442 -       if (tty_paranoia_check(tty, inode->i_rdev, "tty_write"))
17443 +       if (tty_paranoia_check(tty, inode, "tty_write"))
17444                 return -EIO;
17445         if (!tty || !tty->driver->write || (test_bit(TTY_IO_ERROR, &tty->flags)))
17446                 return -EIO;
17447 @@ -1023,7 +1023,7 @@
17448                 o_tty->magic = 0;
17449                 o_tty->driver->refcount--;
17450                 file_list_lock();
17451 -               list_del(&o_tty->tty_files);
17452 +               list_del_init(&o_tty->tty_files);
17453                 file_list_unlock();
17454                 free_tty_struct(o_tty);
17455         }
17456 @@ -1037,7 +1037,7 @@
17457         tty->magic = 0;
17458         tty->driver->refcount--;
17459         file_list_lock();
17460 -       list_del(&tty->tty_files);
17461 +       list_del_init(&tty->tty_files);
17462         file_list_unlock();
17463         module_put(tty->driver->owner);
17464         free_tty_struct(tty);
17465 @@ -1059,7 +1059,7 @@
17466         char    buf[64];
17467         
17468         tty = (struct tty_struct *)filp->private_data;
17469 -       if (tty_paranoia_check(tty, filp->f_dentry->d_inode->i_rdev, "release_dev"))
17470 +       if (tty_paranoia_check(tty, filp->f_dentry->d_inode, "release_dev"))
17471                 return;
17472  
17473         check_tty_count(tty, "release_dev");
17474 @@ -1439,7 +1439,7 @@
17475         struct tty_struct * tty;
17476  
17477         tty = (struct tty_struct *)filp->private_data;
17478 -       if (tty_paranoia_check(tty, filp->f_dentry->d_inode->i_rdev, "tty_poll"))
17479 +       if (tty_paranoia_check(tty, filp->f_dentry->d_inode, "tty_poll"))
17480                 return 0;
17481  
17482         if (tty->ldisc.poll)
17483 @@ -1453,7 +1453,7 @@
17484         int retval;
17485  
17486         tty = (struct tty_struct *)filp->private_data;
17487 -       if (tty_paranoia_check(tty, filp->f_dentry->d_inode->i_rdev, "tty_fasync"))
17488 +       if (tty_paranoia_check(tty, filp->f_dentry->d_inode, "tty_fasync"))
17489                 return 0;
17490         
17491         retval = fasync_helper(fd, filp, on, &tty->fasync);
17492 @@ -1727,7 +1727,7 @@
17493         int retval;
17494         
17495         tty = (struct tty_struct *)file->private_data;
17496 -       if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
17497 +       if (tty_paranoia_check(tty, inode, "tty_ioctl"))
17498                 return -EINVAL;
17499  
17500         real_tty = tty;
17501 diff -Nru a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
17502 --- a/drivers/char/vc_screen.c  Wed May  7 08:47:30 2003
17503 +++ b/drivers/char/vc_screen.c  Tue Aug 26 09:25:41 2003
17504 @@ -49,7 +49,7 @@
17505  vcs_size(struct inode *inode)
17506  {
17507         int size;
17508 -       int minor = minor(inode->i_rdev);
17509 +       int minor = iminor(inode);
17510         int currcons = minor & 127;
17511         if (currcons == 0)
17512                 currcons = fg_console;
17513 @@ -104,7 +104,7 @@
17514  vcs_read(struct file *file, char *buf, size_t count, loff_t *ppos)
17515  {
17516         struct inode *inode = file->f_dentry->d_inode;
17517 -       unsigned int currcons = minor(inode->i_rdev);
17518 +       unsigned int currcons = iminor(inode);
17519         long pos = *ppos;
17520         long viewed, attr, read;
17521         int col, maxcol;
17522 @@ -273,7 +273,7 @@
17523  vcs_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
17524  {
17525         struct inode *inode = file->f_dentry->d_inode;
17526 -       unsigned int currcons = minor(inode->i_rdev);
17527 +       unsigned int currcons = iminor(inode);
17528         long pos = *ppos;
17529         long viewed, attr, size, written;
17530         char *con_buf0;
17531 @@ -456,7 +456,7 @@
17532  static int
17533  vcs_open(struct inode *inode, struct file *filp)
17534  {
17535 -       unsigned int currcons = minor(inode->i_rdev) & 127;
17536 +       unsigned int currcons = iminor(inode) & 127;
17537         if(currcons && !vc_cons_allocated(currcons-1))
17538                 return -ENXIO;
17539         return 0;
17540 diff -Nru a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
17541 --- a/drivers/char/watchdog/Kconfig     Mon Jul 28 13:28:55 2003
17542 +++ b/drivers/char/watchdog/Kconfig     Sun Aug 31 11:39:56 2003
17543 @@ -346,6 +346,18 @@
17544           module, say M here and read <file:Documentation/modules.txt>.  Most
17545           people will say N.
17546  
17547 +config ALIM1535_WDT
17548 +       tristate "ALi M1535 PMU Watchdog Timer"
17549 +       depends on WATCHDOG
17550 +       ---help---
17551 +         This is the driver for the hardware watchdog on the ALi M1535 PMU.
17552 +
17553 +         This driver is also available as a module ( = code which can be
17554 +         inserted in and removed from the running kernel whenever you want).
17555 +         The module is called alim1535_wdt.  If you want to compile it as a
17556 +         module, say M here and read <file:Documentation/modules.txt>.  Most
17557 +         people will say N.
17558 +
17559  config SC1200_WDT
17560         tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog"
17561         depends on WATCHDOG
17562 diff -Nru a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
17563 --- a/drivers/char/watchdog/Makefile    Thu Feb 27 12:38:45 2003
17564 +++ b/drivers/char/watchdog/Makefile    Sun Aug 31 11:39:56 2003
17565 @@ -27,6 +27,7 @@
17566  obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o
17567  obj-$(CONFIG_SC520_WDT) += sc520_wdt.o
17568  obj-$(CONFIG_ALIM7101_WDT) += alim7101_wdt.o
17569 +obj-$(CONFIG_ALIM1535_WDT) += alim1535_wdt.o
17570  obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o
17571  obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o
17572  obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o
17573 diff -Nru a/drivers/char/watchdog/acquirewdt.c b/drivers/char/watchdog/acquirewdt.c
17574 --- a/drivers/char/watchdog/acquirewdt.c        Fri Aug  8 03:28:08 2003
17575 +++ b/drivers/char/watchdog/acquirewdt.c        Sun Aug 31 14:15:12 2003
17576 @@ -1,5 +1,5 @@
17577  /*
17578 - *     Acquire Single Board Computer Watchdog Timer driver for Linux 2.1.x
17579 + *     Acquire Single Board Computer Watchdog Timer driver
17580   *
17581   *      Based on wdt.c. Original copyright messages:
17582   *
17583 @@ -10,10 +10,10 @@
17584   *     modify it under the terms of the GNU General Public License
17585   *     as published by the Free Software Foundation; either version
17586   *     2 of the License, or (at your option) any later version.
17587 - *     
17588 - *     Neither Alan Cox nor CymruNet Ltd. admit liability nor provide 
17589 - *     warranty for any of this software. This material is provided 
17590 - *     "AS-IS" and at no charge.       
17591 + *
17592 + *     Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
17593 + *     warranty for any of this software. This material is provided
17594 + *     "AS-IS" and at no charge.
17595   *
17596   *     (c) Copyright 1995    Alan Cox <alan@redhat.com>
17597   *
17598 @@ -22,33 +22,39 @@
17599   *          Can't add timeout - driver doesn't allow changing value
17600   */
17601  
17602 -#include <linux/config.h>
17603  #include <linux/module.h>
17604  #include <linux/moduleparam.h>
17605  #include <linux/types.h>
17606  #include <linux/miscdevice.h>
17607  #include <linux/watchdog.h>
17608 +#include <linux/fs.h>
17609  #include <linux/ioport.h>
17610  #include <linux/notifier.h>
17611 -#include <linux/fs.h>
17612  #include <linux/reboot.h>
17613  #include <linux/init.h>
17614 -#include <linux/spinlock.h>
17615  
17616  #include <asm/io.h>
17617  #include <asm/uaccess.h>
17618  #include <asm/system.h>
17619  
17620 -static int acq_is_open;
17621 -static spinlock_t acq_lock;
17622 -static int expect_close = 0;
17623 +#define WATCHDOG_NAME "Acquire WDT"
17624 +#define PFX WATCHDOG_NAME ": "
17625 +#define WATCHDOG_TIMEOUT 0     /* ??? Is the timeout hardcoded to 1 minute ??? */
17626 +
17627 +static unsigned long acq_is_open;
17628 +static char expect_close;
17629  
17630  /*
17631   *     You must set these - there is no sane way to probe for this board.
17632   */
17633
17634 -#define WDT_STOP 0x43
17635 -#define WDT_START 0x443
17636 +
17637 +static int wdt_stop = 0x43;
17638 +module_param(wdt_stop, int, 0);
17639 +MODULE_PARM_DESC(wdt_stop, "Acquire WDT 'stop' io port (default 0x43)");
17640 +
17641 +static int wdt_start = 0x443;
17642 +module_param(wdt_start, int, 0);
17643 +MODULE_PARM_DESC(wdt_start, "Acquire WDT 'start' io port (default 0x443)");
17644  
17645  #ifdef CONFIG_WATCHDOG_NOWAYOUT
17646  static int nowayout = 1;
17647 @@ -62,38 +68,52 @@
17648  /*
17649   *     Kernel methods.
17650   */
17651
17652  
17653  static void acq_ping(void)
17654  {
17655         /* Write a watchdog value */
17656 -       inb_p(WDT_START);
17657 +       inb_p(wdt_start);
17658  }
17659  
17660 +static void acq_stop(void)
17661 +{
17662 +       /* Turn the card off */
17663 +       inb_p(wdt_stop);
17664 +}
17665 +
17666 +/*
17667 + *     /dev/watchdog handling.
17668 + */
17669 +
17670  static ssize_t acq_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
17671  {
17672         /*  Can't seek (pwrite) on this device  */
17673         if (ppos != &file->f_pos)
17674                 return -ESPIPE;
17675  
17676 +       /* See if we got the magic character 'V' and reload the timer */
17677         if(count) {
17678                 if (!nowayout) {
17679                         size_t i;
17680  
17681 +                       /* note: just in case someone wrote the magic character
17682 +                        * five months ago... */
17683                         expect_close = 0;
17684  
17685 +                       /* scan to see wether or not we got the magic character */
17686                         for (i = 0; i != count; i++) {
17687                                 char c;
17688                                 if (get_user(c, buf + i))
17689                                         return -EFAULT;
17690                                 if (c == 'V')
17691 -                                       expect_close = 1;
17692 +                                       expect_close = 42;
17693                         }
17694                 }
17695 +
17696 +               /* Well, anyhow someone wrote to us, we should return that favour */
17697                 acq_ping();
17698 -               return 1;
17699         }
17700 -       return 0;
17701 +       return count;
17702  }
17703  
17704  static int acq_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
17705 @@ -103,65 +123,75 @@
17706         {
17707                 .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
17708                 .firmware_version = 1,
17709 -               .identity = "Acquire WDT"
17710 +               .identity = "Acquire WDT",
17711         };
17712 -       
17713 +
17714         switch(cmd)
17715         {
17716         case WDIOC_GETSUPPORT:
17717 -         if (copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident)))
17718 -           return -EFAULT;
17719 -         break;
17720 -         
17721 +         return copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident)) ? -EFAULT : 0;
17722 +
17723         case WDIOC_GETSTATUS:
17724 -         if (copy_to_user((int *)arg, &acq_is_open,  sizeof(int)))
17725 -           return -EFAULT;
17726 -         break;
17727 +       case WDIOC_GETBOOTSTATUS:
17728 +         return put_user(0, (int *)arg);
17729  
17730         case WDIOC_KEEPALIVE:
17731           acq_ping();
17732 -         break;
17733 +         return 0;
17734 +
17735 +       case WDIOC_GETTIMEOUT:
17736 +         return put_user(WATCHDOG_TIMEOUT, (int *)arg);
17737 +
17738 +       case WDIOC_SETOPTIONS:
17739 +       {
17740 +           int options, retval = -EINVAL;
17741 +
17742 +           if (get_user(options, (int *)arg))
17743 +             return -EFAULT;
17744 +
17745 +           if (options & WDIOS_DISABLECARD)
17746 +           {
17747 +             acq_stop();
17748 +             retval = 0;
17749 +           }
17750 +
17751 +           if (options & WDIOS_ENABLECARD)
17752 +           {
17753 +             acq_ping();
17754 +             retval = 0;
17755 +           }
17756 +
17757 +           return retval;
17758 +       }
17759  
17760         default:
17761 -         return -ENOTTY;
17762 +         return -ENOIOCTLCMD;
17763         }
17764 -       return 0;
17765  }
17766  
17767  static int acq_open(struct inode *inode, struct file *file)
17768  {
17769 -       if ((minor(inode->i_rdev) == WATCHDOG_MINOR)) {
17770 -               spin_lock(&acq_lock);
17771 -               if(acq_is_open) {
17772 -                       spin_unlock(&acq_lock);
17773 -                       return -EBUSY;
17774 -               }
17775 -               if (nowayout)
17776 -                       __module_get(THIS_MODULE);
17777 +       if (test_and_set_bit(0, &acq_is_open))
17778 +               return -EBUSY;
17779  
17780 -               /* Activate */
17781 -               acq_is_open=1;
17782 -               inb_p(WDT_START);      
17783 -               spin_unlock(&acq_lock);
17784 -               return 0;
17785 +       if (nowayout)
17786 +               __module_get(THIS_MODULE);
17787  
17788 -       } else {
17789 -               return -ENODEV;
17790 -       }
17791 +       /* Activate */
17792 +       acq_ping();
17793 +       return 0;
17794  }
17795  
17796  static int acq_close(struct inode *inode, struct file *file)
17797  {
17798 -       if(minor(inode->i_rdev)==WATCHDOG_MINOR) {
17799 -               spin_lock(&acq_lock);
17800 -               if (expect_close)
17801 -                       inb_p(WDT_STOP);
17802 -               else
17803 -                       printk(KERN_CRIT "WDT closed unexpectedly.  WDT will not stop!\n");
17804 -
17805 -               acq_is_open=0;
17806 -               spin_unlock(&acq_lock);
17807 +       if (expect_close == 42) {
17808 +               acq_stop();
17809 +       } else {
17810 +               printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
17811 +               acq_ping();
17812         }
17813 +       clear_bit(0, &acq_is_open);
17814 +       expect_close = 0;
17815         return 0;
17816  }
17817  
17818 @@ -172,20 +202,20 @@
17819  static int acq_notify_sys(struct notifier_block *this, unsigned long code,
17820         void *unused)
17821  {
17822 -       if(code==SYS_DOWN || code==SYS_HALT)
17823 -               /* Turn the card off */
17824 -               inb_p(WDT_STOP);
17825 -
17826 +       if(code==SYS_DOWN || code==SYS_HALT) {
17827 +               /* Turn the WDT off */
17828 +               acq_stop();
17829 +       }
17830         return NOTIFY_DONE;
17831  }
17832
17833 +
17834  /*
17835   *     Kernel Interfaces
17836   */
17837
17838
17839 +
17840  static struct file_operations acq_fops = {
17841         .owner          = THIS_MODULE,
17842 +       .llseek         = no_llseek,
17843         .write          = acq_write,
17844         .ioctl          = acq_ioctl,
17845         .open           = acq_open,
17846 @@ -196,52 +226,84 @@
17847  {
17848         .minor = WATCHDOG_MINOR,
17849         .name = "watchdog",
17850 -       .fops = &acq_fops
17851 +       .fops = &acq_fops,
17852  };
17853  
17854 -
17855  /*
17856   *     The WDT card needs to learn about soft shutdowns in order to
17857 - *     turn the timebomb registers off. 
17858 + *     turn the timebomb registers off.
17859   */
17860
17861 +
17862  static struct notifier_block acq_notifier =
17863  {
17864         .notifier_call = acq_notify_sys,
17865         .next = NULL,
17866 -       .priority = 0
17867 +       .priority = 0,
17868  };
17869  
17870  static int __init acq_init(void)
17871  {
17872 +       int ret;
17873 +
17874         printk(KERN_INFO "WDT driver for Acquire single board computer initialising.\n");
17875  
17876 -       spin_lock_init(&acq_lock);
17877 -       if (misc_register(&acq_miscdev))
17878 -               return -ENODEV;
17879 -       if (!request_region(WDT_STOP, 1, "Acquire WDT")) {
17880 -               misc_deregister(&acq_miscdev);
17881 -               return -EIO;
17882 -       }
17883 -       if (!request_region(WDT_START, 1, "Acquire WDT")) {
17884 -               release_region(WDT_STOP, 1);
17885 -               misc_deregister(&acq_miscdev);
17886 -               return -EIO;
17887 +       if (wdt_stop != wdt_start) {
17888 +               if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) {
17889 +                       printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
17890 +                               wdt_stop);
17891 +                       ret = -EIO;
17892 +                       goto out;
17893 +               }
17894         }
17895  
17896 -       register_reboot_notifier(&acq_notifier);
17897 -       return 0;
17898 +       if (!request_region(wdt_start, 1, WATCHDOG_NAME)) {
17899 +               printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
17900 +                       wdt_start);
17901 +               ret = -EIO;
17902 +               goto unreg_stop;
17903 +       }
17904 +
17905 +        ret = register_reboot_notifier(&acq_notifier);
17906 +        if (ret != 0) {
17907 +                printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
17908 +                        ret);
17909 +                goto unreg_regions;
17910 +        }
17911 +                                                                                                 
17912 +        ret = misc_register(&acq_miscdev);
17913 +        if (ret != 0) {
17914 +                printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
17915 +                        WATCHDOG_MINOR, ret);
17916 +                goto unreg_reboot;
17917 +        }
17918 +                                                                                                 
17919 +        printk (KERN_INFO PFX "initialized. (nowayout=%d)\n",
17920 +                nowayout);
17921 +                                                                                                 
17922 +out:
17923 +        return ret;
17924 +unreg_reboot:
17925 +        unregister_reboot_notifier(&acq_notifier);
17926 +unreg_regions:
17927 +        release_region(wdt_start, 1);
17928 +unreg_stop:
17929 +        if (wdt_stop != wdt_start)
17930 +                release_region(wdt_stop, 1);
17931 +        goto out;
17932  }
17933 -       
17934 +
17935  static void __exit acq_exit(void)
17936  {
17937         misc_deregister(&acq_miscdev);
17938         unregister_reboot_notifier(&acq_notifier);
17939 -       release_region(WDT_STOP,1);
17940 -       release_region(WDT_START,1);
17941 +       if(wdt_stop != wdt_start)
17942 +               release_region(wdt_stop,1);
17943 +       release_region(wdt_start,1);
17944  }
17945  
17946  module_init(acq_init);
17947  module_exit(acq_exit);
17948  
17949  MODULE_LICENSE("GPL");
17950 +MODULE_AUTHOR("Unkown");
17951 +MODULE_DESCRIPTION("Acquire Single Board Computer Watchdog Timer driver");
17952 diff -Nru a/drivers/char/watchdog/advantechwdt.c b/drivers/char/watchdog/advantechwdt.c
17953 --- a/drivers/char/watchdog/advantechwdt.c      Sat Aug  9 07:00:04 2003
17954 +++ b/drivers/char/watchdog/advantechwdt.c      Sat Aug 30 04:48:19 2003
17955 @@ -133,7 +133,7 @@
17956         static struct watchdog_info ident = {
17957                 .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
17958                 .firmware_version = 1,
17959 -               .identity = "Advantech WDT"
17960 +               .identity = "Advantech WDT",
17961         };
17962  
17963         switch (cmd) {
17964 diff -Nru a/drivers/char/watchdog/alim1535_wdt.c b/drivers/char/watchdog/alim1535_wdt.c
17965 --- /dev/null   Wed Dec 31 16:00:00 1969
17966 +++ b/drivers/char/watchdog/alim1535_wdt.c      Sun Aug 31 11:38:01 2003
17967 @@ -0,0 +1,465 @@
17968 +/*
17969 + *     Watchdog for the 7101 PMU version found in the ALi M1535 chipsets
17970 + *
17971 + *     This program is free software; you can redistribute it and/or
17972 + *     modify it under the terms of the GNU General Public License
17973 + *     as published by the Free Software Foundation; either version
17974 + *     2 of the License, or (at your option) any later version.
17975 + */
17976 +
17977 +#include <linux/module.h>
17978 +#include <linux/moduleparam.h>
17979 +#include <linux/types.h>
17980 +#include <linux/miscdevice.h>
17981 +#include <linux/watchdog.h>
17982 +#include <linux/ioport.h>
17983 +#include <linux/notifier.h>
17984 +#include <linux/reboot.h>
17985 +#include <linux/init.h>
17986 +#include <linux/pci.h>
17987 +
17988 +#include <asm/uaccess.h>
17989 +#include <asm/io.h>
17990 +
17991 +#define WATCHDOG_NAME "ALi_M1535"
17992 +#define PFX WATCHDOG_NAME ": "
17993 +#define WATCHDOG_TIMEOUT 60    /* 60 sec default timeout */
17994 +
17995 +/* internal variables */
17996 +static unsigned long ali_is_open;
17997 +static char ali_expect_release;
17998 +static struct pci_dev *ali_pci;
17999 +static u32 ali_timeout_bits;   /* stores the computed timeout */
18000 +static spinlock_t ali_lock;    /* Guards the hardware */
18001 +
18002 +/* module parameters */
18003 +static int timeout = WATCHDOG_TIMEOUT;
18004 +module_param(timeout, int, 0);
18005 +MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (0<timeout<18000, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ")");
18006 +
18007 +#ifdef CONFIG_WATCHDOG_NOWAYOUT
18008 +static int nowayout = 1;
18009 +#else
18010 +static int nowayout = 0;
18011 +#endif
18012 +
18013 +module_param(nowayout, int, 0);
18014 +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
18015 +
18016 +/*
18017 + *     ali_start       -       start watchdog countdown
18018 + *
18019 + *     Starts the timer running providing the timer has a counter
18020 + *     configuration set.
18021 + */
18022 +
18023 +static void ali_start(void)
18024 +{
18025 +       u32 val;
18026 +
18027 +       spin_lock(&ali_lock);
18028 +
18029 +       pci_read_config_dword(ali_pci, 0xCC, &val);
18030 +       val &= ~0x3F;   /* Mask count */
18031 +       val |= (1<<25) | ali_timeout_bits;
18032 +       pci_write_config_dword(ali_pci, 0xCC, val);
18033 +
18034 +       spin_unlock(&ali_lock);
18035 +}
18036 +
18037 +/*
18038 + *     ali_stop        -       stop the timer countdown
18039 + *
18040 + *     Stop the ALi watchdog countdown
18041 + */
18042 +
18043 +static void ali_stop(void)
18044 +{
18045 +       u32 val;
18046 +
18047 +       spin_lock(&ali_lock);
18048 +
18049 +       pci_read_config_dword(ali_pci, 0xCC, &val);
18050 +       val &= ~0x3F;   /* Mask count to zero (disabled) */
18051 +       val &= ~(1<<25);/* and for safety mask the reset enable */
18052 +       pci_write_config_dword(ali_pci, 0xCC, val);
18053 +
18054 +       spin_unlock(&ali_lock);
18055 +}
18056 +
18057 +/*
18058 + *     ali_keepalive   -       send a keepalive to the watchdog
18059 + *
18060 + *      Send a keepalive to the timer (actually we restart the timer).
18061 + */
18062 +
18063 +static void ali_keepalive(void)
18064 +{
18065 +       ali_start();
18066 +}
18067 +
18068 +/*
18069 + *     ali_settimer    -       compute the timer reload value
18070 + *     @t: time in seconds
18071 + *
18072 + *     Computes the timeout values needed
18073 + */
18074 +
18075 +static int ali_settimer(int t)
18076 +{
18077 +       if(t < 0)
18078 +               return -EINVAL;
18079 +       else if(t < 60)
18080 +               ali_timeout_bits = t|(1<<6);
18081 +       else if(t < 3600)
18082 +               ali_timeout_bits = (t/60)|(1<<7);
18083 +       else if(t < 18000)
18084 +               ali_timeout_bits = (t/300)|(1<<6)|(1<<7);
18085 +       else return -EINVAL;
18086 +
18087 +       timeout = t;
18088 +       return 0;
18089 +}
18090 +
18091 +/*
18092 + *     /dev/watchdog handling
18093 + */
18094 +
18095 +/*
18096 + *     ali_write       -       writes to ALi watchdog
18097 + *     @file: file from VFS
18098 + *     @data: user address of data
18099 + *     @len: length of data
18100 + *     @ppos: pointer to the file offset
18101 + *
18102 + *     Handle a write to the ALi watchdog. Writing to the file pings
18103 + *     the watchdog and resets it. Writing the magic 'V' sequence allows
18104 + *     the next close to turn off the watchdog.
18105 + */
18106 +
18107 +static ssize_t ali_write(struct file *file, const char *data,
18108 +                             size_t len, loff_t * ppos)
18109 +{
18110 +       /*  Can't seek (pwrite) on this device  */
18111 +       if (ppos != &file->f_pos)
18112 +               return -ESPIPE;
18113 +
18114 +       /* See if we got the magic character 'V' and reload the timer */
18115 +       if (len) {
18116 +               if (!nowayout) {
18117 +                       size_t i;
18118 +
18119 +                       /* note: just in case someone wrote the magic character
18120 +                        * five months ago... */
18121 +                       ali_expect_release = 0;
18122 +
18123 +                       /* scan to see wether or not we got the magic character */
18124 +                       for (i = 0; i != len; i++) {
18125 +                               char c;
18126 +                               if(get_user(c, data+i))
18127 +                                       return -EFAULT;
18128 +                               if (c == 'V')
18129 +                                       ali_expect_release = 42;
18130 +                       }
18131 +               }
18132 +
18133 +               /* someone wrote to us, we should reload the timer */
18134 +               ali_start();
18135 +       }
18136 +       return len;
18137 +}
18138 +
18139 +/*
18140 + *     ali_ioctl       -       handle watchdog ioctls
18141 + *     @inode: VFS inode
18142 + *     @file: VFS file pointer
18143 + *     @cmd: ioctl number
18144 + *     @arg: arguments to the ioctl
18145 + *
18146 + *     Handle the watchdog ioctls supported by the ALi driver. Really
18147 + *     we want an extension to enable irq ack monitoring and the like
18148 + */
18149 +
18150 +static int ali_ioctl(struct inode *inode, struct file *file,
18151 +                         unsigned int cmd, unsigned long arg)
18152 +{
18153 +       static struct watchdog_info ident = {
18154 +               .options =              WDIOF_KEEPALIVEPING |
18155 +                                       WDIOF_SETTIMEOUT |
18156 +                                       WDIOF_MAGICCLOSE,
18157 +               .firmware_version =     0,
18158 +               .identity =             "ALi M1535 WatchDog Timer",
18159 +       };
18160 +
18161 +       switch (cmd) {
18162 +               case WDIOC_GETSUPPORT:
18163 +                       return copy_to_user((struct watchdog_info *) arg, &ident,
18164 +                               sizeof (ident)) ? -EFAULT : 0;
18165 +
18166 +               case WDIOC_GETSTATUS:
18167 +               case WDIOC_GETBOOTSTATUS:
18168 +                       return put_user(0, (int *) arg);
18169 +
18170 +               case WDIOC_KEEPALIVE:
18171 +                       ali_keepalive();
18172 +                       return 0;
18173 +
18174 +               case WDIOC_SETOPTIONS:
18175 +               {
18176 +                       int new_options, retval = -EINVAL;
18177 +
18178 +                       if (get_user (new_options, (int *) arg))
18179 +                               return -EFAULT;
18180 +
18181 +                       if (new_options & WDIOS_DISABLECARD) {
18182 +                               ali_stop();
18183 +                               retval = 0;
18184 +                       }
18185 +
18186 +                       if (new_options & WDIOS_ENABLECARD) {
18187 +                               ali_start();
18188 +                               retval = 0;
18189 +                       }
18190 +
18191 +                       return retval;
18192 +               }
18193 +
18194 +               case WDIOC_SETTIMEOUT:
18195 +               {
18196 +                       int new_timeout;
18197 +
18198 +                       if (get_user(new_timeout, (int *) arg))
18199 +                               return -EFAULT;
18200 +
18201 +                       if (ali_settimer(new_timeout))
18202 +                           return -EINVAL;
18203 +
18204 +                       ali_keepalive();
18205 +                       /* Fall */
18206 +               }
18207 +
18208 +               case WDIOC_GETTIMEOUT:
18209 +                       return put_user(timeout, (int *)arg);
18210 +
18211 +               default:
18212 +                       return -ENOIOCTLCMD;
18213 +       }
18214 +}
18215 +
18216 +/*
18217 + *     ali_open        -       handle open of ali watchdog
18218 + *     @inode: inode from VFS
18219 + *     @file: file from VFS
18220 + *
18221 + *     Open the ALi watchdog device. Ensure only one person opens it
18222 + *     at a time. Also start the watchdog running.
18223 + */
18224 +
18225 +static int ali_open(struct inode *inode, struct file *file)
18226 +{
18227 +       /* /dev/watchdog can only be opened once */
18228 +       if (test_and_set_bit(0, &ali_is_open))
18229 +               return -EBUSY;
18230 +
18231 +       /* Activate */
18232 +       ali_start();
18233 +       return 0;
18234 +}
18235 +
18236 +/*
18237 + *     ali_release     -       close an ALi watchdog
18238 + *     @inode: inode from VFS
18239 + *     @file: file from VFS
18240 + *
18241 + *     Close the ALi watchdog device. Actual shutdown of the timer
18242 + *     only occurs if the magic sequence has been set.
18243 + */
18244 +
18245 +static int ali_release(struct inode *inode, struct file *file)
18246 +{
18247 +       /*
18248 +        *      Shut off the timer.
18249 +        */
18250 +       if (ali_expect_release == 42) {
18251 +               ali_stop();
18252 +       } else {
18253 +               printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
18254 +               ali_keepalive();
18255 +       }
18256 +       clear_bit(0, &ali_is_open);
18257 +       ali_expect_release = 0;
18258 +       return 0;
18259 +}
18260 +
18261 +/*
18262 + *     ali_notify_sys  -       System down notifier
18263 + *
18264 + *     Notifier for system down
18265 + */
18266 +
18267 +
18268 +static int ali_notify_sys(struct notifier_block *this, unsigned long code, void *unused)
18269 +{
18270 +       if (code==SYS_DOWN || code==SYS_HALT) {
18271 +               /* Turn the WDT off */
18272 +               ali_stop();
18273 +       }
18274 +
18275 +       return NOTIFY_DONE;
18276 +}
18277 +
18278 +/*
18279 + *     Data for PCI driver interface
18280 + *
18281 + *     This data only exists for exporting the supported
18282 + *     PCI ids via MODULE_DEVICE_TABLE.  We do not actually
18283 + *     register a pci_driver, because someone else might one day
18284 + *     want to register another driver on the same PCI id.
18285 + */
18286 +
18287 +static struct pci_device_id ali_pci_tbl[] __initdata = {
18288 +       { PCI_VENDOR_ID_AL, 1535, PCI_ANY_ID, PCI_ANY_ID,},
18289 +       { 0, },
18290 +};
18291 +MODULE_DEVICE_TABLE(pci, ali_pci_tbl);
18292 +
18293 +/*
18294 + *     ali_find_watchdog       -       find a 1535 and 7101
18295 + *
18296 + *     Scans the PCI hardware for a 1535 series bridge and matching 7101
18297 + *     watchdog device. This may be overtight but it is better to be safe
18298 + */
18299 +
18300 +static int __init ali_find_watchdog(void)
18301 +{
18302 +       struct pci_dev *pdev;
18303 +       u32 wdog;
18304 +
18305 +       /* Check for a 1535 series bridge */
18306 +       pdev = pci_find_device(PCI_VENDOR_ID_AL, 0x1535, NULL);
18307 +       if(pdev == NULL)
18308 +               return -ENODEV;
18309 +
18310 +       /* Check for the a 7101 PMU */
18311 +       pdev = pci_find_device(PCI_VENDOR_ID_AL, 0x7101, NULL);
18312 +       if(pdev == NULL)
18313 +               return -ENODEV;
18314 +
18315 +       if(pci_enable_device(pdev))
18316 +               return -EIO;
18317 +
18318 +       ali_pci = pdev;
18319 +
18320 +       /*
18321 +        *      Initialize the timer bits
18322 +        */
18323 +       pci_read_config_dword(pdev, 0xCC, &wdog);
18324 +
18325 +       wdog &= ~0x3F;          /* Timer bits */
18326 +       wdog &= ~((1<<27)|(1<<26)|(1<<25)|(1<<24));     /* Issued events */
18327 +       wdog &= ~((1<<16)|(1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9));      /* No monitor bits */
18328 +
18329 +       pci_write_config_dword(pdev, 0xCC, wdog);
18330 +
18331 +       return 0;
18332 +}
18333 +
18334 +/*
18335 + *     Kernel Interfaces
18336 + */
18337 +
18338 +static struct file_operations ali_fops = {
18339 +       .owner =        THIS_MODULE,
18340 +       .llseek =       no_llseek,
18341 +       .write =        ali_write,
18342 +       .ioctl =        ali_ioctl,
18343 +       .open =         ali_open,
18344 +       .release =      ali_release,
18345 +};
18346 +
18347 +static struct miscdevice ali_miscdev = {
18348 +       .minor =        WATCHDOG_MINOR,
18349 +       .name =         "watchdog",
18350 +       .fops =         &ali_fops,
18351 +};
18352 +
18353 +static struct notifier_block ali_notifier = {
18354 +       .notifier_call =        ali_notify_sys,
18355 +       .next =                 NULL,
18356 +       .priority =             0,
18357 +};
18358 +
18359 +/*
18360 + *     watchdog_init   -       module initialiser
18361 + *
18362 + *     Scan for a suitable watchdog and if so initialize it. Return an error
18363 + *     if we cannot, the error causes the module to unload
18364 + */
18365 +
18366 +static int __init watchdog_init(void)
18367 +{
18368 +       int ret;
18369 +
18370 +       spin_lock_init(&ali_lock);
18371 +
18372 +       /* Check wether or not the hardware watchdog is there */
18373 +       if (ali_find_watchdog() != 0) {
18374 +               return -ENODEV;
18375 +       }
18376 +
18377 +       /* Check that the timeout value is within it's range ; if not reset to the default */
18378 +       if (timeout < 1 || timeout >= 18000) {
18379 +               timeout = WATCHDOG_TIMEOUT;
18380 +               printk(KERN_INFO PFX "timeout value must be 0<timeout<18000, using %d\n",
18381 +                       timeout);
18382 +       }
18383 +
18384 +       /* Calculate the watchdog's timeout */
18385 +       ali_settimer(timeout);
18386 +
18387 +       ret = misc_register(&ali_miscdev);
18388 +       if (ret != 0) {
18389 +               printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
18390 +                       WATCHDOG_MINOR, ret);
18391 +               goto out;
18392 +       }
18393 +
18394 +       ret = register_reboot_notifier(&ali_notifier);
18395 +       if (ret != 0) {
18396 +               printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
18397 +                       ret);
18398 +               goto unreg_miscdev;
18399 +       }
18400 +
18401 +       printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n",
18402 +               timeout, nowayout);
18403 +
18404 +out:
18405 +       return ret;
18406 +unreg_miscdev:
18407 +       misc_deregister(&ali_miscdev);
18408 +       goto out;
18409 +}
18410 +
18411 +/*
18412 + *     watchdog_exit   -       module de-initialiser
18413 + *
18414 + *     Called while unloading a successfully installed watchdog module.
18415 + */
18416 +
18417 +static void __exit watchdog_exit(void)
18418 +{
18419 +       /* Stop the timer before we leave */
18420 +       ali_stop();
18421 +
18422 +       /* Deregister */
18423 +       unregister_reboot_notifier(&ali_notifier);
18424 +       misc_deregister(&ali_miscdev);
18425 +}
18426 +
18427 +module_init(watchdog_init);
18428 +module_exit(watchdog_exit);
18429 +
18430 +MODULE_AUTHOR("Alan Cox");
18431 +MODULE_DESCRIPTION("ALi M1535 PMU Watchdog Timer driver");
18432 +MODULE_LICENSE("GPL");
18433 diff -Nru a/drivers/char/watchdog/cpu5wdt.c b/drivers/char/watchdog/cpu5wdt.c
18434 --- a/drivers/char/watchdog/cpu5wdt.c   Thu Feb 13 06:54:43 2003
18435 +++ b/drivers/char/watchdog/cpu5wdt.c   Tue Aug 26 09:25:41 2003
18436 @@ -134,7 +134,7 @@
18437  
18438  static int cpu5wdt_open(struct inode *inode, struct file *file)
18439  {
18440 -       switch(minor(inode->i_rdev)) {
18441 +       switch(iminor(inode)) {
18442                 case WATCHDOG_MINOR:
18443                         if ( test_and_set_bit(0, &cpu5wdt_device.inuse) )
18444                                 return -EBUSY;
18445 @@ -148,7 +148,7 @@
18446  
18447  static int cpu5wdt_release(struct inode *inode, struct file *file)
18448  {
18449 -       if(minor(inode->i_rdev)==WATCHDOG_MINOR) {
18450 +       if(iminor(inode)==WATCHDOG_MINOR) {
18451                 clear_bit(0, &cpu5wdt_device.inuse);
18452         }
18453         return 0;
18454 diff -Nru a/drivers/char/watchdog/ib700wdt.c b/drivers/char/watchdog/ib700wdt.c
18455 --- a/drivers/char/watchdog/ib700wdt.c  Fri Aug  8 03:28:08 2003
18456 +++ b/drivers/char/watchdog/ib700wdt.c  Tue Aug 26 09:25:41 2003
18457 @@ -218,7 +218,7 @@
18458  static int
18459  ibwdt_open(struct inode *inode, struct file *file)
18460  {
18461 -       if (minor(inode->i_rdev) == WATCHDOG_MINOR) {
18462 +       if (iminor(inode) == WATCHDOG_MINOR) {
18463                 spin_lock(&ibwdt_lock);
18464                 if (ibwdt_is_open) {
18465                         spin_unlock(&ibwdt_lock);
18466 @@ -240,7 +240,7 @@
18467  static int
18468  ibwdt_close(struct inode *inode, struct file *file)
18469  {
18470 -       if (minor(inode->i_rdev) == WATCHDOG_MINOR) {
18471 +       if (iminor(inode) == WATCHDOG_MINOR) {
18472                 spin_lock(&ibwdt_lock);
18473                 if (expect_close)
18474                         outb_p(wd_times[wd_margin], WDT_STOP);
18475 diff -Nru a/drivers/char/watchdog/machzwd.c b/drivers/char/watchdog/machzwd.c
18476 --- a/drivers/char/watchdog/machzwd.c   Fri Aug  8 03:28:08 2003
18477 +++ b/drivers/char/watchdog/machzwd.c   Tue Aug 26 09:25:41 2003
18478 @@ -377,7 +377,7 @@
18479  
18480  static int zf_open(struct inode *inode, struct file *file)
18481  {
18482 -       switch(minor(inode->i_rdev)){
18483 +       switch(iminor(inode)){
18484                 case WATCHDOG_MINOR:
18485                         spin_lock(&zf_lock);
18486                         if(zf_is_open){
18487 @@ -402,7 +402,7 @@
18488  
18489  static int zf_close(struct inode *inode, struct file *file)
18490  {
18491 -       if(minor(inode->i_rdev) == WATCHDOG_MINOR){
18492 +       if(iminor(inode) == WATCHDOG_MINOR){
18493  
18494                 if(zf_expect_close){
18495                         zf_timer_off();
18496 diff -Nru a/drivers/char/watchdog/pcwd.c b/drivers/char/watchdog/pcwd.c
18497 --- a/drivers/char/watchdog/pcwd.c      Fri Aug  1 03:02:31 2003
18498 +++ b/drivers/char/watchdog/pcwd.c      Tue Aug 26 09:25:41 2003
18499 @@ -426,7 +426,7 @@
18500  
18501  static int pcwd_open(struct inode *ino, struct file *filep)
18502  {
18503 -       switch (minor(ino->i_rdev)) {
18504 +       switch (iminor(ino)) {
18505         case WATCHDOG_MINOR:
18506                 if (!atomic_dec_and_test(&open_allowed) ) {
18507                         atomic_inc( &open_allowed );
18508 @@ -457,7 +457,7 @@
18509         /*  Can't seek (pread) on this device  */
18510         if (ppos != &file->f_pos)
18511                 return -ESPIPE;
18512 -       switch(minor(file->f_dentry->d_inode->i_rdev)) 
18513 +       switch(iminor(file->f_dentry->d_inode)) 
18514         {
18515                 case TEMP_MINOR:
18516                         /*
18517 @@ -477,7 +477,7 @@
18518  
18519  static int pcwd_close(struct inode *ino, struct file *filep)
18520  {
18521 -       if (minor(ino->i_rdev)==WATCHDOG_MINOR) {
18522 +       if (iminor(ino)==WATCHDOG_MINOR) {
18523                 if (expect_close) {
18524                         /*  Disable the board  */
18525                         if (revision == PCWD_REVISION_C) {
18526 diff -Nru a/drivers/char/watchdog/wafer5823wdt.c b/drivers/char/watchdog/wafer5823wdt.c
18527 --- a/drivers/char/watchdog/wafer5823wdt.c      Fri Aug  1 03:02:31 2003
18528 +++ b/drivers/char/watchdog/wafer5823wdt.c      Sun Aug 31 11:32:43 2003
18529 @@ -1,5 +1,5 @@
18530  /*
18531 - *     ICP Wafer 5823 Single Board Computer WDT driver for Linux 2.4.x
18532 + *     ICP Wafer 5823 Single Board Computer WDT driver
18533   *      http://www.icpamerica.com/wafer_5823.php
18534   *      May also work on other similar models
18535   *
18536 @@ -17,10 +17,10 @@
18537   *     modify it under the terms of the GNU General Public License
18538   *     as published by the Free Software Foundation; either version
18539   *     2 of the License, or (at your option) any later version.
18540 - *     
18541 - *     Neither Alan Cox nor CymruNet Ltd. admit liability nor provide 
18542 - *     warranty for any of this software. This material is provided 
18543 - *     "AS-IS" and at no charge.       
18544 + *
18545 + *     Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
18546 + *     warranty for any of this software. This material is provided
18547 + *     "AS-IS" and at no charge.
18548   *
18549   *     (c) Copyright 1995    Alan Cox <alan@lxorguk.ukuu.org.uk>
18550   *
18551 @@ -39,9 +39,13 @@
18552  #include <asm/io.h>
18553  #include <asm/uaccess.h>
18554  
18555 +#define WATCHDOG_NAME "Wafer 5823 WDT"
18556 +#define PFX WATCHDOG_NAME ": "
18557 +#define WD_TIMO 60                     /* 60 sec default timeout */
18558 +
18559  static unsigned long wafwdt_is_open;
18560 +static char expect_close;
18561  static spinlock_t wafwdt_lock;
18562 -static int expect_close = 0;
18563  
18564  /*
18565   *     You must set these - there is no sane way to probe for this board.
18566 @@ -52,11 +56,17 @@
18567   *      to restart it again.
18568   */
18569  
18570 -#define WDT_START 0x443
18571 -#define WDT_STOP 0x843
18572 -
18573 -#define WD_TIMO 60             /* 1 minute */
18574 -static int wd_margin = WD_TIMO;
18575 +static int wdt_stop = 0x843;
18576 +module_param(wdt_stop, int, 0);
18577 +MODULE_PARM_DESC(wdt_stop, "Wafer 5823 WDT 'stop' io port (default 0x843)");
18578 +
18579 +static int wdt_start = 0x443;
18580 +module_param(wdt_start, int, 0);
18581 +MODULE_PARM_DESC(wdt_start, "Wafer 5823 WDT 'start' io port (default 0x443)");
18582 +
18583 +static int timeout = WD_TIMO;  /* in seconds */
18584 +module_param(timeout, int, 0);
18585 +MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=255, default=" __MODULE_STRING(WD_TIMO) ".");
18586  
18587  #ifdef CONFIG_WATCHDOG_NOWAYOUT
18588  static int nowayout = 1;
18589 @@ -70,24 +80,24 @@
18590  static void wafwdt_ping(void)
18591  {
18592         /* pat watchdog */
18593 -        spin_lock(&wafwdt_lock);
18594 -       inb_p(WDT_STOP);
18595 -       inb_p(WDT_START);
18596 -        spin_unlock(&wafwdt_lock);
18597 +       spin_lock(&wafwdt_lock);
18598 +       inb_p(wdt_stop);
18599 +       inb_p(wdt_start);
18600 +       spin_unlock(&wafwdt_lock);
18601  }
18602  
18603  static void wafwdt_start(void)
18604  {
18605         /* start up watchdog */
18606 -       outb_p(wd_margin, WDT_START);
18607 -       inb_p(WDT_START);
18608 +       outb_p(timeout, wdt_start);
18609 +       inb_p(wdt_start);
18610  }
18611  
18612  static void
18613  wafwdt_stop(void)
18614  {
18615         /* stop watchdog */
18616 -       inb_p(WDT_STOP);
18617 +       inb_p(wdt_stop);
18618  }
18619  
18620  static ssize_t wafwdt_write(struct file *file, const char *buf, size_t count, loff_t * ppos)
18621 @@ -96,6 +106,7 @@
18622         if (ppos != &file->f_pos)
18623                 return -ESPIPE;
18624  
18625 +       /* See if we got the magic character 'V' and reload the timer */
18626         if (count) {
18627                 if (!nowayout) {
18628                         size_t i;
18629 @@ -103,30 +114,30 @@
18630                         /* In case it was set long ago */
18631                         expect_close = 0;
18632  
18633 +                       /* scan to see wether or not we got the magic character */
18634                         for (i = 0; i != count; i++) {
18635                                 char c;
18636                                 if (get_user(c, buf + i))
18637                                         return -EFAULT;
18638                                 if (c == 'V')
18639 -                                       expect_close = 1;
18640 +                                       expect_close = 42;
18641                         }
18642                 }
18643 +               /* Well, anyhow someone wrote to us, we should return that favour */
18644                 wafwdt_ping();
18645 -               return 1;
18646         }
18647 -       return 0;
18648 +       return count;
18649  }
18650  
18651  static int wafwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
18652              unsigned long arg)
18653  {
18654 -       int new_margin;
18655 +       int new_timeout;
18656         static struct watchdog_info ident = {
18657                 .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
18658                 .firmware_version = 1,
18659 -               .identity = "Wafer 5823 WDT"
18660 +               .identity = "Wafer 5823 WDT",
18661         };
18662 -       int one=1;
18663  
18664         switch (cmd) {
18665         case WDIOC_GETSUPPORT:
18666 @@ -136,25 +147,44 @@
18667                 break;
18668  
18669         case WDIOC_GETSTATUS:
18670 -               if (copy_to_user((int *) arg, &one, sizeof (int)))
18671 -                       return -EFAULT;
18672 -               break;
18673 +       case WDIOC_GETBOOTSTATUS:
18674 +               return put_user(0, (int *)arg);
18675  
18676         case WDIOC_KEEPALIVE:
18677                 wafwdt_ping();
18678                 break;
18679  
18680         case WDIOC_SETTIMEOUT:
18681 -               if (get_user(new_margin, (int *)arg))
18682 +               if (get_user(new_timeout, (int *)arg))
18683                         return -EFAULT;
18684 -               if ((new_margin < 1) || (new_margin > 255))
18685 +               if ((new_timeout < 1) || (new_timeout > 255))
18686                         return -EINVAL;
18687 -               wd_margin = new_margin;
18688 +               timeout = new_timeout;
18689                 wafwdt_stop();
18690                 wafwdt_start();
18691                 /* Fall */
18692         case WDIOC_GETTIMEOUT:
18693 -               return put_user(wd_margin, (int *)arg);
18694 +               return put_user(timeout, (int *)arg);
18695 +
18696 +       case WDIOC_SETOPTIONS:
18697 +       {
18698 +               int options, retval = -EINVAL;
18699 +
18700 +               if (get_user(options, (int *)arg))
18701 +                       return -EFAULT;
18702 +
18703 +               if (options & WDIOS_DISABLECARD) {
18704 +                       wafwdt_start();
18705 +                       retval = 0;
18706 +               }
18707 +
18708 +               if (options & WDIOS_ENABLECARD) {
18709 +                       wafwdt_stop();
18710 +                       retval = 0;
18711 +               }
18712 +
18713 +               return retval;
18714 +       }
18715  
18716         default:
18717                 return -ENOTTY;
18718 @@ -166,6 +196,10 @@
18719  {
18720         if (test_and_set_bit(0, &wafwdt_is_open))
18721                 return -EBUSY;
18722 +
18723 +       /*
18724 +        *      Activate
18725 +        */
18726         wafwdt_start();
18727         return 0;
18728  }
18729 @@ -173,12 +207,14 @@
18730  static int
18731  wafwdt_close(struct inode *inode, struct file *file)
18732  {
18733 -       clear_bit(0, &wafwdt_is_open);
18734 -       if (expect_close) {   
18735 +       if (expect_close == 42) {
18736                 wafwdt_stop();
18737         } else {
18738 -               printk(KERN_CRIT "WDT device closed unexpectedly.  WDT will not stop!\n");
18739 +               printk(KERN_CRIT PFX "WDT device closed unexpectedly.  WDT will not stop!\n");
18740 +               wafwdt_ping();
18741         }
18742 +       clear_bit(0, &wafwdt_is_open);
18743 +       expect_close = 0;
18744         return 0;
18745  }
18746  
18747 @@ -201,6 +237,7 @@
18748  
18749  static struct file_operations wafwdt_fops = {
18750         .owner          = THIS_MODULE,
18751 +       .llseek         = no_llseek,
18752         .write          = wafwdt_write,
18753         .ioctl          = wafwdt_ioctl,
18754         .open           = wafwdt_open,
18755 @@ -210,53 +247,93 @@
18756  static struct miscdevice wafwdt_miscdev = {
18757         .minor  = WATCHDOG_MINOR,
18758         .name   = "watchdog",
18759 -       .fops   = &wafwdt_fops
18760 +       .fops   = &wafwdt_fops,
18761  };
18762  
18763  /*
18764   *     The WDT needs to learn about soft shutdowns in order to
18765 - *     turn the timebomb registers off. 
18766 + *     turn the timebomb registers off.
18767   */
18768  
18769  static struct notifier_block wafwdt_notifier = {
18770         .notifier_call = wafwdt_notify_sys,
18771         .next = NULL,
18772 -       .priority = 0
18773 +       .priority = 0,
18774  };
18775  
18776  static int __init wafwdt_init(void)
18777  {
18778 +       int ret;
18779 +
18780         printk(KERN_INFO "WDT driver for Wafer 5823 single board computer initialising.\n");
18781  
18782         spin_lock_init(&wafwdt_lock);
18783 -       if(!request_region(WDT_STOP, 1, "Wafer 5823 WDT"))
18784 -               goto error;
18785 -       if(!request_region(WDT_START, 1, "Wafer 5823 WDT"))
18786 +
18787 +       if (timeout < 1 || timeout > 63) {
18788 +               timeout = WD_TIMO;
18789 +               printk (KERN_INFO PFX "timeout value must be 1<=x<=255, using %d\n",
18790 +                       timeout);
18791 +       }
18792 +
18793 +       if (wdt_stop != wdt_start) {
18794 +               if(!request_region(wdt_stop, 1, "Wafer 5823 WDT")) {
18795 +                       printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
18796 +                       wdt_stop);
18797 +                       ret = -EIO;
18798 +                       goto error;
18799 +               }
18800 +       }
18801 +
18802 +       if(!request_region(wdt_start, 1, "Wafer 5823 WDT")) {
18803 +               printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
18804 +                       wdt_start);
18805 +               ret = -EIO;
18806                 goto error2;
18807 -       if(misc_register(&wafwdt_miscdev)<0)
18808 +       }
18809 +
18810 +       ret = register_reboot_notifier(&wafwdt_notifier);
18811 +       if (ret != 0) {
18812 +               printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
18813 +                       ret);
18814                 goto error3;
18815 -       register_reboot_notifier(&wafwdt_notifier);
18816 -       return 0;
18817 +       }
18818 +
18819 +       ret = misc_register(&wafwdt_miscdev);
18820 +       if (ret != 0) {
18821 +               printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
18822 +                       WATCHDOG_MINOR, ret);
18823 +               goto error4;
18824 +       }
18825 +
18826 +       printk (KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n",
18827 +               timeout, nowayout);
18828 +
18829 +       return ret;
18830 +error4:
18831 +       unregister_reboot_notifier(&wafwdt_notifier);
18832  error3:
18833 -       release_region(WDT_START, 1);
18834 +       release_region(wdt_start, 1);
18835  error2:
18836 -       release_region(WDT_STOP, 1);
18837 +       if (wdt_stop != wdt_start)
18838 +               release_region(wdt_stop, 1);
18839  error:
18840 -       return -ENODEV;
18841 +       return ret;
18842  }
18843  
18844  static void __exit wafwdt_exit(void)
18845  {
18846         misc_deregister(&wafwdt_miscdev);
18847         unregister_reboot_notifier(&wafwdt_notifier);
18848 -       release_region(WDT_STOP, 1);
18849 -       release_region(WDT_START, 1);
18850 +       if(wdt_stop != wdt_start)
18851 +               release_region(wdt_stop, 1);
18852 +       release_region(wdt_start, 1);
18853  }
18854  
18855  module_init(wafwdt_init);
18856  module_exit(wafwdt_exit);
18857  
18858  MODULE_AUTHOR("Justin Cormack");
18859 +MODULE_DESCRIPTION("ICP Wafer 5823 Single Board Computer WDT driver");
18860  MODULE_LICENSE("GPL");
18861  
18862  /* end of wafer5823wdt.c */
18863 diff -Nru a/drivers/char/watchdog/wdt.c b/drivers/char/watchdog/wdt.c
18864 --- a/drivers/char/watchdog/wdt.c       Thu Apr 24 05:36:57 2003
18865 +++ b/drivers/char/watchdog/wdt.c       Tue Aug 26 09:25:41 2003
18866 @@ -290,7 +290,7 @@
18867         if (ptr != &file->f_pos)
18868                 return -ESPIPE;
18869  
18870 -       switch(minor(file->f_dentry->d_inode->i_rdev))
18871 +       switch(iminor(file->f_dentry->d_inode))
18872         {
18873                 case TEMP_MINOR:
18874                         c*=11;
18875 @@ -373,7 +373,7 @@
18876   
18877  static int wdt_open(struct inode *inode, struct file *file)
18878  {
18879 -       switch(minor(inode->i_rdev))
18880 +       switch(iminor(inode))
18881         {
18882                 case WATCHDOG_MINOR:
18883                         if(test_and_set_bit(0, &wdt_is_open))
18884 @@ -413,7 +413,7 @@
18885   
18886  static int wdt_release(struct inode *inode, struct file *file)
18887  {
18888 -       if(minor(inode->i_rdev)==WATCHDOG_MINOR)
18889 +       if(iminor(inode)==WATCHDOG_MINOR)
18890         {
18891                 if (expect_close) {
18892                         inb_p(WDT_DC);          /* Disable counters */
18893 diff -Nru a/drivers/char/watchdog/wdt_pci.c b/drivers/char/watchdog/wdt_pci.c
18894 --- a/drivers/char/watchdog/wdt_pci.c   Fri Aug  1 11:59:44 2003
18895 +++ b/drivers/char/watchdog/wdt_pci.c   Tue Aug 26 09:25:41 2003
18896 @@ -276,7 +276,7 @@
18897         if (ptr != &file->f_pos)
18898                 return -ESPIPE;
18899  
18900 -       switch(minor(file->f_dentry->d_inode->i_rdev))
18901 +       switch(iminor(file->f_dentry->d_inode))
18902         {
18903                 case TEMP_MINOR:
18904                         c*=11;
18905 @@ -361,7 +361,7 @@
18906  {
18907         unsigned long flags;
18908  
18909 -       switch(minor(inode->i_rdev))
18910 +       switch(iminor(inode))
18911         {
18912                 case WATCHDOG_MINOR:
18913                         if (down_trylock(&open_sem))
18914 @@ -423,7 +423,7 @@
18915  static int wdtpci_release(struct inode *inode, struct file *file)
18916  {
18917  
18918 -       if (minor(inode->i_rdev)==WATCHDOG_MINOR) {
18919 +       if (iminor(inode)==WATCHDOG_MINOR) {
18920                 unsigned long flags;
18921                 if (expect_close) {
18922                         spin_lock_irqsave(&wdtpci_lock, flags);
18923 diff -Nru a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
18924 --- a/drivers/i2c/i2c-dev.c     Wed Aug  6 02:26:55 2003
18925 +++ b/drivers/i2c/i2c-dev.c     Tue Aug 26 09:25:41 2003
18926 @@ -138,7 +138,7 @@
18927                 return -ENOMEM;
18928  
18929         pr_debug("i2c-dev.o: i2c-%d reading %d bytes.\n",
18930 -               minor(file->f_dentry->d_inode->i_rdev), count);
18931 +               iminor(file->f_dentry->d_inode), count);
18932  
18933         ret = i2c_master_recv(client,tmp,count);
18934         if (ret >= 0)
18935 @@ -166,7 +166,7 @@
18936         }
18937  
18938         pr_debug("i2c-dev.o: i2c-%d writing %d bytes.\n",
18939 -               minor(file->f_dentry->d_inode->i_rdev), count);
18940 +               iminor(file->f_dentry->d_inode), count);
18941  
18942         ret = i2c_master_send(client,tmp,count);
18943         kfree(tmp);
18944 @@ -186,7 +186,7 @@
18945         unsigned long funcs;
18946  
18947         dev_dbg(&client->dev, "i2c-%d ioctl, cmd: 0x%x, arg: %lx.\n",
18948 -               minor(inode->i_rdev),cmd, arg);
18949 +               iminor(inode),cmd, arg);
18950  
18951         switch ( cmd ) {
18952         case I2C_SLAVE:
18953 @@ -373,7 +373,7 @@
18954  
18955  static int i2cdev_open(struct inode *inode, struct file *file)
18956  {
18957 -       unsigned int minor = minor(inode->i_rdev);
18958 +       unsigned int minor = iminor(inode);
18959         struct i2c_client *client;
18960         struct i2c_adapter *adap;
18961         struct i2c_dev *i2c_dev;
18962 diff -Nru a/drivers/i2c/i2c-keywest.c b/drivers/i2c/i2c-keywest.c
18963 --- a/drivers/i2c/i2c-keywest.c Wed Jul  9 04:45:34 2003
18964 +++ b/drivers/i2c/i2c-keywest.c Tue Aug 26 06:35:38 2003
18965 @@ -81,9 +81,6 @@
18966  int probe = 0;
18967  int debug = 0;
18968  
18969 -static struct keywest_iface *ifaces = NULL;
18970 -
18971 -
18972  static void
18973  do_stop(struct keywest_iface* iface, int result)
18974  {
18975 @@ -306,6 +303,7 @@
18976         write_reg(reg_control, read_reg(reg_control) | KW_I2C_CTL_XADDR);
18977         write_reg(reg_ier, KW_I2C_IRQ_MASK);
18978  
18979 +       /* Wait interrupt operations completion */
18980         wait_for_completion(&iface->complete);  
18981  
18982         rc = iface->result;     
18983 @@ -385,6 +383,7 @@
18984                 write_reg(reg_control, read_reg(reg_control) | KW_I2C_CTL_XADDR);
18985                 write_reg(reg_ier, KW_I2C_IRQ_MASK);
18986  
18987 +               /* Wait interrupt operations completion */
18988                 wait_for_completion(&iface->complete);  
18989  
18990                 rc = iface->result;
18991 @@ -409,16 +408,16 @@
18992  
18993  /* For now, we only handle combined mode (smbus) */
18994  static struct i2c_algorithm keywest_algorithm = {
18995 -       name:           "Keywest i2c",
18996 -       id:             I2C_ALGO_SMBUS,
18997 -       smbus_xfer:     keywest_smbus_xfer,
18998 -       master_xfer:    keywest_xfer,
18999 -       functionality:  keywest_func,
19000 +       .name           = "Keywest i2c",
19001 +       .id             = I2C_ALGO_SMBUS,
19002 +       .smbus_xfer     = keywest_smbus_xfer,
19003 +       .master_xfer    = keywest_xfer,
19004 +       .functionality  = keywest_func,
19005  };
19006  
19007  
19008  static int
19009 -create_iface(struct device_node* np)
19010 +create_iface(struct device_node *np, struct device *dev)
19011  {
19012         unsigned long steps, *psteps, *prate;
19013         unsigned bsteps, tsize, i, nchan, addroffset;
19014 @@ -487,8 +486,8 @@
19015                         *prate);
19016         }
19017         
19018 -       /* Select standard mode by default */
19019 -       iface->cur_mode |= KW_I2C_MODE_STANDARD;
19020 +       /* Select standard sub mode */
19021 +       iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
19022         
19023         /* Write mode */
19024         write_reg(reg_mode, iface->cur_mode);
19025 @@ -506,11 +505,13 @@
19026                 return -ENODEV;
19027         }
19028  
19029 +       dev_set_drvdata(dev, iface);
19030 +       
19031         for (i=0; i<nchan; i++) {
19032                 struct keywest_chan* chan = &iface->channels[i];
19033                 u8 addr;
19034                 
19035 -               sprintf(chan->adapter.dev.name, "%s %d", np->parent->name, i);
19036 +               sprintf(chan->adapter.name, "%s %d", np->parent->name, i);
19037                 chan->iface = iface;
19038                 chan->chan_no = i;
19039                 chan->adapter.id = I2C_ALGO_SMBUS;
19040 @@ -519,11 +520,12 @@
19041                 chan->adapter.client_register = NULL;
19042                 chan->adapter.client_unregister = NULL;
19043                 i2c_set_adapdata(&chan->adapter, chan);
19044 +               chan->adapter.dev.parent = dev;
19045  
19046                 rc = i2c_add_adapter(&chan->adapter);
19047                 if (rc) {
19048                         printk("i2c-keywest.c: Adapter %s registration failed\n",
19049 -                               chan->adapter.dev.name);
19050 +                               chan->adapter.name);
19051                         i2c_set_adapdata(&chan->adapter, NULL);
19052                 }
19053                 if (probe) {
19054 @@ -540,20 +542,18 @@
19055         printk(KERN_INFO "Found KeyWest i2c on \"%s\", %d channel%s, stepping: %d bits\n",
19056                 np->parent->name, nchan, nchan > 1 ? "s" : "", bsteps);
19057                 
19058 -       iface->next = ifaces;
19059 -       ifaces = iface;
19060         return 0;
19061  }
19062  
19063 -static void
19064 -dispose_iface(struct keywest_iface *iface)
19065 +static int
19066 +dispose_iface(struct device *dev)
19067  {
19068 +       struct keywest_iface *iface = dev_get_drvdata(dev);
19069         int i, rc;
19070         
19071 -       ifaces = iface->next;
19072 -
19073         /* Make sure we stop all activity */
19074         down(&iface->sem);
19075 +
19076         spin_lock_irq(&iface->lock);
19077         while (iface->state != state_idle) {
19078                 spin_unlock_irq(&iface->lock);
19079 @@ -578,31 +578,76 @@
19080                         printk("i2c-keywest.c: i2c_del_adapter failed, that's bad !\n");
19081         }
19082         iounmap((void *)iface->base);
19083 +       dev_set_drvdata(dev, NULL);
19084         kfree(iface);
19085 +
19086 +       return 0;
19087 +}
19088 +
19089 +static int
19090 +create_iface_macio(struct macio_dev* dev, const struct of_match *match)
19091 +{
19092 +       return create_iface(dev->ofdev.node, &dev->ofdev.dev);
19093 +}
19094 +
19095 +static int
19096 +dispose_iface_macio(struct macio_dev* dev)
19097 +{
19098 +       return dispose_iface(&dev->ofdev.dev);
19099 +}
19100 +
19101 +static int
19102 +create_iface_of_platform(struct of_device* dev, const struct of_match *match)
19103 +{
19104 +       return create_iface(dev->node, &dev->dev);
19105 +}
19106 +
19107 +static int
19108 +dispose_iface_of_platform(struct of_device* dev)
19109 +{
19110 +       return dispose_iface(&dev->dev);
19111  }
19112  
19113 +static struct of_match i2c_keywest_match[] = 
19114 +{
19115 +       {
19116 +       .name           = OF_ANY_MATCH,
19117 +       .type           = "i2c",
19118 +       .compatible     = "keywest"
19119 +       },
19120 +       {},
19121 +};
19122 +
19123 +static struct macio_driver i2c_keywest_macio_driver = 
19124 +{
19125 +       .name           = "i2c-keywest",
19126 +       .match_table    = i2c_keywest_match,
19127 +       .probe          = create_iface_macio,
19128 +       .remove         = dispose_iface_macio
19129 +};
19130 +
19131 +static struct of_platform_driver i2c_keywest_of_platform_driver = 
19132 +{
19133 +       .name           = "i2c-keywest",
19134 +       .match_table    = i2c_keywest_match,
19135 +       .probe          = create_iface_of_platform,
19136 +       .remove         = dispose_iface_of_platform
19137 +};
19138 +
19139  static int __init
19140  i2c_keywest_init(void)
19141  {
19142 -       struct device_node *np;
19143 -       int rc = -ENODEV;
19144 -       
19145 -       np = find_compatible_devices("i2c", "keywest");
19146 -       while (np != 0) {
19147 -               if (np->n_addrs >= 1 && np->n_intrs >= 1)
19148 -                       rc = create_iface(np);
19149 -               np = np->next;
19150 -       }
19151 -       if (ifaces)
19152 -               rc = 0;
19153 -       return rc;
19154 +       macio_register_driver(&i2c_keywest_macio_driver);
19155 +       of_register_driver(&i2c_keywest_of_platform_driver);
19156 +
19157 +       return 0;
19158  }
19159  
19160  static void __exit
19161  i2c_keywest_cleanup(void)
19162  {
19163 -       while(ifaces)
19164 -               dispose_iface(ifaces);
19165 +       macio_unregister_driver(&i2c_keywest_macio_driver);
19166 +       of_unregister_driver(&i2c_keywest_of_platform_driver);
19167  }
19168  
19169  module_init(i2c_keywest_init);
19170 diff -Nru a/drivers/i2c/i2c-keywest.h b/drivers/i2c/i2c-keywest.h
19171 --- a/drivers/i2c/i2c-keywest.h Fri Feb 15 14:32:09 2002
19172 +++ b/drivers/i2c/i2c-keywest.h Sun Aug 24 06:10:14 2003
19173 @@ -67,7 +67,6 @@
19174         int                     stopretry;
19175         struct timer_list       timeout_timer;
19176         struct completion       complete;
19177 -       struct keywest_iface*   next;
19178  };
19179  
19180  enum {
19181 diff -Nru a/drivers/ide/Kconfig b/drivers/ide/Kconfig
19182 --- a/drivers/ide/Kconfig       Wed Aug 13 14:35:06 2003
19183 +++ b/drivers/ide/Kconfig       Sun Aug 24 06:08:48 2003
19184 @@ -815,6 +815,17 @@
19185           most of the recent Apple Power Macintoshes and PowerBooks.
19186           If unsure, say Y.
19187  
19188 +config BLK_DEV_IDE_PMAC_ATA100FIRST
19189 +       bool "Probe internal ATA/100 (Kauai) first"
19190 +       depends on BLK_DEV_IDE_PMAC
19191 +       help
19192 +         This option will cause the ATA/100 controller found in UniNorth2
19193 +         based machines (Windtunnel PowerMac, Aluminium PowerBooks, ...)
19194 +         to be probed before the ATA/66 and ATA/33 controllers. Without
19195 +         these, those machine used to have the hard disk on hdc and the
19196 +         CD-ROM on hda. This option changes this to more natural hda for
19197 +         hard disk and hdc for CD-ROM.
19198 +
19199  config BLK_DEV_IDEDMA_PMAC
19200         bool "PowerMac IDE DMA support"
19201         depends on BLK_DEV_IDE_PMAC
19202 diff -Nru a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
19203 --- a/drivers/ide/ide-cd.c      Wed Aug 20 09:01:03 2003
19204 +++ b/drivers/ide/ide-cd.c      Fri Aug 22 18:04:49 2003
19205 @@ -794,16 +794,16 @@
19206                            request or data protect error.*/
19207                         ide_dump_status (drive, "command error", stat);
19208                         do_end_request = 1;
19209 -               } else if ((err & ~ABRT_ERR) != 0) {
19210 -                       /* Go to the default handler
19211 -                          for other errors. */
19212 -                       DRIVER(drive)->error(drive, "cdrom_decode_status",stat);
19213 -                       return 1;
19214                 } else if (sense_key == MEDIUM_ERROR) {
19215                         /* No point in re-trying a zillion times on a bad 
19216                          * sector...  If we got here the error is not correctable */
19217                         ide_dump_status (drive, "media error (bad sector)", stat);
19218                         do_end_request = 1;
19219 +               } else if ((err & ~ABRT_ERR) != 0) {
19220 +                       /* Go to the default handler
19221 +                          for other errors. */
19222 +                       DRIVER(drive)->error(drive, "cdrom_decode_status",stat);
19223 +                       return 1;
19224                 } else if ((++rq->errors > ERROR_MAX)) {
19225                         /* We've racked up too many retries.  Abort. */
19226                         do_end_request = 1;
19227 diff -Nru a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
19228 --- a/drivers/ide/ide-io.c      Thu Aug  7 02:25:24 2003
19229 +++ b/drivers/ide/ide-io.c      Sun Aug 24 15:33:30 2003
19230 @@ -54,8 +54,6 @@
19231  #include <asm/io.h>
19232  #include <asm/bitops.h>
19233  
19234 -#include "ide_modes.h"
19235 -
19236  #if (DISK_RECOVERY_TIME > 0)
19237  
19238  #error So the User Has To Fix the Compilation And Stop Hacking Port 0x43. Does anyone ever use this anyway ??
19239 diff -Nru a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
19240 --- a/drivers/ide/ide-lib.c     Thu Aug  7 02:25:25 2003
19241 +++ b/drivers/ide/ide-lib.c     Sun Aug 24 15:33:30 2003
19242 @@ -22,8 +22,6 @@
19243  #include <asm/io.h>
19244  #include <asm/bitops.h>
19245  
19246 -#include "ide_modes.h"
19247 -
19248  /*
19249   *     IDE library routines. These are plug in code that most 
19250   *     drivers can use but occasionally may be weird enough
19251 @@ -170,7 +168,7 @@
19252                 BUG();
19253         return min(speed, speed_max[mode]);
19254  #else /* !CONFIG_BLK_DEV_IDEDMA */
19255 -       return min(speed, XFER_PIO_4);
19256 +       return min(speed, (u8)XFER_PIO_4);
19257  #endif /* CONFIG_BLK_DEV_IDEDMA */
19258  }
19259  
19260 @@ -188,6 +186,12 @@
19261  
19262  EXPORT_SYMBOL(ide_dma_enable);
19263  
19264 +/*
19265 + * Standard (generic) timings for PIO modes, from ATA2 specification.
19266 + * These timings are for access to the IDE data port register *only*.
19267 + * Some drives may specify a mode, while also specifying a different
19268 + * value for cycle_time (from drive identification data).
19269 + */
19270  const ide_pio_timings_t ide_pio_timings[6] = {
19271         { 70,   165,    600 },  /* PIO Mode 0 */
19272         { 50,   125,    383 },  /* PIO Mode 1 */
19273 @@ -198,6 +202,13 @@
19274  };
19275  
19276  EXPORT_SYMBOL_GPL(ide_pio_timings);
19277 +
19278 +/*
19279 + * Shared data/functions for determining best PIO mode for an IDE drive.
19280 + * Most of this stuff originally lived in cmd640.c, and changes to the
19281 + * ide_pio_blacklist[] table should be made with EXTREME CAUTION to avoid
19282 + * breaking the fragile cmd640.c support.
19283 + */
19284  
19285  /*
19286   * Black list. Some drives incorrectly report their maximal PIO mode,
19287 diff -Nru a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
19288 --- a/drivers/ide/ide-probe.c   Thu Aug 14 16:52:06 2003
19289 +++ b/drivers/ide/ide-probe.c   Sun Aug 24 15:46:28 2003
19290 @@ -649,10 +649,13 @@
19291         /* register with global device tree */
19292         strlcpy(hwif->gendev.bus_id,hwif->name,BUS_ID_SIZE);
19293         hwif->gendev.driver_data = hwif;
19294 -       if (hwif->pci_dev)
19295 -               hwif->gendev.parent = &hwif->pci_dev->dev;
19296 -       else
19297 -               hwif->gendev.parent = NULL; /* Would like to do = &device_legacy */
19298 +       if (hwif->gendev.parent == NULL) {
19299 +               if (hwif->pci_dev)
19300 +                       hwif->gendev.parent = &hwif->pci_dev->dev;
19301 +               else
19302 +                       /* Would like to do = &device_legacy */
19303 +                       hwif->gendev.parent = NULL;
19304 +       }
19305         device_register(&hwif->gendev);
19306  }
19307  
19308 @@ -770,8 +773,7 @@
19309          */
19310         for (unit = 0; unit < MAX_DRIVES; ++unit) {
19311                 ide_drive_t *drive = &hwif->drives[unit];
19312 -               drive->dn = ((hwif->channel ? 2 : 0) + unit);
19313 -               hwif->drives[unit].dn = ((hwif->channel ? 2 : 0) + unit);
19314 +               drive->dn = (hwif->channel ? 2 : 0) + unit;
19315                 (void) probe_for_drive(drive);
19316                 if (drive->present && !hwif->present) {
19317                         hwif->present = 1;
19318 @@ -945,15 +947,10 @@
19319         if (drive->disk)
19320                 drive->disk->queue = drive->queue;
19321  
19322 -       return 0;
19323 -}
19324 -
19325 -/*
19326 - * Setup the drive for request handling.
19327 - */
19328 -static void ide_init_drive(ide_drive_t *drive)
19329 -{
19330 +       /* needs drive->queue to be set */
19331         ide_toggle_bounce(drive, 1);
19332 +
19333 +       return 0;
19334  }
19335  
19336  /*
19337 @@ -1068,10 +1065,9 @@
19338         }
19339  
19340         /*
19341 -        * Link any new drives into the hwgroup, allocate
19342 -        * the block device queue and initialize the drive.
19343 -        * Note that ide_init_drive sends commands to the new
19344 -        * drive.
19345 +        * For any present drive:
19346 +        * - allocate the block device queue
19347 +        * - link drive into the hwgroup
19348          */
19349         for (index = 0; index < MAX_DRIVES; ++index) {
19350                 ide_drive_t *drive = &hwif->drives[index];
19351 @@ -1092,7 +1088,6 @@
19352                         hwgroup->drive->next = drive;
19353                 }
19354                 spin_unlock_irq(&ide_lock);
19355 -               ide_init_drive(drive);
19356         }
19357  
19358  #if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__)
19359 @@ -1303,31 +1298,6 @@
19360  
19361  EXPORT_SYMBOL(hwif_init);
19362  
19363 -int export_ide_init_queue (ide_drive_t *drive)
19364 -{
19365 -       if (ide_init_queue(drive))
19366 -               return 1;
19367 -
19368 -       ide_init_drive(drive);
19369 -       return 0;
19370 -}
19371 -
19372 -EXPORT_SYMBOL(export_ide_init_queue);
19373 -
19374 -u8 export_probe_for_drive (ide_drive_t *drive)
19375 -{
19376 -       return probe_for_drive(drive);
19377 -}
19378 -
19379 -EXPORT_SYMBOL(export_probe_for_drive);
19380 -
19381 -int ideprobe_init (void);
19382 -static ide_module_t ideprobe_module = {
19383 -       IDE_PROBE_MODULE,
19384 -       ideprobe_init,
19385 -       NULL
19386 -};
19387 -
19388  int ideprobe_init (void)
19389  {
19390         unsigned int index;
19391 @@ -1359,7 +1329,7 @@
19392                 }
19393         }
19394         if (!ide_probe)
19395 -               ide_probe = &ideprobe_module;
19396 +               ide_probe = &ideprobe_init;
19397         MOD_DEC_USE_COUNT;
19398         return 0;
19399  }
19400 diff -Nru a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
19401 --- a/drivers/ide/ide-tape.c    Wed Aug 20 14:21:56 2003
19402 +++ b/drivers/ide/ide-tape.c    Tue Aug 26 09:25:41 2003
19403 @@ -4922,7 +4922,7 @@
19404         struct inode *inode = file->f_dentry->d_inode;
19405         ide_drive_t *drive = file->private_data;
19406         idetape_tape_t *tape = drive->driver_data;
19407 -       unsigned int minor = minor(inode->i_rdev);
19408 +       unsigned int minor = iminor(inode);
19409         ssize_t retval, actually_written = 0;
19410         int position;
19411  
19412 @@ -5568,7 +5568,7 @@
19413   */
19414  static int idetape_chrdev_open (struct inode *inode, struct file *filp)
19415  {
19416 -       unsigned int minor = minor(inode->i_rdev), i = minor & ~0xc0;
19417 +       unsigned int minor = iminor(inode), i = minor & ~0xc0;
19418         ide_drive_t *drive;
19419         idetape_tape_t *tape;
19420         idetape_pc_t pc;
19421 @@ -5649,7 +5649,7 @@
19422         ide_drive_t *drive = filp->private_data;
19423         idetape_tape_t *tape;
19424         idetape_pc_t pc;
19425 -       unsigned int minor = minor(inode->i_rdev);
19426 +       unsigned int minor = iminor(inode);
19427  
19428         lock_kernel();
19429         tape = drive->driver_data;
19430 diff -Nru a/drivers/ide/ide.c b/drivers/ide/ide.c
19431 --- a/drivers/ide/ide.c Wed Aug 20 09:01:03 2003
19432 +++ b/drivers/ide/ide.c Sun Aug 31 16:13:57 2003
19433 @@ -161,8 +161,6 @@
19434  #include <asm/io.h>
19435  #include <asm/bitops.h>
19436  
19437 -#include "ide_modes.h"
19438 -
19439  
19440  /* default maximum number of failures */
19441  #define IDE_DEFAULT_MAX_FAILURES       1
19442 @@ -180,7 +178,9 @@
19443  DECLARE_MUTEX(ide_cfg_sem);
19444  spinlock_t ide_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
19445  
19446 +#ifdef CONFIG_BLK_DEV_IDEPCI
19447  static int ide_scan_direction; /* THIS was formerly 2.2.x pci=reverse */
19448 +#endif
19449  
19450  #ifdef CONFIG_IDEDMA_AUTO
19451  int noautodma = 0;
19452 @@ -190,11 +190,7 @@
19453  
19454  EXPORT_SYMBOL(noautodma);
19455  
19456 -/*
19457 - * ide_modules keeps track of the available IDE chipset/probe/driver modules.
19458 - */
19459 -ide_module_t *ide_chipsets;
19460 -ide_module_t *ide_probe;
19461 +int (*ide_probe)(void);
19462  
19463  /*
19464   * This is declared extern in ide.h, for access by other IDE modules:
19465 @@ -452,7 +448,7 @@
19466                 (void) request_module("ide-probe-mod");
19467  #endif /* (CONFIG_KMOD) && (CONFIG_BLK_DEV_IDE_MODULE) */
19468         } else {
19469 -               (void) ide_probe->init();
19470 +               (void)ide_probe();
19471         }
19472  }
19473  
19474 @@ -1046,21 +1042,6 @@
19475  EXPORT_SYMBOL(ide_register_hw);
19476  
19477  /*
19478 - * Compatibility function with existing drivers.  If you want
19479 - * something different, use the function above.
19480 - */
19481 -int ide_register (int arg1, int arg2, int irq)
19482 -{
19483 -       hw_regs_t hw;
19484 -       ide_init_hwif_ports(&hw, (unsigned long) arg1, (unsigned long) arg2, NULL);
19485 -       hw.irq = irq;
19486 -       return ide_register_hw(&hw, NULL);
19487 -}
19488 -
19489 -EXPORT_SYMBOL(ide_register);
19490 -
19491 -
19492 -/*
19493   *     Locks for IDE setting functionality
19494   */
19495  
19496 @@ -1658,11 +1639,15 @@
19497  
19498                 case HDIO_SCAN_HWIF:
19499                 {
19500 +                       hw_regs_t hw;
19501                         int args[3];
19502                         if (!capable(CAP_SYS_RAWIO)) return -EACCES;
19503                         if (copy_from_user(args, (void *)arg, 3 * sizeof(int)))
19504                                 return -EFAULT;
19505 -                       if (ide_register(args[0], args[1], args[2]) == -1)
19506 +                       ide_init_hwif_ports(&hw, (unsigned long) args[0],
19507 +                                           (unsigned long) args[1], NULL);
19508 +                       hw.irq = args[2];
19509 +                       if (ide_register_hw(&hw, NULL) == -1)
19510                                 return -EIO;
19511                         return 0;
19512                 }
19513 @@ -1870,7 +1855,7 @@
19514   *                             registered. In most cases, only one device
19515   *                             will be present.
19516   * "hdx=scsi"          : the return of the ide-scsi flag, this is useful for
19517 - *                             allowwing ide-floppy, ide-tape, and ide-cdrom|writers
19518 + *                             allowing ide-floppy, ide-tape, and ide-cdrom|writers
19519   *                             to use ide-scsi emulation on a device specific option.
19520   * "idebus=xx"         : inform IDE driver of VESA/PCI bus speed in MHz,
19521   *                             where "xx" is between 20 and 66 inclusive,
19522 diff -Nru a/drivers/ide/ide_modes.h b/drivers/ide/ide_modes.h
19523 --- a/drivers/ide/ide_modes.h   Mon Sep 16 05:54:57 2002
19524 +++ /dev/null   Wed Dec 31 16:00:00 1969
19525 @@ -1,41 +0,0 @@
19526 -/*
19527 - *  linux/drivers/ide/ide_modes.h
19528 - *
19529 - *  Copyright (C) 1996  Linus Torvalds, Igor Abramov, and Mark Lord
19530 - */
19531 -
19532 -#ifndef _IDE_MODES_H
19533 -#define _IDE_MODES_H
19534 -
19535 -#include <linux/config.h>
19536 -
19537 -/*
19538 - * Shared data/functions for determining best PIO mode for an IDE drive.
19539 - * Most of this stuff originally lived in cmd640.c, and changes to the
19540 - * ide_pio_blacklist[] table should be made with EXTREME CAUTION to avoid
19541 - * breaking the fragile cmd640.c support.
19542 - */
19543 -
19544 -/*
19545 - * Standard (generic) timings for PIO modes, from ATA2 specification.
19546 - * These timings are for access to the IDE data port register *only*.
19547 - * Some drives may specify a mode, while also specifying a different
19548 - * value for cycle_time (from drive identification data).
19549 - */
19550 -typedef struct ide_pio_timings_s {
19551 -       int     setup_time;     /* Address setup (ns) minimum */
19552 -       int     active_time;    /* Active pulse (ns) minimum */
19553 -       int     cycle_time;     /* Cycle time (ns) minimum = (setup + active + recovery) */
19554 -} ide_pio_timings_t;
19555 -
19556 -typedef struct ide_pio_data_s {
19557 -       u8 pio_mode;
19558 -       u8 use_iordy;
19559 -       u8 overridden;
19560 -       u8 blacklisted;
19561 -       unsigned int cycle_time;
19562 -} ide_pio_data_t;
19563 -       
19564 -u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_pio_data_t *d);
19565 -extern const ide_pio_timings_t ide_pio_timings[6];
19566 -#endif /* _IDE_MODES_H */
19567 diff -Nru a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c
19568 --- a/drivers/ide/legacy/ali14xx.c      Tue Aug 12 13:29:09 2003
19569 +++ b/drivers/ide/legacy/ali14xx.c      Sun Aug 24 15:33:30 2003
19570 @@ -54,8 +54,6 @@
19571  
19572  #include <asm/io.h>
19573  
19574 -#include "ide_modes.h"
19575 -
19576  /* port addresses for auto-detection */
19577  #define ALI_NUM_PORTS 4
19578  static int ports[ALI_NUM_PORTS] __initdata = {0x074, 0x0f4, 0x034, 0x0e4};
19579 diff -Nru a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c
19580 --- a/drivers/ide/legacy/dtc2278.c      Tue Aug 12 13:29:09 2003
19581 +++ b/drivers/ide/legacy/dtc2278.c      Sun Aug 24 15:33:30 2003
19582 @@ -21,8 +21,6 @@
19583  
19584  #include <asm/io.h>
19585  
19586 -#include "ide_modes.h"
19587 -
19588  /*
19589   * Changing this #undef to #define may solve start up problems in some systems.
19590   */
19591 diff -Nru a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c
19592 --- a/drivers/ide/legacy/ht6560b.c      Tue Aug 12 13:29:09 2003
19593 +++ b/drivers/ide/legacy/ht6560b.c      Sun Aug 24 15:33:30 2003
19594 @@ -53,8 +53,6 @@
19595  
19596  #include <asm/io.h>
19597  
19598 -#include "ide_modes.h"
19599 -
19600  /* #define DEBUG */  /* remove comments for DEBUG messages */
19601  
19602  /*
19603 diff -Nru a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c
19604 --- a/drivers/ide/legacy/macide.c       Tue Feb 18 10:06:19 2003
19605 +++ b/drivers/ide/legacy/macide.c       Sun Aug 24 05:37:06 2003
19606 @@ -126,7 +126,7 @@
19607                         /* probing the drive which freezes a 190.       */
19608  
19609                         ide_drive_t *drive = &ide_hwifs[index].drives[0];
19610 -                       drive->capacity = drive->cyl*drive->head*drive->sect;
19611 +                       drive->capacity64 = drive->cyl*drive->head*drive->sect;
19612  
19613  #ifdef CONFIG_BLK_DEV_MAC_MEDIABAY
19614                         request_irq(IRQ_BABOON_2, macide_mediabay_interrupt,
19615 diff -Nru a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c
19616 --- a/drivers/ide/legacy/qd65xx.c       Tue Aug 12 13:29:09 2003
19617 +++ b/drivers/ide/legacy/qd65xx.c       Sun Aug 24 15:33:30 2003
19618 @@ -42,7 +42,6 @@
19619  #include <asm/system.h>
19620  #include <asm/io.h>
19621  
19622 -#include "ide_modes.h"
19623  #include "qd65xx.h"
19624  
19625  /*
19626 diff -Nru a/drivers/ide/legacy/umc8672.c b/drivers/ide/legacy/umc8672.c
19627 --- a/drivers/ide/legacy/umc8672.c      Tue Aug 12 13:29:09 2003
19628 +++ b/drivers/ide/legacy/umc8672.c      Sun Aug 24 15:33:30 2003
19629 @@ -54,8 +54,6 @@
19630  
19631  #include <asm/io.h>
19632  
19633 -#include "ide_modes.h"
19634 -
19635  /*
19636   * Default speeds.  These can be changed with "auto-tune" and/or hdparm.
19637   */
19638 diff -Nru a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
19639 --- a/drivers/ide/pci/aec62xx.c Thu Jul 31 08:58:49 2003
19640 +++ b/drivers/ide/pci/aec62xx.c Sun Aug 24 15:33:30 2003
19641 @@ -16,7 +16,6 @@
19642  
19643  #include <asm/io.h>
19644  
19645 -#include "ide_modes.h"
19646  #include "aec62xx.h"
19647  
19648  #if defined(DISPLAY_AEC62XX_TIMINGS) && defined(CONFIG_PROC_FS)
19649 diff -Nru a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
19650 --- a/drivers/ide/pci/alim15x3.c        Sat Aug 16 06:34:25 2003
19651 +++ b/drivers/ide/pci/alim15x3.c        Sun Aug 24 15:33:30 2003
19652 @@ -37,7 +37,6 @@
19653  
19654  #include <asm/io.h>
19655  
19656 -#include "ide_modes.h"
19657  #include "alim15x3.h"
19658  
19659  /*
19660 diff -Nru a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c
19661 --- a/drivers/ide/pci/cmd640.c  Thu Mar 13 16:49:44 2003
19662 +++ b/drivers/ide/pci/cmd640.c  Sun Aug 24 15:33:30 2003
19663 @@ -115,8 +115,6 @@
19664  
19665  #include <asm/io.h>
19666  
19667 -#include "ide_modes.h"
19668 -
19669  /*
19670   * This flag is set in ide.c by the parameter:  ide0=cmd640_vlb
19671   */
19672 diff -Nru a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
19673 --- a/drivers/ide/pci/cmd64x.c  Thu Jul 31 08:58:49 2003
19674 +++ b/drivers/ide/pci/cmd64x.c  Mon Sep  1 08:23:55 2003
19675 @@ -25,7 +25,6 @@
19676  
19677  #include <asm/io.h>
19678  
19679 -#include "ide_modes.h"
19680  #include "cmd64x.h"
19681  
19682  #if defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_PROC_FS)
19683 @@ -629,10 +628,7 @@
19684  
19685         /* Set a good latency timer and cache line size value. */
19686         (void) pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
19687 -#ifdef __sparc_v9__
19688 -       (void) pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 0x10);
19689 -#endif
19690 -
19691 +       /* FIXME: pci_set_master() to ensure a good latency timer value */
19692  
19693         /* Setup interrupts. */
19694         (void) pci_read_config_byte(dev, MRDMODE, &mrdmode);
19695 diff -Nru a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
19696 --- a/drivers/ide/pci/cs5520.c  Thu Jul 31 08:58:49 2003
19697 +++ b/drivers/ide/pci/cs5520.c  Sun Aug 24 15:33:30 2003
19698 @@ -51,7 +51,6 @@
19699  #include <asm/io.h>
19700  #include <asm/irq.h>
19701  
19702 -#include "ide_modes.h"
19703  #include "cs5520.h"
19704  
19705  #if defined(DISPLAY_CS5520_TIMINGS) && defined(CONFIG_PROC_FS)
19706 diff -Nru a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c
19707 --- a/drivers/ide/pci/cs5530.c  Thu Jul 31 08:58:49 2003
19708 +++ b/drivers/ide/pci/cs5530.c  Sun Aug 24 15:33:30 2003
19709 @@ -31,7 +31,6 @@
19710  #include <asm/io.h>
19711  #include <asm/irq.h>
19712  
19713 -#include "ide_modes.h"
19714  #include "cs5530.h"
19715  
19716  #if defined(DISPLAY_CS5530_TIMINGS) && defined(CONFIG_PROC_FS)
19717 diff -Nru a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c
19718 --- a/drivers/ide/pci/cy82c693.c        Thu Jul 31 08:58:49 2003
19719 +++ b/drivers/ide/pci/cy82c693.c        Sun Aug 24 15:33:30 2003
19720 @@ -54,7 +54,6 @@
19721  
19722  #include <asm/io.h>
19723  
19724 -#include "ide_modes.h"
19725  #include "cy82c693.h"
19726  
19727  /*
19728 @@ -113,7 +112,7 @@
19729  
19730         /* note: we use the same values for 16bit IOR and IOW
19731           *     those are all the same, since I don't have other
19732 -        *      timings than those from ide_modes.h
19733 +        *      timings than those from ide-lib.c
19734          */
19735  
19736         p_pclk->time_16r = (u8)clk1;
19737 diff -Nru a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c
19738 --- a/drivers/ide/pci/hpt34x.c  Thu Jul 31 08:58:49 2003
19739 +++ b/drivers/ide/pci/hpt34x.c  Sun Aug 24 15:33:30 2003
19740 @@ -42,7 +42,6 @@
19741  #include <asm/io.h>
19742  #include <asm/irq.h>
19743  
19744 -#include "ide_modes.h"
19745  #include "hpt34x.h"
19746  
19747  #if defined(DISPLAY_HPT34X_TIMINGS) && defined(CONFIG_PROC_FS)
19748 diff -Nru a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
19749 --- a/drivers/ide/pci/hpt366.c  Mon Aug 11 09:04:06 2003
19750 +++ b/drivers/ide/pci/hpt366.c  Sun Aug 24 15:33:30 2003
19751 @@ -62,7 +62,6 @@
19752  #include <asm/io.h>
19753  #include <asm/irq.h>
19754  
19755 -#include "ide_modes.h"
19756  #include "hpt366.h"
19757  
19758  #if defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS)
19759 @@ -989,7 +988,40 @@
19760         hwif->intrproc                  = &hpt3xx_intrproc;
19761         hwif->maskproc                  = &hpt3xx_maskproc;
19762  
19763 -       pci_read_config_byte(hwif->pci_dev, 0x5a, &ata66);
19764 +       /*
19765 +        * The HPT37x uses the CBLID pins as outputs for MA15/MA16
19766 +        * address lines to access an external eeprom.  To read valid
19767 +        * cable detect state the pins must be enabled as inputs.
19768 +        */
19769 +       if (hpt_minimum_revision(dev, 8) && PCI_FUNC(dev->devfn) & 1) {
19770 +               /*
19771 +                * HPT374 PCI function 1
19772 +                * - set bit 15 of reg 0x52 to enable TCBLID as input
19773 +                * - set bit 15 of reg 0x56 to enable FCBLID as input
19774 +                */
19775 +               u16 mcr3, mcr6;
19776 +               pci_read_config_word(dev, 0x52, &mcr3);
19777 +               pci_read_config_word(dev, 0x56, &mcr6);
19778 +               pci_write_config_word(dev, 0x52, mcr3 | 0x8000);
19779 +               pci_write_config_word(dev, 0x56, mcr6 | 0x8000);
19780 +               /* now read cable id register */
19781 +               pci_read_config_byte(dev, 0x5a, &ata66);
19782 +               pci_write_config_word(dev, 0x52, mcr3);
19783 +               pci_write_config_word(dev, 0x56, mcr6);
19784 +       } else if (hpt_minimum_revision(dev, 3)) {
19785 +               /*
19786 +                * HPT370/372 and 374 pcifn 0
19787 +                * - clear bit 0 of 0x5b to enable P/SCBLID as inputs
19788 +                */
19789 +               u8 scr2;
19790 +               pci_read_config_byte(dev, 0x5b, &scr2);
19791 +               pci_write_config_byte(dev, 0x5b, scr2 & ~1);
19792 +               /* now read cable id register */
19793 +               pci_read_config_byte(dev, 0x5a, &ata66);
19794 +               pci_write_config_byte(dev, 0x5b, scr2);
19795 +       } else {
19796 +               pci_read_config_byte(dev, 0x5a, &ata66);
19797 +       }
19798  
19799  #ifdef DEBUG
19800         printk("HPT366: reg5ah=0x%02x ATA-%s Cable Port%d\n",
19801 diff -Nru a/drivers/ide/pci/it8172.c b/drivers/ide/pci/it8172.c
19802 --- a/drivers/ide/pci/it8172.c  Thu Jul 31 08:58:49 2003
19803 +++ b/drivers/ide/pci/it8172.c  Sun Aug 24 15:33:30 2003
19804 @@ -42,7 +42,6 @@
19805  #include <asm/io.h>
19806  #include <asm/it8172/it8172_int.h>
19807  
19808 -#include "ide_modes.h"
19809  #include "it8172.h"
19810  
19811  /*
19812 diff -Nru a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c
19813 --- a/drivers/ide/pci/ns87415.c Thu Jul 31 08:58:49 2003
19814 +++ b/drivers/ide/pci/ns87415.c Mon Sep  1 08:23:55 2003
19815 @@ -147,9 +147,7 @@
19816  
19817         /* Set a good latency timer and cache line size value. */
19818         (void) pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
19819 -#ifdef __sparc_v9__
19820 -       (void) pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 0x10);
19821 -#endif
19822 +       /* FIXME: use pci_set_master() to ensure good latency timer value */
19823  
19824         /*
19825          * We cannot probe for IRQ: both ports share common IRQ on INTA.
19826 diff -Nru a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c
19827 --- a/drivers/ide/pci/opti621.c Thu Jul 31 08:58:49 2003
19828 +++ b/drivers/ide/pci/opti621.c Sun Aug 24 15:33:30 2003
19829 @@ -104,7 +104,6 @@
19830  
19831  #include <asm/io.h>
19832  
19833 -#include "ide_modes.h"
19834  #include "opti621.h"
19835  
19836  #define OPTI621_MAX_PIO 3
19837 diff -Nru a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
19838 --- a/drivers/ide/pci/pdc202xx_new.c    Thu Jul 31 08:58:49 2003
19839 +++ b/drivers/ide/pci/pdc202xx_new.c    Sun Aug 24 15:33:30 2003
19840 @@ -32,7 +32,6 @@
19841  #include <asm/io.h>
19842  #include <asm/irq.h>
19843  
19844 -#include "ide_modes.h"
19845  #include "pdc202xx_new.h"
19846  
19847  #define PDC202_DEBUG_CABLE     0
19848 diff -Nru a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
19849 --- a/drivers/ide/pci/pdc202xx_old.c    Wed Aug 13 17:45:49 2003
19850 +++ b/drivers/ide/pci/pdc202xx_old.c    Sun Aug 24 15:33:30 2003
19851 @@ -46,7 +46,6 @@
19852  #include <asm/io.h>
19853  #include <asm/irq.h>
19854  
19855 -#include "ide_modes.h"
19856  #include "pdc202xx_old.h"
19857  
19858  #define PDC202_DEBUG_CABLE     0
19859 diff -Nru a/drivers/ide/pci/pdcadma.c b/drivers/ide/pci/pdcadma.c
19860 --- a/drivers/ide/pci/pdcadma.c Thu Jul 31 08:58:49 2003
19861 +++ b/drivers/ide/pci/pdcadma.c Sun Aug 24 15:33:30 2003
19862 @@ -24,7 +24,6 @@
19863  #include <asm/io.h>
19864  #include <asm/irq.h>
19865  
19866 -#include "ide_modes.h"
19867  #include "pdcadma.h"
19868  
19869  #if defined(DISPLAY_PDCADMA_TIMINGS) && defined(CONFIG_PROC_FS)
19870 diff -Nru a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c
19871 --- a/drivers/ide/pci/piix.c    Thu Jul 31 08:58:49 2003
19872 +++ b/drivers/ide/pci/piix.c    Sun Aug 24 15:33:30 2003
19873 @@ -103,7 +103,6 @@
19874  
19875  #include <asm/io.h>
19876  
19877 -#include "ide_modes.h"
19878  #include "piix.h"
19879  
19880  static int no_piix_dma;
19881 diff -Nru a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c
19882 --- a/drivers/ide/pci/sc1200.c  Thu Jul 31 08:58:49 2003
19883 +++ b/drivers/ide/pci/sc1200.c  Sun Aug 24 15:33:30 2003
19884 @@ -29,7 +29,6 @@
19885  #include <asm/io.h>
19886  #include <asm/irq.h>
19887  
19888 -#include "ide_modes.h"
19889  #include "sc1200.h"
19890  
19891  #define SC1200_REV_A   0x00
19892 diff -Nru a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
19893 --- a/drivers/ide/pci/serverworks.c     Thu Jul 31 08:58:49 2003
19894 +++ b/drivers/ide/pci/serverworks.c     Sun Aug 24 15:33:30 2003
19895 @@ -39,7 +39,6 @@
19896  
19897  #include <asm/io.h>
19898  
19899 -#include "ide_modes.h"
19900  #include "serverworks.h"
19901  
19902  static u8 svwks_revision = 0;
19903 diff -Nru a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
19904 --- a/drivers/ide/pci/siimage.c Wed Aug 13 17:45:20 2003
19905 +++ b/drivers/ide/pci/siimage.c Sun Aug 24 15:33:30 2003
19906 @@ -15,7 +15,6 @@
19907  
19908  #include <asm/io.h>
19909  
19910 -#include "ide_modes.h"
19911  #include "siimage.h"
19912  
19913  #if defined(DISPLAY_SIIMAGE_TIMINGS) && defined(CONFIG_PROC_FS)
19914 diff -Nru a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
19915 --- a/drivers/ide/pci/sis5513.c Thu Jul 31 08:58:49 2003
19916 +++ b/drivers/ide/pci/sis5513.c Sun Aug 24 15:33:30 2003
19917 @@ -63,7 +63,6 @@
19918  #include <asm/irq.h>
19919  
19920  #include "ide-timing.h"
19921 -#include "ide_modes.h"
19922  #include "sis5513.h"
19923  
19924  /* registers layout and init values are chipset family dependant */
19925 diff -Nru a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c
19926 --- a/drivers/ide/pci/sl82c105.c        Thu Jul 31 08:58:49 2003
19927 +++ b/drivers/ide/pci/sl82c105.c        Sun Aug 24 15:33:30 2003
19928 @@ -29,7 +29,6 @@
19929  #include <asm/io.h>
19930  #include <asm/dma.h>
19931  
19932 -#include "ide_modes.h"
19933  #include "sl82c105.h"
19934  
19935  #undef DEBUG
19936 diff -Nru a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c
19937 --- a/drivers/ide/pci/slc90e66.c        Thu Jul 31 08:58:49 2003
19938 +++ b/drivers/ide/pci/slc90e66.c        Sun Aug 24 15:33:30 2003
19939 @@ -21,7 +21,6 @@
19940  
19941  #include <asm/io.h>
19942  
19943 -#include "ide_modes.h"
19944  #include "slc90e66.h"
19945  
19946  #if defined(DISPLAY_SLC90E66_TIMINGS) && defined(CONFIG_PROC_FS)
19947 diff -Nru a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c
19948 --- a/drivers/ide/pci/triflex.c Sat Feb 22 15:52:14 2003
19949 +++ b/drivers/ide/pci/triflex.c Sun Aug 24 15:33:30 2003
19950 @@ -41,7 +41,6 @@
19951  #include <linux/ide.h>
19952  #include <linux/init.h>
19953  
19954 -#include "ide_modes.h"
19955  #include "triflex.h"
19956  
19957  static struct pci_dev *triflex_dev;
19958 diff -Nru a/drivers/ide/ppc/mpc8xx.c b/drivers/ide/ppc/mpc8xx.c
19959 --- a/drivers/ide/ppc/mpc8xx.c  Fri May  2 10:53:08 2003
19960 +++ b/drivers/ide/ppc/mpc8xx.c  Sun Aug 24 15:33:30 2003
19961 @@ -42,7 +42,6 @@
19962  #include <asm/machdep.h>
19963  #include <asm/irq.h>
19964  
19965 -#include "ide_modes.h"
19966  static int identify  (volatile u8 *p);
19967  static void print_fixed (volatile u8 *p);
19968  static void print_funcid (int func);
19969 diff -Nru a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
19970 --- a/drivers/ide/ppc/pmac.c    Sat Aug 16 11:46:50 2003
19971 +++ b/drivers/ide/ppc/pmac.c    Sun Aug 31 14:09:16 2003
19972 @@ -5,7 +5,7 @@
19973   * These IDE interfaces are memory-mapped and have a DBDMA channel
19974   * for doing DMA.
19975   *
19976 - *  Copyright (C) 1998-2001 Paul Mackerras & Ben. Herrenschmidt
19977 + *  Copyright (C) 1998-2003 Paul Mackerras & Ben. Herrenschmidt
19978   *
19979   *  This program is free software; you can redistribute it and/or
19980   *  modify it under the terms of the GNU General Public License
19981 @@ -16,6 +16,11 @@
19982   *
19983   *  Copyright (c) 1995-1998  Mark Lord
19984   *
19985 + * TODO: - Use pre-calculated (kauai) timing tables all the time and
19986 + * get rid of the "rounded" tables used previously, so we have the
19987 + * same table format for all controllers and can then just have one
19988 + * big table
19989 + * 
19990   */
19991  #include <linux/config.h>
19992  #include <linux/types.h>
19993 @@ -27,6 +32,8 @@
19994  #include <linux/notifier.h>
19995  #include <linux/reboot.h>
19996  #include <linux/pci.h>
19997 +#include <linux/adb.h>
19998 +#include <linux/pmu.h>
19999  
20000  #include <asm/prom.h>
20001  #include <asm/io.h>
20002 @@ -38,26 +45,27 @@
20003  #include <asm/pmac_feature.h>
20004  #include <asm/sections.h>
20005  #include <asm/irq.h>
20006 -#ifdef CONFIG_PMAC_PBOOK
20007 -#include <linux/adb.h>
20008 -#include <linux/pmu.h>
20009 -#endif
20010 -#include "ide_modes.h"
20011 +
20012 +#include "ide-timing.h"
20013  
20014  extern void ide_do_request(ide_hwgroup_t *hwgroup, int masked_irq);
20015  
20016  #define IDE_PMAC_DEBUG
20017  
20018 -#define DMA_WAIT_TIMEOUT       500
20019 +#define DMA_WAIT_TIMEOUT       100
20020  
20021  typedef struct pmac_ide_hwif {
20022         unsigned long                   regbase;
20023         int                             irq;
20024         int                             kind;
20025         int                             aapl_bus_id;
20026 +       int                             cable_80 : 1;
20027 +       int                             mediabay : 1;
20028 +       int                             broken_dma : 1;
20029 +       int                             broken_dma_warn : 1;
20030         struct device_node*             node;
20031 -       u32                             timings[2];
20032 -       int                             index;
20033 +       struct macio_dev                *mdev;
20034 +       u32                             timings[4];
20035  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
20036         /* Those fields are duplicating what is in hwif. We currently
20037          * can't use the hwif ones because of some assumptions that are
20038 @@ -82,7 +90,15 @@
20039         controller_heathrow,    /* Heathrow/Paddington */
20040         controller_kl_ata3,     /* KeyLargo ATA-3 */
20041         controller_kl_ata4,     /* KeyLargo ATA-4 */
20042 -       controller_kl_ata4_80   /* KeyLargo ATA-4 with 80 conductor cable */
20043 +       controller_un_ata6      /* UniNorth2 ATA-6 */
20044 +};
20045 +
20046 +static const char* model_name[] = {
20047 +       "OHare ATA",            /* OHare based */
20048 +       "Heathrow ATA",         /* Heathrow/Paddington */
20049 +       "KeyLargo ATA-3",       /* KeyLargo ATA-3 */
20050 +       "KeyLargo ATA-4",       /* KeyLargo ATA-4 */
20051 +       "UniNorth ATA-6"        /* UniNorth2 ATA-6 */
20052  };
20053  
20054  /*
20055 @@ -91,6 +107,11 @@
20056  #define IDE_TIMING_CONFIG      0x200
20057  #define IDE_INTERRUPT          0x300
20058  
20059 +/* Kauai (U2) ATA has different register setup */
20060 +#define IDE_KAUAI_PIO_CONFIG   0x200
20061 +#define IDE_KAUAI_ULTRA_CONFIG 0x210
20062 +#define IDE_KAUAI_POLL_CONFIG  0x220
20063 +
20064  /*
20065   * Timing configuration register definitions
20066   */
20067 @@ -101,6 +122,28 @@
20068  #define IDE_SYSCLK_NS          30      /* 33Mhz cell */
20069  #define IDE_SYSCLK_66_NS       15      /* 66Mhz cell */
20070  
20071 +/* 100Mhz cell, found in Uninorth 2. I don't have much infos about
20072 + * this one yet, it appears as a pci device (106b/0033) on uninorth
20073 + * internal PCI bus and it's clock is controlled like gem or fw. It
20074 + * appears to be an evolution of keylargo ATA4 with a timing register
20075 + * extended to 2 32bits registers and a similar DBDMA channel. Other
20076 + * registers seem to exist but I can't tell much about them.
20077 + * 
20078 + * So far, I'm using pre-calculated tables for this extracted from
20079 + * the values used by the MacOS X driver.
20080 + * 
20081 + * The "PIO" register controls PIO and MDMA timings, the "ULTRA"
20082 + * register controls the UDMA timings. At least, it seems bit 0
20083 + * of this one enables UDMA vs. MDMA, and bits 4..7 are the
20084 + * cycle time in units of 10ns. Bits 8..15 are used by I don't
20085 + * know their meaning yet
20086 + */
20087 +#define TR_100_PIOREG_PIO_MASK         0xff000fff
20088 +#define TR_100_PIOREG_MDMA_MASK                0x00fff000
20089 +#define TR_100_UDMAREG_UDMA_MASK       0x0000ffff
20090 +#define TR_100_UDMAREG_UDMA_EN         0x00000001
20091 +
20092 +
20093  /* 66Mhz cell, found in KeyLargo. Can do ultra mode 0 to 2 on
20094   * 40 connector cable and to 4 on 80 connector one.
20095   * Clock unit is 15ns (66Mhz)
20096 @@ -115,8 +158,7 @@
20097   *    well, despite a comment that would lead to think it has a
20098   *    min value of 45ns.
20099   * Apple also add 60ns to the write data setup (or cycle time ?) on
20100 - * reads. I can't explain that, I tried it and it broke everything
20101 - * here.
20102 + * reads.
20103   */
20104  #define TR_66_UDMA_MASK                        0xfff00000
20105  #define TR_66_UDMA_EN                  0x00100000 /* Enable Ultra mode for DMA */
20106 @@ -220,12 +262,12 @@
20107      {   0,   0,   0 }
20108  };
20109  
20110 -/* Ultra DMA timings (rounded) */
20111 +/* KeyLargo ATA-4 Ultra DMA timings (rounded) */
20112  struct {
20113         int     addrSetup; /* ??? */
20114         int     rdy2pause;
20115         int     wrDataSetup;
20116 -} udma_timings[] __pmacdata =
20117 +} kl66_udma_timings[] __pmacdata =
20118  {
20119      {   0, 180,  120 },        /* Mode 0 */
20120      {   0, 150,  90 }, /*      1 */
20121 @@ -234,6 +276,63 @@
20122      {   0, 90,   30 }  /*      4 */
20123  };
20124  
20125 +/* UniNorth 2 ATA/100 timings */
20126 +struct kauai_timing {
20127 +       int     cycle_time;
20128 +       u32     timing_reg;
20129 +};
20130 +
20131 +static struct kauai_timing     kauai_pio_timings[] __pmacdata =
20132 +{
20133 +       { 930   , 0x08000fff },
20134 +       { 600   , 0x08000a92 },
20135 +       { 383   , 0x0800060f },
20136 +       { 360   , 0x08000492 },
20137 +       { 330   , 0x0800048f },
20138 +       { 300   , 0x080003cf },
20139 +       { 270   , 0x080003cc },
20140 +       { 240   , 0x0800038b },
20141 +       { 239   , 0x0800030c },
20142 +       { 180   , 0x05000249 },
20143 +       { 120   , 0x04000148 }
20144 +};
20145 +
20146 +static struct kauai_timing     kauai_mdma_timings[] __pmacdata =
20147 +{
20148 +       { 1260  , 0x00fff000 },
20149 +       { 480   , 0x00618000 },
20150 +       { 360   , 0x00492000 },
20151 +       { 270   , 0x0038e000 },
20152 +       { 240   , 0x0030c000 },
20153 +       { 210   , 0x002cb000 },
20154 +       { 180   , 0x00249000 },
20155 +       { 150   , 0x00209000 },
20156 +       { 120   , 0x00148000 },
20157 +       { 0     , 0 },
20158 +};
20159 +
20160 +static struct kauai_timing     kauai_udma_timings[] __pmacdata =
20161 +{
20162 +       { 120   , 0x000070c0 },
20163 +       { 90    , 0x00005d80 },
20164 +       { 60    , 0x00004a60 },
20165 +       { 45    , 0x00003a50 },
20166 +       { 30    , 0x00002a30 },
20167 +       { 20    , 0x00002921 },
20168 +       { 0     , 0 },
20169 +};
20170 +
20171 +static inline u32
20172 +kauai_lookup_timing(struct kauai_timing* table, int cycle_time)
20173 +{
20174 +       int i;
20175 +       
20176 +       for (i=0; table[i].cycle_time; i++)
20177 +               if (cycle_time > table[i+1].cycle_time)
20178 +                       return table[i].timing_reg;
20179 +       return 0;
20180 +}
20181 +
20182  /* allow up to 256 DBDMA commands per xfer */
20183  #define MAX_DCMDS              256
20184  
20185 @@ -242,24 +341,106 @@
20186   * NOTE: There is at least one case I know of a disk that needs about 10sec
20187   *       before anwering on the bus. I beleive we could add a kernel command
20188   *       line arg to override this delay for such cases.
20189 + *       
20190 + * NOTE2: This has to be fixed with a BSY wait loop. I'm working on adding
20191 + *        that to the generic probe code.
20192   */
20193  #define IDE_WAKEUP_DELAY_MS    2000
20194  
20195 -static void pmac_ide_setup_dma(struct device_node *np, int ix);
20196 -static int pmac_ide_build_dmatable(ide_drive_t *drive, int wr);
20197 +static void pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif);
20198 +static int pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq);
20199  static int pmac_ide_tune_chipset(ide_drive_t *drive, u8 speed);
20200  static void pmac_ide_tuneproc(ide_drive_t *drive, u8 pio);
20201  static void pmac_ide_selectproc(ide_drive_t *drive);
20202 +static void pmac_ide_kauai_selectproc(ide_drive_t *drive);
20203  static int pmac_ide_dma_begin (ide_drive_t *drive);
20204  
20205  #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
20206  
20207 -#ifdef CONFIG_PMAC_PBOOK
20208 -static int idepmac_notify_sleep(struct pmu_sleep_notifier *self, int when);
20209 -struct pmu_sleep_notifier idepmac_sleep_notifier = {
20210 -       idepmac_notify_sleep, SLEEP_LEVEL_BLOCK,
20211 -};
20212 -#endif /* CONFIG_PMAC_PBOOK */
20213 +#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
20214 +
20215 +/* Set to 50ms */
20216 +#define PMU_HD_BLINK_TIME      (HZ/50)
20217 +
20218 +static struct adb_request pmu_blink_on, pmu_blink_off;
20219 +static spinlock_t pmu_blink_lock;
20220 +static unsigned long pmu_blink_stoptime;
20221 +static int pmu_blink_ledstate;
20222 +static struct timer_list pmu_blink_timer;
20223 +static int pmu_ide_blink_enabled;
20224 +
20225 +
20226 +static void
20227 +pmu_hd_blink_timeout(unsigned long data)
20228 +{
20229 +       unsigned long flags;
20230 +       
20231 +       spin_lock_irqsave(&pmu_blink_lock, flags);
20232 +
20233 +       /* We may have been triggered again in a racy way, check
20234 +        * that we really want to switch it off
20235 +        */
20236 +       if (time_after(pmu_blink_stoptime, jiffies))
20237 +               goto done;
20238 +
20239 +       /* Previous req. not complete, try 100ms more */
20240 +       if (pmu_blink_off.complete == 0)
20241 +               mod_timer(&pmu_blink_timer, jiffies + PMU_HD_BLINK_TIME);
20242 +       else if (pmu_blink_ledstate) {
20243 +               pmu_request(&pmu_blink_off, NULL, 4, 0xee, 4, 0, 0);
20244 +               pmu_blink_ledstate = 0;
20245 +       }
20246 +done:
20247 +       spin_unlock_irqrestore(&pmu_blink_lock, flags);
20248 +}
20249 +
20250 +static void
20251 +pmu_hd_kick_blink(void *data, int rw)
20252 +{
20253 +       unsigned long flags;
20254 +       
20255 +       pmu_blink_stoptime = jiffies + PMU_HD_BLINK_TIME;
20256 +       wmb();
20257 +       mod_timer(&pmu_blink_timer, pmu_blink_stoptime);
20258 +       if (pmu_blink_ledstate == 1)
20259 +               return;
20260 +       spin_lock_irqsave(&pmu_blink_lock, flags);
20261 +       if (pmu_blink_on.complete && !pmu_blink_ledstate) {
20262 +               pmu_request(&pmu_blink_on, NULL, 4, 0xee, 4, 0, 1);
20263 +               pmu_blink_ledstate = 1;
20264 +       }
20265 +       spin_unlock_irqrestore(&pmu_blink_lock, flags);
20266 +}
20267 +
20268 +static int
20269 +pmu_hd_blink_init(void)
20270 +{
20271 +       struct device_node *dt;
20272 +       const char *model;
20273 +
20274 +       if (pmu_get_model() != PMU_KEYLARGO_BASED)
20275 +               return 0;
20276 +       
20277 +       dt = find_devices("device-tree");
20278 +       if (dt == NULL)
20279 +               return 0;
20280 +       model = (const char *)get_property(dt, "model", NULL);
20281 +       if (model == NULL)
20282 +               return 0;
20283 +       if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 &&
20284 +           strncmp(model, "iBook", strlen("iBook")) != 0)
20285 +               return 0;
20286 +       
20287 +       pmu_blink_on.complete = 1;
20288 +       pmu_blink_off.complete = 1;
20289 +       spin_lock_init(&pmu_blink_lock);
20290 +       init_timer(&pmu_blink_timer);
20291 +       pmu_blink_timer.function = pmu_hd_blink_timeout;
20292 +
20293 +       return 1;
20294 +}
20295 +
20296 +#endif /* CONFIG_BLK_DEV_IDE_PMAC_BLINK */
20297  
20298  /*
20299   * N.B. this can't be an initfunc, because the media-bay task can
20300 @@ -315,6 +496,41 @@
20301         (void)readl((unsigned *)(IDE_DATA_REG+IDE_TIMING_CONFIG));
20302  }
20303  
20304 +static void __pmac
20305 +pmac_ide_kauai_selectproc(ide_drive_t *drive)
20306 +{
20307 +       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
20308 +
20309 +       if (pmif == NULL)
20310 +               return;
20311 +
20312 +       if (drive->select.b.unit & 0x01) {
20313 +               writel(pmif->timings[1],
20314 +                      (unsigned *)(IDE_DATA_REG + IDE_KAUAI_PIO_CONFIG));
20315 +               writel(pmif->timings[3],
20316 +                      (unsigned *)(IDE_DATA_REG + IDE_KAUAI_ULTRA_CONFIG));
20317 +       } else {
20318 +               writel(pmif->timings[0],
20319 +                      (unsigned *)(IDE_DATA_REG + IDE_KAUAI_PIO_CONFIG));
20320 +               writel(pmif->timings[2],
20321 +                      (unsigned *)(IDE_DATA_REG + IDE_KAUAI_ULTRA_CONFIG));
20322 +       }
20323 +       (void)readl((unsigned *)(IDE_DATA_REG + IDE_KAUAI_PIO_CONFIG));
20324 +}
20325 +
20326 +static void __pmac
20327 +pmac_ide_do_update_timings(ide_drive_t *drive)
20328 +{
20329 +       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
20330 +
20331 +       if (pmif == NULL)
20332 +               return;
20333 +
20334 +       if (pmif->kind == controller_un_ata6)
20335 +               pmac_ide_kauai_selectproc(drive);
20336 +       else
20337 +               pmac_ide_selectproc(drive);
20338 +}
20339  
20340  static int __pmac
20341  pmac_ide_do_setfeature(ide_drive_t *drive, u8 command)
20342 @@ -322,7 +538,7 @@
20343         ide_hwif_t *hwif = HWIF(drive);
20344         int result = 1;
20345         
20346 -       disable_irq(hwif->irq); /* disable_irq_nosync ?? */
20347 +       disable_irq_nosync(hwif->irq);
20348         udelay(1);
20349         SELECT_DRIVE(drive);
20350         SELECT_MASK(drive, 0);
20351 @@ -332,22 +548,22 @@
20352         /* Timeout bumped for some powerbooks */
20353         if (wait_for_ready(drive, 2000)) {
20354                 /* Timeout bumped for some powerbooks */
20355 -               printk(KERN_ERR "pmac_ide_do_setfeature disk not ready "
20356 -                       "before SET_FEATURE!\n");
20357 +               printk(KERN_ERR "%s: pmac_ide_do_setfeature disk not ready "
20358 +                       "before SET_FEATURE!\n", drive->name);
20359                 goto out;
20360         }
20361         udelay(10);
20362         hwif->OUTB(drive->ctl | 2, IDE_CONTROL_REG);
20363         hwif->OUTB(command, IDE_NSECTOR_REG);
20364         hwif->OUTB(SETFEATURES_XFER, IDE_FEATURE_REG);
20365 -       hwif->OUTB(WIN_SETFEATURES, IDE_COMMAND_REG);
20366 +       hwif->OUTBSYNC(drive, WIN_SETFEATURES, IDE_COMMAND_REG);
20367         udelay(1);
20368         /* Timeout bumped for some powerbooks */
20369         result = wait_for_ready(drive, 2000);
20370         hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
20371         if (result)
20372 -               printk(KERN_ERR "pmac_ide_do_setfeature disk not ready "
20373 -                       "after SET_FEATURE !\n");
20374 +               printk(KERN_ERR "%s: pmac_ide_do_setfeature disk not ready "
20375 +                       "after SET_FEATURE !\n", drive->name);
20376  out:
20377         SELECT_MASK(drive, 0);
20378         if (result == 0) {
20379 @@ -403,21 +619,27 @@
20380         if (pmif == NULL)
20381                 return;
20382                 
20383 +       /* which drive is it ? */
20384 +       timings = &pmif->timings[drive->select.b.unit & 0x01];
20385 +
20386         pio = ide_get_best_pio_mode(drive, pio, 4, &d);
20387 -       accessTicks = SYSCLK_TICKS(ide_pio_timings[pio].active_time);
20388 -       if (drive->select.b.unit & 0x01)
20389 -               timings = &pmif->timings[1];
20390 -       else
20391 -               timings = &pmif->timings[0];
20392  
20393 -       recTime = d.cycle_time - ide_pio_timings[pio].active_time
20394 -                       - ide_pio_timings[pio].setup_time;
20395 -       recTime = max(recTime, 150U);
20396 -       accessTime = ide_pio_timings[pio].active_time;
20397 -       accessTime = max(accessTime, 150U);
20398 -       if (pmif->kind == controller_kl_ata4 ||
20399 -               pmif->kind == controller_kl_ata4_80) {
20400 +       switch (pmif->kind) {
20401 +       case controller_un_ata6: {
20402 +               /* 100Mhz cell */
20403 +               u32 tr = kauai_lookup_timing(kauai_pio_timings, d.cycle_time);
20404 +               if (tr == 0)
20405 +                       return;
20406 +               *timings = ((*timings) & ~TR_100_PIOREG_PIO_MASK) | tr;
20407 +               break;
20408 +               }
20409 +       case controller_kl_ata4:
20410                 /* 66Mhz cell */
20411 +               recTime = d.cycle_time - ide_pio_timings[pio].active_time
20412 +                               - ide_pio_timings[pio].setup_time;
20413 +               recTime = max(recTime, 150U);
20414 +               accessTime = ide_pio_timings[pio].active_time;
20415 +               accessTime = max(accessTime, 150U);
20416                 accessTicks = SYSCLK_TICKS_66(accessTime);
20417                 accessTicks = min(accessTicks, 0x1fU);
20418                 recTicks = SYSCLK_TICKS_66(recTime);
20419 @@ -425,9 +647,15 @@
20420                 *timings = ((*timings) & ~TR_66_PIO_MASK) |
20421                                 (accessTicks << TR_66_PIO_ACCESS_SHIFT) |
20422                                 (recTicks << TR_66_PIO_RECOVERY_SHIFT);
20423 -       } else {
20424 +               break;
20425 +       default: {
20426                 /* 33Mhz cell */
20427                 int ebit = 0;
20428 +               recTime = d.cycle_time - ide_pio_timings[pio].active_time
20429 +                               - ide_pio_timings[pio].setup_time;
20430 +               recTime = max(recTime, 150U);
20431 +               accessTime = ide_pio_timings[pio].active_time;
20432 +               accessTime = max(accessTime, 150U);
20433                 accessTicks = SYSCLK_TICKS(accessTime);
20434                 accessTicks = min(accessTicks, 0x1fU);
20435                 accessTicks = max(accessTicks, 4U);
20436 @@ -443,26 +671,31 @@
20437                                 (recTicks << TR_33_PIO_RECOVERY_SHIFT);
20438                 if (ebit)
20439                         *timings |= TR_33_PIO_E;
20440 +               break;
20441 +               }
20442         }
20443  
20444  #ifdef IDE_PMAC_DEBUG
20445 -       printk(KERN_ERR "ide_pmac: Set PIO timing for mode %d, reg: 0x%08x\n",
20446 -               pio,  *timings);
20447 +       printk(KERN_ERR "%s: Set PIO timing for mode %d, reg: 0x%08x\n",
20448 +               drive->name, pio,  *timings);
20449  #endif 
20450  
20451         if (drive->select.all == HWIF(drive)->INB(IDE_SELECT_REG))
20452 -               pmac_ide_selectproc(drive);
20453 +               pmac_ide_do_update_timings(drive);
20454  }
20455  
20456  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
20457  static int __pmac
20458 -set_timings_udma(u32 *timings, u8 speed)
20459 +set_timings_udma_ata4(u32 *timings, u8 speed)
20460  {
20461         unsigned rdyToPauseTicks, wrDataSetupTicks, addrTicks;
20462  
20463 -       rdyToPauseTicks = SYSCLK_TICKS_66(udma_timings[speed & 0xf].rdy2pause);
20464 -       wrDataSetupTicks = SYSCLK_TICKS_66(udma_timings[speed & 0xf].wrDataSetup);
20465 -       addrTicks = SYSCLK_TICKS_66(udma_timings[speed & 0xf].addrSetup);
20466 +       if (speed > XFER_UDMA_4)
20467 +               return 1;
20468 +
20469 +       rdyToPauseTicks = SYSCLK_TICKS_66(kl66_udma_timings[speed & 0xf].rdy2pause);
20470 +       wrDataSetupTicks = SYSCLK_TICKS_66(kl66_udma_timings[speed & 0xf].wrDataSetup);
20471 +       addrTicks = SYSCLK_TICKS_66(kl66_udma_timings[speed & 0xf].addrSetup);
20472  
20473         *timings = ((*timings) & ~(TR_66_UDMA_MASK | TR_66_MDMA_MASK)) |
20474                         (wrDataSetupTicks << TR_66_UDMA_WRDATASETUP_SHIFT) | 
20475 @@ -478,11 +711,29 @@
20476  }
20477  
20478  static int __pmac
20479 -set_timings_mdma(int intf_type, u32 *timings, u8 speed, int drive_cycle_time)
20480 +set_timings_udma_ata6(u32 *pio_timings, u32 *ultra_timings, u8 speed)
20481 +{
20482 +       struct ide_timing *t = ide_timing_find_mode(speed);
20483 +       u32 tr;
20484 +
20485 +       if (speed > XFER_UDMA_5 || t == NULL)
20486 +               return 1;
20487 +       tr = kauai_lookup_timing(kauai_udma_timings, (int)t->udma);
20488 +       if (tr == 0)
20489 +               return 1;
20490 +       *ultra_timings = ((*ultra_timings) & ~TR_100_UDMAREG_UDMA_MASK) | tr;
20491 +       *ultra_timings = (*ultra_timings) | TR_100_UDMAREG_UDMA_EN;
20492 +
20493 +       return 0;
20494 +}
20495 +
20496 +static int __pmac
20497 +set_timings_mdma(ide_drive_t *drive, int intf_type, u32 *timings, u32 *timings2,
20498 +                       u8 speed, int drive_cycle_time)
20499  {
20500         int cycleTime, accessTime, recTime;
20501         unsigned accessTicks, recTicks;
20502 -       struct mdma_timings_t* tm;
20503 +       struct mdma_timings_t* tm = NULL;
20504         int i;
20505  
20506         /* Get default cycle time for mode */
20507 @@ -491,7 +742,7 @@
20508                 case 1: cycleTime = 150; break;
20509                 case 2: cycleTime = 120; break;
20510                 default:
20511 -                       return -1;
20512 +                       return 1;
20513         }
20514         /* Adjust for drive */
20515         if (drive_cycle_time && drive_cycle_time > cycleTime)
20516 @@ -501,8 +752,9 @@
20517                 cycleTime = 150;
20518         /* Get the proper timing array for this controller */
20519         switch(intf_type) {
20520 +               case controller_un_ata6:
20521 +                       break;
20522                 case controller_kl_ata4:
20523 -               case controller_kl_ata4_80:
20524                         tm = mdma_timings_66;
20525                         break;
20526                 case controller_kl_ata3:
20527 @@ -512,24 +764,36 @@
20528                         tm = mdma_timings_33;
20529                         break;
20530         }
20531 -       /* Lookup matching access & recovery times */
20532 -       i = -1;
20533 -       for (;;) {
20534 -               if (tm[i+1].cycleTime < cycleTime)
20535 -                       break;
20536 -               i++;
20537 -       }
20538 -       if (i < 0)
20539 -               return -1;
20540 -       cycleTime = tm[i].cycleTime;
20541 -       accessTime = tm[i].accessTime;
20542 -       recTime = tm[i].recoveryTime;
20543 +       if (tm != NULL) {
20544 +               /* Lookup matching access & recovery times */
20545 +               i = -1;
20546 +               for (;;) {
20547 +                       if (tm[i+1].cycleTime < cycleTime)
20548 +                               break;
20549 +                       i++;
20550 +               }
20551 +               if (i < 0)
20552 +                       return 1;
20553 +               cycleTime = tm[i].cycleTime;
20554 +               accessTime = tm[i].accessTime;
20555 +               recTime = tm[i].recoveryTime;
20556  
20557  #ifdef IDE_PMAC_DEBUG
20558 -       printk(KERN_ERR "ide_pmac: MDMA, cycleTime: %d, accessTime: %d, recTime: %d\n",
20559 -               cycleTime, accessTime, recTime);
20560 -#endif 
20561 -       if (intf_type == controller_kl_ata4 || intf_type == controller_kl_ata4_80) {
20562 +               printk(KERN_ERR "%s: MDMA, cycleTime: %d, accessTime: %d, recTime: %d\n",
20563 +                       drive->name, cycleTime, accessTime, recTime);
20564 +#endif
20565 +       }
20566 +       switch(intf_type) {
20567 +       case controller_un_ata6: {
20568 +               /* 100Mhz cell */
20569 +               u32 tr = kauai_lookup_timing(kauai_mdma_timings, cycleTime);
20570 +               if (tr == 0)
20571 +                       return 1;
20572 +               *timings = ((*timings) & ~TR_100_PIOREG_MDMA_MASK) | tr;
20573 +               *timings2 = (*timings2) & ~TR_100_UDMAREG_UDMA_EN;
20574 +               }
20575 +               break;
20576 +       case controller_kl_ata4:
20577                 /* 66Mhz cell */
20578                 accessTicks = SYSCLK_TICKS_66(accessTime);
20579                 accessTicks = min(accessTicks, 0x1fU);
20580 @@ -541,7 +805,8 @@
20581                 *timings = ((*timings) & ~(TR_66_MDMA_MASK | TR_66_UDMA_MASK)) |
20582                         (accessTicks << TR_66_MDMA_ACCESS_SHIFT) |
20583                         (recTicks << TR_66_MDMA_RECOVERY_SHIFT);
20584 -       } else if (intf_type == controller_kl_ata3) {
20585 +               break;
20586 +       case controller_kl_ata3:
20587                 /* 33Mhz cell on KeyLargo */
20588                 accessTicks = SYSCLK_TICKS(accessTime);
20589                 accessTicks = max(accessTicks, 1U);
20590 @@ -553,7 +818,8 @@
20591                 *timings = ((*timings) & ~TR_33_MDMA_MASK) |
20592                                 (accessTicks << TR_33_MDMA_ACCESS_SHIFT) |
20593                                 (recTicks << TR_33_MDMA_RECOVERY_SHIFT);
20594 -       } else {
20595 +               break;
20596 +       default: {
20597                 /* 33Mhz cell on others */
20598                 int halfTick = 0;
20599                 int origAccessTime = accessTime;
20600 @@ -578,10 +844,11 @@
20601                                 (recTicks << TR_33_MDMA_RECOVERY_SHIFT);
20602                 if (halfTick)
20603                         *timings |= TR_33_MDMA_HALFTICK;
20604 +               }
20605         }
20606  #ifdef IDE_PMAC_DEBUG
20607 -       printk(KERN_ERR "ide_pmac: Set MDMA timing for mode %d, reg: 0x%08x\n",
20608 -               speed & 0xf,  *timings);
20609 +       printk(KERN_ERR "%s: Set MDMA timing for mode %d, reg: 0x%08x\n",
20610 +               drive->name, speed & 0xf,  *timings);
20611  #endif 
20612         return 0;
20613  }
20614 @@ -591,36 +858,42 @@
20615   * our, normal mdma function is supposed to be more precise
20616   */
20617  static int __pmac
20618 -pmac_ide_tune_chipset (ide_drive_t *drive, u8 speed)
20619 +pmac_ide_tune_chipset (ide_drive_t *drive, byte speed)
20620  {
20621         int unit = (drive->select.b.unit & 0x01);
20622         int ret = 0;
20623         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
20624 -       u32 *timings;
20625 -       
20626 +       u32 *timings, *timings2;
20627 +
20628         if (pmif == NULL)
20629                 return 1;
20630 -
20631 +               
20632         timings = &pmif->timings[unit];
20633 +       timings2 = &pmif->timings[unit+2];
20634         
20635         switch(speed) {
20636  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
20637 +               case XFER_UDMA_5:
20638 +                       if (pmif->kind != controller_un_ata6)
20639 +                               return 1;
20640                 case XFER_UDMA_4:
20641                 case XFER_UDMA_3:
20642 -                       if (pmif->kind != controller_kl_ata4_80)
20643 +                       if (HWIF(drive)->udma_four == 0)
20644                                 return 1;               
20645                 case XFER_UDMA_2:
20646                 case XFER_UDMA_1:
20647                 case XFER_UDMA_0:
20648 -                       if (pmif->kind != controller_kl_ata4 &&
20649 -                               pmif->kind != controller_kl_ata4_80)
20650 -                               return 1;               
20651 -                       ret = set_timings_udma(timings, speed);
20652 +                       if (pmif->kind == controller_kl_ata4)
20653 +                               ret = set_timings_udma_ata4(timings, speed);
20654 +                       else if (pmif->kind == controller_un_ata6)
20655 +                               ret = set_timings_udma_ata6(timings, timings2, speed);
20656 +                       else
20657 +                               ret = 1;                
20658                         break;
20659                 case XFER_MW_DMA_2:
20660                 case XFER_MW_DMA_1:
20661                 case XFER_MW_DMA_0:
20662 -                       ret = set_timings_mdma(pmif->kind, timings, speed, 0);
20663 +                       ret = set_timings_mdma(drive, pmif->kind, timings, timings2, speed, 0);
20664                         break;
20665                 case XFER_SW_DMA_2:
20666                 case XFER_SW_DMA_1:
20667 @@ -644,7 +917,7 @@
20668         if (ret)
20669                 return ret;
20670                 
20671 -       pmac_ide_selectproc(drive);     
20672 +       pmac_ide_do_update_timings(drive);      
20673         drive->current_speed = speed;
20674  
20675         return 0;
20676 @@ -653,11 +926,14 @@
20677  static void __pmac
20678  sanitize_timings(pmac_ide_hwif_t *pmif)
20679  {
20680 -       unsigned value;
20681 +       unsigned int value, value2 = 0;
20682         
20683         switch(pmif->kind) {
20684 +               case controller_un_ata6:
20685 +                       value = 0x08618a92;
20686 +                       value2 = 0x00002921;
20687 +                       break;
20688                 case controller_kl_ata4:
20689 -               case controller_kl_ata4_80:
20690                         value = 0x0008438c;
20691                         break;
20692                 case controller_kl_ata3:
20693 @@ -670,6 +946,7 @@
20694                         break;
20695         }
20696         pmif->timings[0] = pmif->timings[1] = value;
20697 +       pmif->timings[2] = pmif->timings[3] = value2;
20698  }
20699  
20700  unsigned long __pmac
20701 @@ -724,214 +1001,474 @@
20702         return 0;
20703  }
20704  
20705 -void __init
20706 -pmac_ide_probe(void)
20707 +/* Suspend call back, should be called after the child devices
20708 + * have actually been suspended
20709 + */
20710 +static int
20711 +pmac_ide_do_suspend(ide_hwif_t *hwif)
20712  {
20713 -       struct device_node *np;
20714 -       int i;
20715 -       struct device_node *atas;
20716 -       struct device_node *p, **pp, *removables, **rp;
20717 -       unsigned long base;
20718 -       int irq, big_delay;
20719 -       ide_hwif_t *hwif;
20720 +       pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
20721 +       
20722 +       /* We clear the timings */
20723 +       pmif->timings[0] = 0;
20724 +       pmif->timings[1] = 0;
20725 +       
20726 +#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
20727 +       /* Note: This code will be called for every hwif, thus we'll
20728 +        * try several time to stop the LED blinker timer,  but that
20729 +        * should be harmless
20730 +        */
20731 +       if (pmu_ide_blink_enabled) {
20732 +               unsigned long flags;
20733  
20734 -       if (_machine != _MACH_Pmac)
20735 -               return;
20736 -       pp = &atas;
20737 -       rp = &removables;
20738 -       p = find_devices("ATA");
20739 -       if (p == NULL)
20740 -               p = find_devices("IDE");
20741 -       if (p == NULL)
20742 -               p = find_type_devices("ide");
20743 -       if (p == NULL)
20744 -               p = find_type_devices("ata");
20745 -       /* Move removable devices such as the media-bay CDROM
20746 -          on the PB3400 to the end of the list. */
20747 -       for (; p != NULL; p = p->next) {
20748 -               if (p->parent && p->parent->type
20749 -                   && strcasecmp(p->parent->type, "media-bay") == 0) {
20750 -                       *rp = p;
20751 -                       rp = &p->next;
20752 -               } else {
20753 -                       *pp = p;
20754 -                       pp = &p->next;
20755 -               }
20756 +               /* Make sure we don't hit the PMU blink */
20757 +               spin_lock_irqsave(&pmu_blink_lock, flags);
20758 +               if (pmu_blink_ledstate)
20759 +                       del_timer(&pmu_blink_timer);
20760 +               pmu_blink_ledstate = 0;
20761 +               spin_unlock_irqrestore(&pmu_blink_lock, flags);
20762         }
20763 -       *rp = NULL;
20764 -       *pp = removables;
20765 -       big_delay = 0;
20766 -
20767 -       for (i = 0, np = atas; i < MAX_HWIFS && np != NULL; np = np->next) {
20768 -               struct device_node *tp;
20769 -               struct pmac_ide_hwif* pmif;
20770 -               int *bidp;
20771 -               int in_bay = 0;
20772 -               u8 pbus, pid;
20773 -               struct pci_dev *pdev = NULL;
20774 -
20775 -               /*
20776 -                * If this node is not under a mac-io or dbdma node,
20777 -                * leave it to the generic PCI driver.
20778 -                */
20779 -               for (tp = np->parent; tp != 0; tp = tp->parent)
20780 -                       if (tp->type && (strcmp(tp->type, "mac-io") == 0
20781 -                                        || strcmp(tp->type, "dbdma") == 0))
20782 -                               break;
20783 -               if (tp == 0)
20784 -                       continue;
20785 +#endif /* CONFIG_BLK_DEV_IDE_PMAC_BLINK */
20786  
20787 -               if (np->n_addrs == 0) {
20788 -                       printk(KERN_WARNING "ide: no address for device %s\n",
20789 -                              np->full_name);
20790 -                       continue;
20791 -               }
20792 +       /* The media bay will handle itself just fine */
20793 +       if (pmif->mediabay)
20794 +               return 0;
20795 +       
20796 +       /* Disable the bus */
20797 +       ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id, 0);
20798  
20799 -               /* We need to find the pci_dev of the mac-io holding the
20800 -                * IDE interface
20801 -                */
20802 -               if (pci_device_from_OF_node(tp, &pbus, &pid) == 0)
20803 -                       pdev = pci_find_slot(pbus, pid);
20804 -               if (pdev == NULL)
20805 -                       printk(KERN_WARNING "ide: no PCI host for device %s, DMA disabled\n",
20806 -                              np->full_name);
20807 +       return 0;
20808 +}
20809  
20810 -               /*
20811 -                * If this slot is taken (e.g. by ide-pci.c) try the next one.
20812 -                */
20813 -               while (i < MAX_HWIFS
20814 -                      && ide_hwifs[i].io_ports[IDE_DATA_OFFSET] != 0)
20815 -                       ++i;
20816 -               if (i >= MAX_HWIFS)
20817 -                       break;
20818 -               pmif = &pmac_ide[i];
20819 +/* Resume call back, should be called before the child devices
20820 + * are resumed
20821 + */
20822 +static int
20823 +pmac_ide_do_resume(ide_hwif_t *hwif)
20824 +{
20825 +       pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
20826 +       
20827 +       /* Hard reset & re-enable controller (do we really need to reset ? -BenH) */
20828 +       if (!pmif->mediabay) {
20829 +               ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 1);
20830 +               ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id, 1);
20831 +               mdelay(10);
20832 +               ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 0);
20833 +               mdelay(100);
20834 +       }
20835  
20836 -               /*
20837 -                * Some older OFs have bogus sizes, causing request_OF_resource
20838 -                * to fail. We fix them up here
20839 -                */
20840 -               if (np->addrs[0].size > 0x1000)
20841 -                       np->addrs[0].size = 0x1000;
20842 -               if (np->n_addrs > 1 && np->addrs[1].size > 0x100)
20843 -                       np->addrs[1].size = 0x100;
20844 +       /* Sanitize drive timings */
20845 +       sanitize_timings(pmif);
20846  
20847 -               if (request_OF_resource(np, 0, "  (mac-io IDE IO)") == NULL) {
20848 -                       printk(KERN_ERR "ide-pmac(%s): can't request IO resource !\n", np->name);
20849 -                       continue;
20850 -               }
20851 +       return 0;
20852 +}
20853  
20854 -               base = (unsigned long) ioremap(np->addrs[0].address, 0x400);
20855 +static int
20856 +pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
20857 +{
20858 +       struct device_node *np = pmif->node;
20859 +       int *bidp, i;
20860  
20861 -               /* XXX This is bogus. Should be fixed in the registry by checking
20862 -                  the kind of host interrupt controller, a bit like gatwick
20863 -                  fixes in irq.c
20864 -                */
20865 -               if (np->n_intrs == 0) {
20866 -                       printk(KERN_WARNING "ide: no intrs for device %s, using 13\n",
20867 -                              np->full_name);
20868 -                       irq = 13;
20869 -               } else {
20870 -                       irq = np->intrs[0].line;
20871 -               }
20872 -               pmif->regbase = base;
20873 -               pmif->irq = irq;
20874 -               pmif->node = np;
20875 -               pmif->index = i;
20876 -               if (device_is_compatible(np, "keylargo-ata")) {
20877 -                       if (strcmp(np->name, "ata-4") == 0)
20878 -                               pmif->kind = controller_kl_ata4;
20879 -                       else
20880 -                               pmif->kind = controller_kl_ata3;
20881 -               } else if (device_is_compatible(np, "heathrow-ata"))
20882 -                       pmif->kind = controller_heathrow;
20883 +       pmif->cable_80 = 0;
20884 +       pmif->broken_dma = pmif->broken_dma_warn = 0;
20885 +       if (device_is_compatible(np, "kauai-ata"))
20886 +               pmif->kind = controller_un_ata6;
20887 +       else if (device_is_compatible(np, "keylargo-ata")) {
20888 +               if (strcmp(np->name, "ata-4") == 0)
20889 +                       pmif->kind = controller_kl_ata4;
20890                 else
20891 -                       pmif->kind = controller_ohare;
20892 +                       pmif->kind = controller_kl_ata3;
20893 +       } else if (device_is_compatible(np, "heathrow-ata"))
20894 +               pmif->kind = controller_heathrow;
20895 +       else {
20896 +               pmif->kind = controller_ohare;
20897 +               pmif->broken_dma = 1;
20898 +       }
20899  
20900 -               bidp = (int *)get_property(np, "AAPL,bus-id", NULL);
20901 -               pmif->aapl_bus_id =  bidp ? *bidp : 0;
20902 +       bidp = (int *)get_property(np, "AAPL,bus-id", NULL);
20903 +       pmif->aapl_bus_id =  bidp ? *bidp : 0;
20904  
20905 -               if (pmif->kind == controller_kl_ata4) {
20906 -                       char* cable = get_property(np, "cable-type", NULL);
20907 -                       if (cable && !strncmp(cable, "80-", 3))
20908 -                               pmif->kind = controller_kl_ata4_80;
20909 -               }
20910 +       /* Get cable type from device-tree */
20911 +       if (pmif->kind == controller_kl_ata4 || pmif->kind == controller_un_ata6) {
20912 +               char* cable = get_property(np, "cable-type", NULL);
20913 +               if (cable && !strncmp(cable, "80-", 3))
20914 +                       pmif->cable_80 = 1;
20915 +       }
20916  
20917 -               /* Make sure we have sane timings */
20918 -               sanitize_timings(pmif);
20919 +       pmif->mediabay = 0;
20920 +       
20921 +       /* Make sure we have sane timings */
20922 +       sanitize_timings(pmif);
20923  
20924 -               if (np->parent && np->parent->name
20925 -                   && strcasecmp(np->parent->name, "media-bay") == 0) {
20926 +       /* XXX FIXME: Media bay stuff need re-organizing */
20927 +       if (np->parent && np->parent->name
20928 +           && strcasecmp(np->parent->name, "media-bay") == 0) {
20929  #ifdef CONFIG_PMAC_PBOOK
20930 -                       media_bay_set_ide_infos(np->parent,base,irq,i);
20931 +               media_bay_set_ide_infos(np->parent, pmif->regbase, pmif->irq, hwif->index);
20932  #endif /* CONFIG_PMAC_PBOOK */
20933 -                       in_bay = 1;
20934 -                       if (!bidp)
20935 -                               pmif->aapl_bus_id = 1;
20936 -               } else if (pmif->kind == controller_ohare) {
20937 -                       /* The code below is having trouble on some ohare machines
20938 -                        * (timing related ?). Until I can put my hand on one of these
20939 -                        * units, I keep the old way
20940 -                        */
20941 -                       ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, 0, 1);
20942 -               } else {
20943 -                       /* This is necessary to enable IDE when net-booting */
20944 -                       printk(KERN_INFO "pmac_ide: enabling IDE bus ID %d\n",
20945 -                               pmif->aapl_bus_id);
20946 -                       ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 1);
20947 -                       ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmif->aapl_bus_id, 1);
20948 -                       mdelay(10);
20949 -                       ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 0);
20950 -                       big_delay = 1;
20951 -               }
20952 +               pmif->mediabay = 1;
20953 +               if (!bidp)
20954 +                       pmif->aapl_bus_id = 1;
20955 +       } else if (pmif->kind == controller_ohare) {
20956 +               /* The code below is having trouble on some ohare machines
20957 +                * (timing related ?). Until I can put my hand on one of these
20958 +                * units, I keep the old way
20959 +                */
20960 +               ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, 0, 1);
20961 +       } else {
20962 +               /* This is necessary to enable IDE when net-booting */
20963 +               ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 1);
20964 +               ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmif->aapl_bus_id, 1);
20965 +               mdelay(10);
20966 +               ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 0);
20967 +               mdelay(100);
20968 +       }
20969  
20970 -               hwif = &ide_hwifs[i];
20971 -               /* Setup MMIO ops */
20972 -               default_hwif_mmiops(hwif);
20973 -               /* Tell common code _not_ to mess with resources */
20974 -               hwif->mmio = 2;
20975 -               hwif->hwif_data = pmif;
20976 -               pmac_ide_init_hwif_ports(&hwif->hw, base, 0, &hwif->irq);
20977 -               memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports));
20978 -               hwif->chipset = ide_pmac;
20979 -               hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET] || in_bay;
20980 -               hwif->udma_four = (pmif->kind == controller_kl_ata4_80);
20981 -               hwif->pci_dev = pdev;
20982 -               hwif->drives[0].unmask = 1;
20983 -               hwif->drives[1].unmask = 1;
20984 -               hwif->tuneproc = pmac_ide_tuneproc;
20985 +       /* Setup MMIO ops */
20986 +       default_hwif_mmiops(hwif);
20987 +
20988 +       /* Tell common code _not_ to mess with resources */
20989 +       hwif->mmio = 2;
20990 +       hwif->hwif_data = pmif;
20991 +       pmac_ide_init_hwif_ports(&hwif->hw, pmif->regbase, 0, &hwif->irq);
20992 +       memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports));
20993 +       hwif->chipset = ide_pmac;
20994 +       hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET] || pmif->mediabay;
20995 +       hwif->hold = pmif->mediabay;
20996 +       hwif->udma_four = pmif->cable_80;
20997 +       hwif->drives[0].unmask = 1;
20998 +       hwif->drives[1].unmask = 1;
20999 +       hwif->tuneproc = pmac_ide_tuneproc;
21000 +       if (pmif->kind == controller_un_ata6)
21001 +               hwif->selectproc = pmac_ide_kauai_selectproc;
21002 +       else
21003                 hwif->selectproc = pmac_ide_selectproc;
21004 -               hwif->speedproc = pmac_ide_tune_chipset;
21005 +       hwif->speedproc = pmac_ide_tune_chipset;
21006 +
21007 +#ifdef CONFIG_BLK_DEV_IDE_PMAC_BLINK
21008 +       pmu_ide_blink_enabled = pmu_hd_blink_init();
21009 +
21010 +       if (pmu_ide_blink_enabled)
21011 +               hwif->led_act = pmu_hd_kick_blink;
21012 +#endif
21013 +
21014 +       printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s\n",
21015 +                       hwif->index, model_name[pmif->kind], pmif->aapl_bus_id,
21016 +                       pmif->mediabay ? " (mediabay)" : "");
21017 +                       
21018  #ifdef CONFIG_PMAC_PBOOK
21019 -               if (in_bay && check_media_bay_by_base(base, MB_CD) == 0)
21020 -                       hwif->noprobe = 0;
21021 +       if (pmif->mediabay && check_media_bay_by_base(pmif->regbase, MB_CD) == 0)
21022 +               hwif->noprobe = 0;
21023  #endif /* CONFIG_PMAC_PBOOK */
21024  
21025  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
21026 -               if (np->n_addrs >= 2) {
21027 -                       /* has a DBDMA controller channel */
21028 -                       pmac_ide_setup_dma(np, i);
21029 -               }
21030 -               hwif->atapi_dma = 1;
21031 -               hwif->ultra_mask = 0x1f;
21032 -               hwif->mwdma_mask = 0x07;
21033 -               hwif->swdma_mask = 0x07;
21034 -
21035 +       /* has a DBDMA controller channel */
21036 +       if (pmif->dma_regs)
21037 +               pmac_ide_setup_dma(pmif, hwif);
21038  #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
21039  
21040 +       /* We probe the hwif now */
21041 +       probe_hwif_init(hwif);
21042 +
21043 +       /* The code IDE code will have set hwif->present if we have devices attached,
21044 +        * if we don't, the discard the interface except if we are on a media bay slot
21045 +        */
21046 +       if (!hwif->present && !pmif->mediabay) {
21047 +               printk(KERN_INFO "ide%d: Bus empty, interface released.\n",
21048 +                       hwif->index);
21049 +               default_hwif_iops(hwif);
21050 +               for (i = IDE_DATA_OFFSET; i <= IDE_CONTROL_OFFSET; ++i)
21051 +                       hwif->io_ports[i] = 0;
21052 +               hwif->chipset = ide_unknown;
21053 +               hwif->noprobe = 1;
21054 +               return -ENODEV;
21055 +       }
21056 +
21057 +       return 0;
21058 +}
21059 +
21060 +static int __devinit
21061 +pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_match *match)
21062 +{
21063 +       unsigned long base, regbase;
21064 +       int irq;
21065 +       ide_hwif_t *hwif;
21066 +       pmac_ide_hwif_t *pmif;
21067 +       int i, rc;
21068 +
21069 +       i = 0;
21070 +       while (i < MAX_HWIFS && (ide_hwifs[i].io_ports[IDE_DATA_OFFSET] != 0
21071 +           || pmac_ide[i].node != NULL))
21072                 ++i;
21073 +       if (i >= MAX_HWIFS) {
21074 +               printk(KERN_ERR "ide-pmac: MacIO interface attach with no slot\n");
21075 +               printk(KERN_ERR "          %s\n", mdev->ofdev.node->full_name);
21076 +               return -ENODEV;
21077         }
21078 -       pmac_ide_count = i;
21079 -       if (big_delay)
21080 -               mdelay(IDE_WAKEUP_DELAY_MS);
21081  
21082 -#ifdef CONFIG_PMAC_PBOOK
21083 -       pmu_register_sleep_notifier(&idepmac_sleep_notifier);
21084 -#endif /* CONFIG_PMAC_PBOOK */
21085 +       pmif = &pmac_ide[i];
21086 +       hwif = &ide_hwifs[i];
21087 +
21088 +       if (mdev->ofdev.node->n_addrs == 0) {
21089 +               printk(KERN_WARNING "ide%d: no address for %s\n",
21090 +                      i, mdev->ofdev.node->full_name);
21091 +               return -ENXIO;
21092 +       }
21093 +
21094 +       /*
21095 +        * Some older OFs have bogus sizes, causing request_OF_resource
21096 +        * to fail. We fix them up here
21097 +        */
21098 +       if (mdev->ofdev.node->addrs[0].size > 0x1000)
21099 +               mdev->ofdev.node->addrs[0].size = 0x1000;
21100 +       if (mdev->ofdev.node->n_addrs > 1 && mdev->ofdev.node->addrs[1].size > 0x100)
21101 +               mdev->ofdev.node->addrs[1].size = 0x100;
21102 +
21103 +       /* Request memory resource for IO ports */
21104 +       if (request_OF_resource(mdev->ofdev.node, 0, "  (mac-io ata ports)") == NULL) {
21105 +               printk(KERN_ERR "ide%d: can't request mmio resource !\n", i);
21106 +               return -EBUSY;
21107 +       }
21108 +                       
21109 +       /* XXX This is bogus. Should be fixed in the registry by checking
21110 +        * the kind of host interrupt controller, a bit like gatwick
21111 +        * fixes in irq.c. That works well enough for the single case
21112 +        * where that happens though...
21113 +        */
21114 +       if (mdev->ofdev.node->n_intrs == 0) {
21115 +               printk(KERN_WARNING "ide%d: no intrs for device %s, using 13\n",
21116 +                       i, mdev->ofdev.node->full_name);
21117 +               irq = 13;
21118 +       } else
21119 +               irq = mdev->ofdev.node->intrs[0].line;
21120 +
21121 +       base =  (unsigned long) ioremap(mdev->ofdev.node->addrs[0].address, 0x400);
21122 +       regbase = base;
21123 +
21124 +       hwif->pci_dev = mdev->bus->pdev;
21125 +       hwif->gendev.parent = &mdev->ofdev.dev;
21126 +
21127 +       pmif->mdev = mdev;
21128 +       pmif->node = mdev->ofdev.node;
21129 +       pmif->regbase = regbase;
21130 +       pmif->irq = irq;
21131 +#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
21132 +       if (mdev->ofdev.node->n_addrs >= 2)
21133 +               pmif->dma_regs = (volatile struct dbdma_regs*)
21134 +                       ioremap(mdev->ofdev.node->addrs[1].address, 0x1000);
21135 +       else
21136 +               pmif->dma_regs = NULL;
21137 +#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
21138 +       dev_set_drvdata(&mdev->ofdev.dev, hwif);
21139 +
21140 +       rc = pmac_ide_setup_device(pmif, hwif);
21141 +       if (rc != 0) {
21142 +               /* The inteface is released to the common IDE layer */
21143 +               dev_set_drvdata(&mdev->ofdev.dev, NULL);
21144 +               iounmap((void *)base);
21145 +               if (pmif->dma_regs)
21146 +                       iounmap((void *)pmif->dma_regs);
21147 +               memset(pmif, 0, sizeof(*pmif));
21148 +               release_OF_resource(mdev->ofdev.node, 0);
21149 +       }
21150 +
21151 +       return rc;
21152  }
21153  
21154 +static int
21155 +pmac_ide_macio_suspend(struct macio_dev *mdev, u32 state)
21156 +{
21157 +       ide_hwif_t      *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
21158 +       int             rc = 0;
21159 +
21160 +       if (state != mdev->ofdev.dev.power_state && state >= 2) {
21161 +               rc = pmac_ide_do_suspend(hwif);
21162 +               if (rc == 0)
21163 +                       mdev->ofdev.dev.power_state = state;
21164 +       }
21165 +
21166 +       return rc;
21167 +}
21168 +
21169 +static int
21170 +pmac_ide_macio_resume(struct macio_dev *mdev)
21171 +{
21172 +       ide_hwif_t      *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
21173 +       int             rc = 0;
21174 +       
21175 +       if (mdev->ofdev.dev.power_state != 0) {
21176 +               rc = pmac_ide_do_resume(hwif);
21177 +               if (rc == 0)
21178 +                       mdev->ofdev.dev.power_state = 0;
21179 +       }
21180 +
21181 +       return rc;
21182 +}
21183 +
21184 +static int __devinit
21185 +pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
21186 +{
21187 +       ide_hwif_t *hwif;
21188 +       struct device_node *np;
21189 +       pmac_ide_hwif_t *pmif;
21190 +       unsigned long base;
21191 +       unsigned long rbase, rlen;
21192 +       int i, rc;
21193 +
21194 +       np = pci_device_to_OF_node(pdev);
21195 +       if (np == NULL) {
21196 +               printk(KERN_ERR "ide-pmac: cannot find MacIO node for Kauai ATA interface\n");
21197 +               return -ENODEV;
21198 +       }
21199 +       i = 0;
21200 +       while (i < MAX_HWIFS && (ide_hwifs[i].io_ports[IDE_DATA_OFFSET] != 0
21201 +           || pmac_ide[i].node != NULL))
21202 +               ++i;
21203 +       if (i >= MAX_HWIFS) {
21204 +               printk(KERN_ERR "ide-pmac: PCI interface attach with no slot\n");
21205 +               printk(KERN_ERR "          %s\n", np->full_name);
21206 +               return -ENODEV;
21207 +       }
21208 +
21209 +       pmif = &pmac_ide[i];
21210 +       hwif = &ide_hwifs[i];
21211 +
21212 +       if (pci_enable_device(pdev)) {
21213 +               printk(KERN_WARNING "ide%i: Can't enable PCI device for %s\n",
21214 +                       i, np->full_name);
21215 +               return -ENXIO;
21216 +       }
21217 +       pci_set_master(pdev);
21218 +                       
21219 +       if (pci_request_regions(pdev, "Kauai ATA")) {
21220 +               printk(KERN_ERR "ide%d: Cannot obtain PCI resources for %s\n",
21221 +                       i, np->full_name);
21222 +               return -ENXIO;
21223 +       }
21224 +
21225 +       hwif->pci_dev = pdev;
21226 +       hwif->gendev.parent = &pdev->dev;
21227 +       pmif->mdev = NULL;
21228 +       pmif->node = np;
21229 +
21230 +       rbase = pci_resource_start(pdev, 0);
21231 +       rlen = pci_resource_len(pdev, 0);
21232 +
21233 +       base = (unsigned long) ioremap(rbase, rlen);
21234 +       pmif->regbase = base + 0x2000;
21235  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
21236 +       pmif->dma_regs = (volatile struct dbdma_regs*)(base + 0x1000);
21237 +#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */        
21238 +       pmif->irq = pdev->irq;
21239 +
21240 +       pci_set_drvdata(pdev, hwif);
21241 +
21242 +       rc = pmac_ide_setup_device(pmif, hwif);
21243 +       if (rc != 0) {
21244 +               /* The inteface is released to the common IDE layer */
21245 +               pci_set_drvdata(pdev, NULL);
21246 +               iounmap((void *)base);
21247 +               memset(pmif, 0, sizeof(*pmif));
21248 +               pci_release_regions(pdev);
21249 +       }
21250 +
21251 +       return rc;
21252 +}
21253 +
21254 +static int
21255 +pmac_ide_pci_suspend(struct pci_dev *pdev, u32 state)
21256 +{
21257 +       ide_hwif_t      *hwif = (ide_hwif_t *)pci_get_drvdata(pdev);
21258 +       int             rc = 0;
21259 +       
21260 +       if (state != pdev->dev.power_state && state >= 2) {
21261 +               rc = pmac_ide_do_suspend(hwif);
21262 +               if (rc == 0)
21263 +                       pdev->dev.power_state = state;
21264 +       }
21265 +
21266 +       return rc;
21267 +}
21268  
21269  static int
21270 +pmac_ide_pci_resume(struct pci_dev *pdev)
21271 +{
21272 +       ide_hwif_t      *hwif = (ide_hwif_t *)pci_get_drvdata(pdev);
21273 +       int             rc = 0;
21274 +       
21275 +       if (pdev->dev.power_state != 0) {
21276 +               rc = pmac_ide_do_resume(hwif);
21277 +               if (rc == 0)
21278 +                       pdev->dev.power_state = 0;
21279 +       }
21280 +
21281 +       return rc;
21282 +}
21283 +
21284 +static struct of_match pmac_ide_macio_match[] = 
21285 +{
21286 +       {
21287 +       .name           = "IDE",
21288 +       .type           = OF_ANY_MATCH,
21289 +       .compatible     = OF_ANY_MATCH
21290 +       },
21291 +       {
21292 +       .name           = "ATA",
21293 +       .type           = OF_ANY_MATCH,
21294 +       .compatible     = OF_ANY_MATCH
21295 +       },
21296 +       {
21297 +       .name           = OF_ANY_MATCH,
21298 +       .type           = "ide",
21299 +       .compatible     = OF_ANY_MATCH
21300 +       },
21301 +       {
21302 +       .name           = OF_ANY_MATCH,
21303 +       .type           = "ata",
21304 +       .compatible     = OF_ANY_MATCH
21305 +       },
21306 +       {},
21307 +};
21308 +
21309 +static struct macio_driver pmac_ide_macio_driver = 
21310 +{
21311 +       .name           = "ide-pmac",
21312 +       .match_table    = pmac_ide_macio_match,
21313 +       .probe          = pmac_ide_macio_attach,
21314 +       .suspend        = pmac_ide_macio_suspend,
21315 +       .resume         = pmac_ide_macio_resume,
21316 +};
21317 +
21318 +static struct pci_device_id pmac_ide_pci_match[] __devinitdata = {
21319 +       { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_KAUAI_ATA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
21320 +};
21321 +
21322 +static struct pci_driver pmac_ide_pci_driver = {
21323 +       .name           = "ide-pmac",
21324 +       .id_table       = pmac_ide_pci_match,
21325 +       .probe          = pmac_ide_pci_attach,
21326 +       .suspend        = pmac_ide_pci_suspend,
21327 +       .resume         = pmac_ide_pci_resume,
21328 +};
21329 +
21330 +void __init
21331 +pmac_ide_probe(void)
21332 +{
21333 +       if (_machine != _MACH_Pmac)
21334 +               return;
21335 +
21336 +#ifdef CONFIG_BLK_DEV_IDE_PMAC_ATA100FIRST
21337 +       pci_register_driver(&pmac_ide_pci_driver);
21338 +       macio_register_driver(&pmac_ide_macio_driver);
21339 +#else
21340 +       macio_register_driver(&pmac_ide_macio_driver);
21341 +       pci_register_driver(&pmac_ide_pci_driver);
21342 +#endif 
21343 +}
21344 +
21345 +#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
21346 +
21347 +static int __pmac
21348  pmac_ide_build_sglist(ide_drive_t *drive, struct request *rq)
21349  {
21350         ide_hwif_t *hwif = HWIF(drive);
21351 @@ -942,7 +1479,7 @@
21352         if (hwif->sg_dma_active)
21353                 BUG();
21354                 
21355 -       nents = blk_rq_map_sg(&drive->queue, rq, sg);
21356 +       nents = blk_rq_map_sg(drive->queue, rq, sg);
21357                 
21358         if (rq_data_dir(rq) == READ)
21359                 pmif->sg_dma_direction = PCI_DMA_FROMDEVICE;
21360 @@ -952,7 +1489,7 @@
21361         return pci_map_sg(hwif->pci_dev, sg, nents, pmif->sg_dma_direction);
21362  }
21363  
21364 -static int
21365 +static int __pmac
21366  pmac_ide_raw_build_sglist(ide_drive_t *drive, struct request *rq)
21367  {
21368         ide_hwif_t *hwif = HWIF(drive);
21369 @@ -968,14 +1505,14 @@
21370         else
21371                 pmif->sg_dma_direction = PCI_DMA_FROMDEVICE;
21372         
21373 -       if (sector_count > 127) {
21374 +       if (sector_count > 128) {
21375                 memset(&sg[nents], 0, sizeof(*sg));
21376                 sg[nents].page = virt_to_page(virt_addr);
21377                 sg[nents].offset = offset_in_page(virt_addr);
21378 -               sg[nents].length = 127  * SECTOR_SIZE;
21379 +               sg[nents].length = 128  * SECTOR_SIZE;
21380                 nents++;
21381 -               virt_addr = virt_addr + (127 * SECTOR_SIZE);
21382 -               sector_count -= 127;
21383 +               virt_addr = virt_addr + (128 * SECTOR_SIZE);
21384 +               sector_count -= 128;
21385         }
21386         memset(&sg[nents], 0, sizeof(*sg));
21387         sg[nents].page = virt_to_page(virt_addr);
21388 @@ -990,16 +1527,16 @@
21389   * pmac_ide_build_dmatable builds the DBDMA command list
21390   * for a transfer and sets the DBDMA channel to point to it.
21391   */
21392 -static int
21393 -pmac_ide_build_dmatable(ide_drive_t *drive, int wr)
21394 +static int __pmac
21395 +pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq)
21396  {
21397         struct dbdma_cmd *table;
21398         int i, count = 0;
21399 -       struct request *rq = HWGROUP(drive)->rq;
21400         ide_hwif_t *hwif = HWIF(drive);
21401         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
21402         volatile struct dbdma_regs *dma = pmif->dma_regs;
21403         struct scatterlist *sg;
21404 +       int wr = (rq_data_dir(rq) == WRITE);
21405  
21406         /* DMA table is already aligned */
21407         table = (struct dbdma_cmd *) pmif->dma_table_cpu;
21408 @@ -1026,10 +1563,18 @@
21409                 cur_addr = sg_dma_address(sg);
21410                 cur_len = sg_dma_len(sg);
21411  
21412 +               if (pmif->broken_dma && cur_addr & (L1_CACHE_BYTES - 1)) {
21413 +                       if (pmif->broken_dma_warn == 0) {
21414 +                               printk(KERN_WARNING "%s: DMA on non aligned address,"
21415 +                                      "switching to PIO on Ohare chipset\n", drive->name);
21416 +                               pmif->broken_dma_warn = 1;
21417 +                       }
21418 +                       goto use_pio_instead;
21419 +               }
21420                 while (cur_len) {
21421                         unsigned int tc = (cur_len < 0xfe00)? cur_len: 0xfe00;
21422  
21423 -                       if (++count >= MAX_DCMDS) {
21424 +                       if (count++ >= MAX_DCMDS) {
21425                                 printk(KERN_WARNING "%s: DMA table too small\n",
21426                                        drive->name);
21427                                 goto use_pio_instead;
21428 @@ -1070,7 +1615,7 @@
21429  }
21430  
21431  /* Teardown mappings after DMA has completed.  */
21432 -static void
21433 +static void __pmac
21434  pmac_ide_destroy_dmatable (ide_drive_t *drive)
21435  {
21436         struct pci_dev *dev = HWIF(drive)->pci_dev;
21437 @@ -1081,67 +1626,25 @@
21438         if (nents) {
21439                 pci_unmap_sg(dev, sg, nents, pmif->sg_dma_direction);
21440                 pmif->sg_nents = 0;
21441 +               HWIF(drive)->sg_dma_active = 0;
21442         }
21443  }
21444  
21445 -static __inline__ unsigned char
21446 -dma_bits_to_command(unsigned char bits)
21447 -{
21448 -       if(bits & 0x04)
21449 -               return XFER_MW_DMA_2;
21450 -       if(bits & 0x02)
21451 -               return XFER_MW_DMA_1;
21452 -       if(bits & 0x01)
21453 -               return XFER_MW_DMA_0;
21454 -       return 0;
21455 -}
21456 -
21457 -static __inline__ unsigned char
21458 -udma_bits_to_command(unsigned char bits, int high_speed)
21459 -{
21460 -       if (high_speed) {
21461 -               if(bits & 0x10)
21462 -                       return XFER_UDMA_4;
21463 -               if(bits & 0x08)
21464 -                       return XFER_UDMA_3;
21465 -       }
21466 -       if(bits & 0x04)
21467 -               return XFER_UDMA_2;
21468 -       if(bits & 0x02)
21469 -               return XFER_UDMA_1;
21470 -       if(bits & 0x01)
21471 -               return XFER_UDMA_0;
21472 -       return 0;
21473 -}
21474 -
21475  /* Calculate MultiWord DMA timings */
21476  static int __pmac
21477 -pmac_ide_mdma_enable(ide_drive_t *drive)
21478 +pmac_ide_mdma_enable(ide_drive_t *drive, u16 mode)
21479  {
21480 -       u8 bits = drive->id->dma_mword & 0x07;
21481 -       u8 feature = dma_bits_to_command(bits);
21482 -       u32 *timings;
21483 +       ide_hwif_t *hwif = HWIF(drive);
21484 +       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
21485         int drive_cycle_time;
21486         struct hd_driveid *id = drive->id;
21487 -       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
21488 +       u32 *timings, *timings2;
21489 +       u32 timing_local[2];
21490         int ret;
21491  
21492 -       /* Set feature on drive */
21493 -       printk(KERN_INFO "%s: Enabling MultiWord DMA %d\n", drive->name, feature & 0xf);
21494 -       ret = pmac_ide_do_setfeature(drive, feature);
21495 -       if (ret) {
21496 -               printk(KERN_WARNING "%s: Failed !\n", drive->name);
21497 -               return 0;
21498 -       }
21499 -
21500 -       if (!drive->init_speed)
21501 -               drive->init_speed = feature;
21502 -       
21503         /* which drive is it ? */
21504 -       if (drive->select.b.unit & 0x01)
21505 -               timings = &pmif->timings[1];
21506 -       else
21507 -               timings = &pmif->timings[0];
21508 +       timings = &pmif->timings[drive->select.b.unit & 0x01];
21509 +       timings2 = &pmif->timings[(drive->select.b.unit & 0x01) + 2];
21510  
21511         /* Check if drive provide explicit cycle time */
21512         if ((id->field_valid & 2) && (id->eide_dma_time))
21513 @@ -1149,201 +1652,220 @@
21514         else
21515                 drive_cycle_time = 0;
21516  
21517 +       /* Copy timings to local image */
21518 +       timing_local[0] = *timings;
21519 +       timing_local[1] = *timings2;
21520 +
21521         /* Calculate controller timings */
21522 -       set_timings_mdma(pmif->kind, timings, feature, drive_cycle_time);
21523 +       ret = set_timings_mdma( drive, pmif->kind,
21524 +                               &timing_local[0],
21525 +                               &timing_local[1],
21526 +                               mode,
21527 +                               drive_cycle_time);
21528 +       if (ret)
21529 +               return 0;
21530 +
21531 +       /* Set feature on drive */
21532 +       printk(KERN_INFO "%s: Enabling MultiWord DMA %d\n", drive->name, mode & 0xf);
21533 +       ret = pmac_ide_do_setfeature(drive, mode);
21534 +       if (ret) {
21535 +               printk(KERN_WARNING "%s: Failed !\n", drive->name);
21536 +               return 0;
21537 +       }
21538 +
21539 +       /* Apply timings to controller */
21540 +       *timings = timing_local[0];
21541 +       *timings2 = timing_local[1];
21542 +       
21543 +       /* Set speed info in drive */
21544 +       drive->current_speed = mode;    
21545 +       if (!drive->init_speed)
21546 +               drive->init_speed = mode;
21547  
21548 -       drive->current_speed = feature; 
21549         return 1;
21550  }
21551  
21552  /* Calculate Ultra DMA timings */
21553  static int __pmac
21554 -pmac_ide_udma_enable(ide_drive_t *drive, int high_speed)
21555 +pmac_ide_udma_enable(ide_drive_t *drive, u16 mode)
21556  {
21557 -       u8 bits = drive->id->dma_ultra & 0x1f;
21558 -       u8 feature = udma_bits_to_command(bits, high_speed);
21559 -       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
21560 -       u32 *timings;
21561 +       ide_hwif_t *hwif = HWIF(drive);
21562 +       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
21563 +       u32 *timings, *timings2;
21564 +       u32 timing_local[2];
21565         int ret;
21566 +               
21567 +       /* which drive is it ? */
21568 +       timings = &pmif->timings[drive->select.b.unit & 0x01];
21569 +       timings2 = &pmif->timings[(drive->select.b.unit & 0x01) + 2];
21570  
21571 +       /* Copy timings to local image */
21572 +       timing_local[0] = *timings;
21573 +       timing_local[1] = *timings2;
21574 +       
21575 +       /* Calculate timings for interface */
21576 +       if (pmif->kind == controller_un_ata6)
21577 +               ret = set_timings_udma_ata6(    &timing_local[0],
21578 +                                               &timing_local[1],
21579 +                                               mode);
21580 +       else
21581 +               ret = set_timings_udma_ata4(&timing_local[0], mode);
21582 +       if (ret)
21583 +               return 0;
21584 +               
21585         /* Set feature on drive */
21586 -       printk(KERN_INFO "%s: Enabling Ultra DMA %d\n", drive->name, feature & 0xf);
21587 -       ret = pmac_ide_do_setfeature(drive, feature);
21588 +       printk(KERN_INFO "%s: Enabling Ultra DMA %d\n", drive->name, mode & 0x0f);
21589 +       ret = pmac_ide_do_setfeature(drive, mode);
21590         if (ret) {
21591                 printk(KERN_WARNING "%s: Failed !\n", drive->name);
21592                 return 0;
21593         }
21594  
21595 -       if (!drive->init_speed)
21596 -               drive->init_speed = feature;
21597 +       /* Apply timings to controller */
21598 +       *timings = timing_local[0];
21599 +       *timings2 = timing_local[1];
21600  
21601 -       /* which drive is it ? */
21602 -       if (drive->select.b.unit & 0x01)
21603 -               timings = &pmif->timings[1];
21604 -       else
21605 -               timings = &pmif->timings[0];
21606 -
21607 -       set_timings_udma(timings, feature);
21608 +       /* Set speed info in drive */
21609 +       drive->current_speed = mode;    
21610 +       if (!drive->init_speed)
21611 +               drive->init_speed = mode;
21612  
21613 -       drive->current_speed = feature; 
21614         return 1;
21615  }
21616  
21617 -int pmac_ide_dma_check(ide_drive_t *drive)
21618 +static int __pmac
21619 +pmac_ide_dma_check(ide_drive_t *drive)
21620  {
21621 -       int ata4, udma;
21622         struct hd_driveid *id = drive->id;
21623         ide_hwif_t *hwif = HWIF(drive);
21624         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
21625         int enable = 1;
21626 -
21627 +       int map;
21628         drive->using_dma = 0;
21629         
21630 -       if (pmif == NULL)
21631 -               return 0;
21632 -               
21633         if (drive->media == ide_floppy)
21634                 enable = 0;
21635 -       if (((id->capability & 1) == 0) &&
21636 -           !HWIF(drive)->ide_dma_good_drive(drive))
21637 +       if (((id->capability & 1) == 0) && !__ide_dma_good_drive(drive))
21638                 enable = 0;
21639 -       if (HWIF(drive)->ide_dma_bad_drive(drive))
21640 +       if (__ide_dma_bad_drive(drive))
21641                 enable = 0;
21642 -       udma = 0;
21643 -       ata4 = (pmif->kind == controller_kl_ata4 ||
21644 -               pmif->kind == controller_kl_ata4_80);
21645 -                       
21646 -       if(enable) {
21647 -               if (ata4 && (drive->media == ide_disk) &&
21648 -                   (id->field_valid & 0x0004) && (id->dma_ultra & 0x1f)) {
21649 -                       /* UltraDMA modes. */
21650 -                       drive->using_dma = pmac_ide_udma_enable(drive,
21651 -                               pmif->kind == controller_kl_ata4_80);
21652 -               }
21653 -               if (!drive->using_dma && (id->dma_mword & 0x0007)) {
21654 -                       /* Normal MultiWord DMA modes. */
21655 -                       drive->using_dma = pmac_ide_mdma_enable(drive);
21656 +
21657 +       if (enable) {
21658 +               short mode;
21659 +               
21660 +               map = XFER_MWDMA;
21661 +               if (pmif->kind == controller_kl_ata4 || pmif->kind == controller_un_ata6) {
21662 +                       map |= XFER_UDMA;
21663 +                       if (pmif->cable_80) {
21664 +                               map |= XFER_UDMA_66;
21665 +                               if (pmif->kind == controller_un_ata6)
21666 +                                       map |= XFER_UDMA_100;
21667 +                       }
21668                 }
21669 +               mode = ide_find_best_mode(drive, map);
21670 +               if (mode & XFER_UDMA)
21671 +                       drive->using_dma = pmac_ide_udma_enable(drive, mode);
21672 +               else if (mode & XFER_MWDMA)
21673 +                       drive->using_dma = pmac_ide_mdma_enable(drive, mode);
21674                 hwif->OUTB(0, IDE_CONTROL_REG);
21675                 /* Apply settings to controller */
21676 -               pmac_ide_selectproc(drive);
21677 +               pmac_ide_do_update_timings(drive);
21678         }
21679         return 0;
21680  }
21681  
21682 -static int
21683 -pmac_ide_dma_read (ide_drive_t *drive)
21684 +static int __pmac
21685 +pmac_ide_dma_start(ide_drive_t *drive, int reading)
21686  {
21687         ide_hwif_t *hwif = HWIF(drive);
21688         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
21689         struct request *rq = HWGROUP(drive)->rq;
21690 -//     ide_task_t *args = rq->special;
21691         u8 unit = (drive->select.b.unit & 0x01);
21692         u8 ata4;
21693 -       u8 lba48 = (drive->addressing == 1) ? 1 : 0;
21694 -       task_ioreg_t command = WIN_NOP;
21695  
21696         if (pmif == NULL)
21697                 return 1;
21698 +       ata4 = (pmif->kind == controller_kl_ata4);      
21699  
21700 -       ata4 = (pmif->kind == controller_kl_ata4 ||
21701 -               pmif->kind == controller_kl_ata4_80);
21702 -
21703 -       if (!pmac_ide_build_dmatable(drive, 0))
21704 +       if (!pmac_ide_build_dmatable(drive, rq))
21705                 return 1;
21706 +
21707         /* Apple adds 60ns to wrDataSetup on reads */
21708         if (ata4 && (pmif->timings[unit] & TR_66_UDMA_EN)) {
21709 -               writel(pmif->timings[unit]+0x00800000UL,
21710 +               writel(pmif->timings[unit] + (reading ? 0x00800000UL : 0),
21711                         (unsigned *)(IDE_DATA_REG+IDE_TIMING_CONFIG));
21712                 (void)readl((unsigned *)(IDE_DATA_REG + IDE_TIMING_CONFIG));
21713         }
21714 +
21715         drive->waiting_for_dma = 1;
21716 +
21717 +       return 0;
21718 +}
21719 +
21720 +static int __pmac
21721 +pmac_ide_dma_read(ide_drive_t *drive)
21722 +{
21723 +       struct request *rq = HWGROUP(drive)->rq;
21724 +       u8 lba48 = (drive->addressing == 1) ? 1 : 0;
21725 +       task_ioreg_t command = WIN_NOP;
21726 +
21727 +       if (pmac_ide_dma_start(drive, 1))
21728 +               return 1;
21729 +
21730         if (drive->media != ide_disk)
21731                 return 0;
21732 -       if (HWGROUP(drive)->handler != NULL)    /* paranoia check */
21733 -               BUG();
21734 -       ide_set_handler(drive, &ide_dma_intr, WAIT_CMD, NULL);
21735 -       /*
21736 -        * FIX ME to use only ACB ide_task_t args Struct
21737 -        */
21738 -#if 0
21739 -       {
21740 -               ide_task_t *args = rq->special;
21741 -               command = args->tfRegister[IDE_COMMAND_OFFSET];
21742 -       }
21743 -#else
21744 +
21745         command = (lba48) ? WIN_READDMA_EXT : WIN_READDMA;
21746 +       
21747 +       if (drive->vdma)
21748 +               command = (lba48) ? WIN_READ_EXT: WIN_READ;
21749 +               
21750         if (rq->flags & REQ_DRIVE_TASKFILE) {
21751                 ide_task_t *args = rq->special;
21752                 command = args->tfRegister[IDE_COMMAND_OFFSET];
21753         }
21754 -#endif
21755 +
21756         /* issue cmd to drive */
21757 -       hwif->OUTB(command, IDE_COMMAND_REG);
21758 +       ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, NULL);
21759  
21760         return pmac_ide_dma_begin(drive);
21761  }
21762  
21763 -static int
21764 +static int __pmac
21765  pmac_ide_dma_write (ide_drive_t *drive)
21766  {
21767 -       ide_hwif_t *hwif = HWIF(drive);
21768 -       pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
21769         struct request *rq = HWGROUP(drive)->rq;
21770 -//     ide_task_t *args = rq->special;
21771 -       u8 unit = (drive->select.b.unit & 0x01);
21772 -       u8 ata4;
21773         u8 lba48 = (drive->addressing == 1) ? 1 : 0;
21774         task_ioreg_t command = WIN_NOP;
21775  
21776 -       if (pmif == NULL)
21777 +       if (pmac_ide_dma_start(drive, 0))
21778                 return 1;
21779  
21780 -       ata4 = (pmif->kind == controller_kl_ata4 ||
21781 -               pmif->kind == controller_kl_ata4_80);
21782 -
21783 -       if (!pmac_ide_build_dmatable(drive, 1))
21784 -               return 1;
21785 -       /* Apple adds 60ns to wrDataSetup on reads */
21786 -       if (ata4 && (pmif->timings[unit] & TR_66_UDMA_EN)) {
21787 -               writel(pmif->timings[unit],
21788 -                       (unsigned *)(IDE_DATA_REG+IDE_TIMING_CONFIG));
21789 -               (void)readl((unsigned *)(IDE_DATA_REG + IDE_TIMING_CONFIG));
21790 -       }
21791 -       drive->waiting_for_dma = 1;
21792         if (drive->media != ide_disk)
21793                 return 0;
21794 -       if (HWGROUP(drive)->handler != NULL)    /* paranoia check */
21795 -               BUG();
21796 -       ide_set_handler(drive, &ide_dma_intr, WAIT_CMD, NULL);
21797 -       /*
21798 -        * FIX ME to use only ACB ide_task_t args Struct
21799 -        */
21800 -#if 0
21801 -       {
21802 -               ide_task_t *args = rq->special;
21803 -               command = args->tfRegister[IDE_COMMAND_OFFSET];
21804 -       }
21805 -#else
21806 +
21807         command = (lba48) ? WIN_WRITEDMA_EXT : WIN_WRITEDMA;
21808 +       if (drive->vdma)
21809 +               command = (lba48) ? WIN_WRITE_EXT: WIN_WRITE;
21810 +               
21811         if (rq->flags & REQ_DRIVE_TASKFILE) {
21812                 ide_task_t *args = rq->special;
21813                 command = args->tfRegister[IDE_COMMAND_OFFSET];
21814         }
21815 -#endif
21816 +
21817         /* issue cmd to drive */
21818 -       hwif->OUTB(command, IDE_COMMAND_REG);
21819 +       ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, NULL);
21820  
21821         return pmac_ide_dma_begin(drive);
21822  }
21823  
21824 -static int
21825 +static int __pmac
21826  pmac_ide_dma_count (ide_drive_t *drive)
21827  {
21828         return HWIF(drive)->ide_dma_begin(drive);
21829  }
21830  
21831 -static int
21832 +static int __pmac
21833  pmac_ide_dma_begin (ide_drive_t *drive)
21834  {
21835         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
21836 @@ -1359,7 +1881,7 @@
21837         return 0;
21838  }
21839  
21840 -static int
21841 +static int __pmac
21842  pmac_ide_dma_end (ide_drive_t *drive)
21843  {
21844         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
21845 @@ -1378,7 +1900,7 @@
21846         return (dstat & (RUN|DEAD|ACTIVE)) != RUN;
21847  }
21848  
21849 -static int
21850 +static int __pmac
21851  pmac_ide_dma_test_irq (ide_drive_t *drive)
21852  {
21853         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
21854 @@ -1418,33 +1940,33 @@
21855                 return 1;
21856         if (!drive->waiting_for_dma)
21857                 printk(KERN_WARNING "ide%d, ide_dma_test_irq \
21858 -                       called while not waiting\n", pmif->index);
21859 +                       called while not waiting\n", HWIF(drive)->index);
21860  
21861         /* If dbdma didn't execute the STOP command yet, the
21862          * active bit is still set */
21863         drive->waiting_for_dma++;
21864         if (drive->waiting_for_dma >= DMA_WAIT_TIMEOUT) {
21865                 printk(KERN_WARNING "ide%d, timeout waiting \
21866 -                       for dbdma command stop\n", pmif->index);
21867 +                       for dbdma command stop\n", HWIF(drive)->index);
21868                 return 1;
21869         }
21870 -       udelay(1);
21871 +       udelay(5);
21872         return 0;
21873  }
21874  
21875 -static int
21876 +static int __pmac
21877  pmac_ide_dma_host_off (ide_drive_t *drive)
21878  {
21879         return 0;
21880  }
21881  
21882 -static int
21883 +static int __pmac
21884  pmac_ide_dma_host_on (ide_drive_t *drive)
21885  {
21886         return 0;
21887  }
21888  
21889 -static int
21890 +static int __pmac
21891  pmac_ide_dma_lostirq (ide_drive_t *drive)
21892  {
21893         pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
21894 @@ -1461,316 +1983,87 @@
21895  }
21896  
21897  static void __init 
21898 -pmac_ide_setup_dma(struct device_node *np, int ix)
21899 +pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
21900  {
21901 -       struct pmac_ide_hwif *pmif = &pmac_ide[ix];
21902 -
21903 -       if (request_OF_resource(np, 1, " (mac-io IDE DMA)") == NULL) {
21904 -               printk(KERN_ERR "ide-pmac(%s): can't request DMA resource !\n", np->name);
21905 +       /* We won't need pci_dev if we switch to generic consistent
21906 +        * DMA routines ...
21907 +        */
21908 +       if (hwif->pci_dev == NULL)
21909                 return;
21910 -       }
21911 -
21912 -       pmif->dma_regs =
21913 -               (volatile struct dbdma_regs*)ioremap(np->addrs[1].address, 0x200);
21914 -
21915         /*
21916          * Allocate space for the DBDMA commands.
21917          * The +2 is +1 for the stop command and +1 to allow for
21918          * aligning the start address to a multiple of 16 bytes.
21919          */
21920         pmif->dma_table_cpu = (struct dbdma_cmd*)pci_alloc_consistent(
21921 -               ide_hwifs[ix].pci_dev,
21922 +               hwif->pci_dev,
21923                 (MAX_DCMDS + 2) * sizeof(struct dbdma_cmd),
21924                 &pmif->dma_table_dma);
21925         if (pmif->dma_table_cpu == NULL) {
21926                 printk(KERN_ERR "%s: unable to allocate DMA command list\n",
21927 -                      ide_hwifs[ix].name);
21928 +                      hwif->name);
21929                 return;
21930         }
21931  
21932         pmif->sg_table = kmalloc(sizeof(struct scatterlist) * MAX_DCMDS,
21933                                  GFP_KERNEL);
21934         if (pmif->sg_table == NULL) {
21935 -               pci_free_consistent(    ide_hwifs[ix].pci_dev,
21936 +               pci_free_consistent(    hwif->pci_dev,
21937                                         (MAX_DCMDS + 2) * sizeof(struct dbdma_cmd),
21938                                         pmif->dma_table_cpu, pmif->dma_table_dma);
21939                 return;
21940         }
21941 -       ide_hwifs[ix].ide_dma_off = &__ide_dma_off;
21942 -       ide_hwifs[ix].ide_dma_off_quietly = &__ide_dma_off_quietly;
21943 -       ide_hwifs[ix].ide_dma_on = &__ide_dma_on;
21944 -       ide_hwifs[ix].ide_dma_check = &pmac_ide_dma_check;
21945 -       ide_hwifs[ix].ide_dma_read = &pmac_ide_dma_read;
21946 -       ide_hwifs[ix].ide_dma_write = &pmac_ide_dma_write;
21947 -       ide_hwifs[ix].ide_dma_count = &pmac_ide_dma_count;
21948 -       ide_hwifs[ix].ide_dma_begin = &pmac_ide_dma_begin;
21949 -       ide_hwifs[ix].ide_dma_end = &pmac_ide_dma_end;
21950 -       ide_hwifs[ix].ide_dma_test_irq = &pmac_ide_dma_test_irq;
21951 -       ide_hwifs[ix].ide_dma_host_off = &pmac_ide_dma_host_off;
21952 -       ide_hwifs[ix].ide_dma_host_on = &pmac_ide_dma_host_on;
21953 -       ide_hwifs[ix].ide_dma_good_drive = &__ide_dma_good_drive;
21954 -       ide_hwifs[ix].ide_dma_bad_drive = &__ide_dma_bad_drive;
21955 -       ide_hwifs[ix].ide_dma_verbose = &__ide_dma_verbose;
21956 -       ide_hwifs[ix].ide_dma_timeout = &__ide_dma_timeout;
21957 -       ide_hwifs[ix].ide_dma_retune = &__ide_dma_retune;
21958 -       ide_hwifs[ix].ide_dma_lostirq = &pmac_ide_dma_lostirq;
21959 -       ide_hwifs[ix].ide_dma_queued_on = &__ide_dma_queued_on;
21960 -       ide_hwifs[ix].ide_dma_queued_off = &__ide_dma_queued_off;
21961 +       hwif->ide_dma_off = &__ide_dma_off;
21962 +       hwif->ide_dma_off_quietly = &__ide_dma_off_quietly;
21963 +       hwif->ide_dma_on = &__ide_dma_on;
21964 +       hwif->ide_dma_check = &pmac_ide_dma_check;
21965 +       hwif->ide_dma_read = &pmac_ide_dma_read;
21966 +       hwif->ide_dma_write = &pmac_ide_dma_write;
21967 +       hwif->ide_dma_count = &pmac_ide_dma_count;
21968 +       hwif->ide_dma_begin = &pmac_ide_dma_begin;
21969 +       hwif->ide_dma_end = &pmac_ide_dma_end;
21970 +       hwif->ide_dma_test_irq = &pmac_ide_dma_test_irq;
21971 +       hwif->ide_dma_host_off = &pmac_ide_dma_host_off;
21972 +       hwif->ide_dma_host_on = &pmac_ide_dma_host_on;
21973 +       hwif->ide_dma_good_drive = &__ide_dma_good_drive;
21974 +       hwif->ide_dma_bad_drive = &__ide_dma_bad_drive;
21975 +       hwif->ide_dma_verbose = &__ide_dma_verbose;
21976 +       hwif->ide_dma_timeout = &__ide_dma_timeout;
21977 +       hwif->ide_dma_retune = &__ide_dma_retune;
21978 +       hwif->ide_dma_lostirq = &pmac_ide_dma_lostirq;
21979 +       hwif->ide_dma_queued_on = &__ide_dma_queued_on;
21980 +       hwif->ide_dma_queued_off = &__ide_dma_queued_off;
21981 +#ifdef CONFIG_BLK_DEV_IDE_TCQ
21982 +       hwif->ide_dma_queued_read = __ide_dma_queued_read;
21983 +       hwif->ide_dma_queued_write = __ide_dma_queued_write;
21984 +       hwif->ide_dma_queued_start = __ide_dma_queued_start;
21985 +#endif
21986  
21987  #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO
21988         if (!noautodma)
21989 -               ide_hwifs[ix].autodma = 1;
21990 +               hwif->autodma = 1;
21991  #endif
21992 -       ide_hwifs[ix].drives[0].autodma = ide_hwifs[ix].autodma;
21993 -       ide_hwifs[ix].drives[1].autodma = ide_hwifs[ix].autodma;
21994 -}
21995 -
21996 -#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
21997 -
21998 -static void __pmac
21999 -idepmac_sleep_device(ide_drive_t *drive, unsigned base)
22000 -{
22001 -       ide_hwif_t *hwif = HWIF(drive);
22002 -       int j;
22003 -       
22004 -       /* FIXME: We only handle the master IDE disk, we shoud
22005 -        *        try to fix CD-ROMs here
22006 -        */
22007 -       switch (drive->media) {
22008 -       case ide_disk:
22009 -               /* Spin down the drive */
22010 -               hwif->OUTB(drive->select.all, base+0x60);
22011 -               (void) hwif->INB(base+0x60);
22012 -               udelay(100);
22013 -               hwif->OUTB(0x0, base+0x30);
22014 -               hwif->OUTB(0x0, base+0x20);
22015 -               hwif->OUTB(0x0, base+0x40);
22016 -               hwif->OUTB(0x0, base+0x50);
22017 -               hwif->OUTB(0xe0, base+0x70);
22018 -               hwif->OUTB(0x2, base+0x160);   
22019 -               for (j = 0; j < 10; j++) {
22020 -                       u8 status;
22021 -                       mdelay(100);
22022 -                       status = hwif->INB(base+0x70);
22023 -                       if (!(status & BUSY_STAT) && (status & DRQ_STAT))
22024 -                               break;
22025 -               }
22026 -               break;
22027 -       case ide_cdrom:
22028 -               // todo
22029 -               break;
22030 -       case ide_floppy:
22031 -               // todo
22032 -               break;
22033 -       }
22034 -}
22035 -
22036 -#ifdef CONFIG_PMAC_PBOOK
22037 -static void __pmac
22038 -idepmac_wake_device(ide_drive_t *drive, int used_dma)
22039 -{
22040 -       /* We force the IDE subdriver to check for a media change
22041 -        * This must be done first or we may lost the condition
22042 -        *
22043 -        * Problem: This can schedule. I moved the block device
22044 -        * wakeup almost late by priority because of that.
22045 -        */
22046 -       //if (DRIVER(drive))
22047 -       //      check_disk_change(MKDEV(drive->disk->major, drive->disk->first_minor));
22048 -       
22049 -#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
22050 -       /* We re-enable DMA on the drive if it was active. */
22051 -       /* This doesn't work with the CD-ROM in the media-bay, probably
22052 -        * because of a pending unit attention. The problem if that if I
22053 -        * clear the error, the filesystem dies.
22054 -        */
22055 -       if (used_dma && !ide_spin_wait_hwgroup(drive)) {
22056 -               /* Lock HW group */
22057 -               HWGROUP(drive)->busy = 1;
22058 -               pmac_ide_dma_check(drive);
22059 -               HWGROUP(drive)->busy = 0;
22060 -               if (!list_empty(&drive->queue.queue_head))
22061 -                       ide_do_request(HWGROUP(drive), 0);
22062 -               spin_unlock_irq(&ide_lock);
22063 -       }
22064 -#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
22065 -}
22066 -
22067 -static void __pmac
22068 -idepmac_sleep_interface(pmac_ide_hwif_t *pmif, unsigned base, int mediabay)
22069 -{
22070 -       struct device_node* np = pmif->node;
22071 -
22072 -       /* We clear the timings */
22073 -       pmif->timings[0] = 0;
22074 -       pmif->timings[1] = 0;
22075 -       
22076 -       /* The media bay will handle itself just fine */
22077 -       if (mediabay)
22078 -               return;
22079 -       
22080 -       /* Disable the bus */
22081 -       ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmif->aapl_bus_id, 0);
22082 -}
22083 +       hwif->drives[0].autodma = hwif->autodma;
22084 +       hwif->drives[1].autodma = hwif->autodma;
22085  
22086 -static void __pmac
22087 -idepmac_wake_interface(pmac_ide_hwif_t *pmif, unsigned long base, int mediabay)
22088 -{
22089 -       struct device_node* np = pmif->node;
22090 -
22091 -       if (!mediabay) {
22092 -               /* Revive IDE disk and controller */
22093 -               ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 1);
22094 -               ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmif->aapl_bus_id, 1);
22095 -               mdelay(10);
22096 -               ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 0);
22097 -       }
22098 -}
22099 -
22100 -static void
22101 -idepmac_sleep_drive(ide_drive_t *drive, unsigned long base)
22102 -{
22103 -       int unlock = 0;
22104 -
22105 -       /* Wait for HW group to complete operations */
22106 -       if (ide_spin_wait_hwgroup(drive)) {
22107 -               // What can we do here ? Wake drive we had already
22108 -               // put to sleep and return an error ?
22109 -       } else {
22110 -               unlock = 1;
22111 -               /* Lock HW group */
22112 -               HWGROUP(drive)->busy = 1;
22113 -               /* Stop the device */
22114 -               idepmac_sleep_device(drive, base);
22115 -       }
22116 -       if (unlock)
22117 -               spin_unlock_irq(&ide_lock);
22118 -}
22119 -
22120 -static void
22121 -idepmac_wake_drive(ide_drive_t *drive, unsigned long base)
22122 -{
22123 -       ide_hwif_t *hwif = HWIF(drive);
22124 -       unsigned long flags;
22125 -       int j;
22126 -       
22127 -       /* Reset timings */
22128 -       pmac_ide_selectproc(drive);
22129 -       mdelay(10);
22130 -       
22131 -       /* Wait up to 20 seconds for the drive to be ready */
22132 -       for (j = 0; j < 200; j++) {
22133 -               u8 status = 0;
22134 -               mdelay(100);
22135 -               hwif->OUTB(drive->select.all, base + 0x60);
22136 -               if ((hwif->INB(base + 0x60)) != drive->select.all)
22137 -                       continue;
22138 -               status = hwif->INB(base + 0x70);
22139 -               if (!(status & BUSY_STAT))
22140 +       hwif->atapi_dma = 1;
22141 +       switch(pmif->kind) {
22142 +               case controller_un_ata6:
22143 +                       hwif->ultra_mask = pmif->cable_80 ? 0x3f : 0x07;
22144 +                       hwif->mwdma_mask = 0x07;
22145 +                       hwif->swdma_mask = 0x00;
22146                         break;
22147 -       }
22148 -
22149 -       /* We resume processing on the HW group */
22150 -       spin_lock_irqsave(&ide_lock, flags);
22151 -       HWGROUP(drive)->busy = 0;
22152 -       if (!list_empty(&drive->queue.queue_head))
22153 -               ide_do_request(HWGROUP(drive), 0);
22154 -       spin_unlock_irqrestore(&ide_lock, flags);
22155 +               case controller_kl_ata4:
22156 +                       hwif->ultra_mask = pmif->cable_80 ? 0x1f : 0x07;
22157 +                       hwif->mwdma_mask = 0x07;
22158 +                       hwif->swdma_mask = 0x00;
22159 +                       break;
22160 +               default:
22161 +                       hwif->ultra_mask = 0x00;
22162 +                       hwif->mwdma_mask = 0x07;
22163 +                       hwif->swdma_mask = 0x00;
22164 +                       break;
22165 +       }       
22166  }
22167  
22168 -/* Note: We support only master drives for now. This will have to be
22169 - * improved if we want to handle sleep on the iMacDV where the CD-ROM
22170 - * is a slave
22171 - */
22172 -static int __pmac
22173 -idepmac_notify_sleep(struct pmu_sleep_notifier *self, int when)
22174 -{
22175 -       int i, ret;
22176 -       unsigned long base;
22177 -       int big_delay;
22178
22179 -       switch (when) {
22180 -       case PBOOK_SLEEP_REQUEST:
22181 -               break;
22182 -       case PBOOK_SLEEP_REJECT:
22183 -               break;
22184 -       case PBOOK_SLEEP_NOW:
22185 -               for (i = 0; i < pmac_ide_count; ++i) {
22186 -                       ide_hwif_t *hwif;
22187 -                       int dn;
22188 -
22189 -                       if ((base = pmac_ide[i].regbase) == 0)
22190 -                               continue;
22191 -
22192 -                       hwif = &ide_hwifs[i];
22193 -                       for (dn=0; dn<MAX_DRIVES; dn++) {
22194 -                               if (!hwif->drives[dn].present)
22195 -                                       continue;
22196 -                               idepmac_sleep_drive(&hwif->drives[dn], base);
22197 -                       }
22198 -                       /* Disable irq during sleep */
22199 -                       disable_irq(pmac_ide[i].irq);
22200 -                       
22201 -                       /* Check if this is a media bay with an IDE device or not
22202 -                        * a media bay.
22203 -                        */
22204 -                       ret = check_media_bay_by_base(base, MB_CD);
22205 -                       if ((ret == 0) || (ret == -ENODEV))
22206 -                               idepmac_sleep_interface(&pmac_ide[i], base, (ret == 0));
22207 -               }
22208 -               break;
22209 -       case PBOOK_WAKE:
22210 -               big_delay = 0;
22211 -               for (i = 0; i < pmac_ide_count; ++i) {
22212 -
22213 -                       if ((base = pmac_ide[i].regbase) == 0)
22214 -                               continue;
22215 -                               
22216 -                       /* Make sure we have sane timings */            
22217 -                       sanitize_timings(&pmac_ide[i]);
22218 -
22219 -                       /* Check if this is a media bay with an IDE device or not
22220 -                        * a media bay
22221 -                        */
22222 -                       ret = check_media_bay_by_base(base, MB_CD);
22223 -                       if ((ret == 0) || (ret == -ENODEV)) {
22224 -                               idepmac_wake_interface(&pmac_ide[i], base, (ret == 0));                         
22225 -                               big_delay = 1;
22226 -                       }
22227 -
22228 -               }
22229 -               /* Let hardware get up to speed */
22230 -               if (big_delay)
22231 -                       mdelay(IDE_WAKEUP_DELAY_MS);
22232 -       
22233 -               for (i = 0; i < pmac_ide_count; ++i) {
22234 -                       ide_hwif_t *hwif;
22235 -                       int used_dma, dn;
22236 -                       int irq_on = 0;
22237 -                       
22238 -                       if ((base = pmac_ide[i].regbase) == 0)
22239 -                               continue;
22240 -                               
22241 -                       hwif = &ide_hwifs[i];
22242 -                       for (dn=0; dn<MAX_DRIVES; dn++) {
22243 -                               ide_drive_t *drive = &hwif->drives[dn];
22244 -                               if (!drive->present)
22245 -                                       continue;
22246 -                               /* We don't have re-configured DMA yet */
22247 -                               used_dma = drive->using_dma;
22248 -                               drive->using_dma = 0;
22249 -                               idepmac_wake_drive(drive, base);
22250 -                               if (!irq_on) {
22251 -                                       enable_irq(pmac_ide[i].irq);
22252 -                                       irq_on = 1;
22253 -                               }
22254 -                               idepmac_wake_device(drive, used_dma);
22255 -                       }
22256 -                       if (!irq_on)
22257 -                               enable_irq(pmac_ide[i].irq);
22258 -               }
22259 -               break;
22260 -       }
22261 -       return PBOOK_SLEEP_OK;
22262 -}
22263 -#endif /* CONFIG_PMAC_PBOOK */
22264 +#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
22265 diff -Nru a/drivers/ieee1394/csr.c b/drivers/ieee1394/csr.c
22266 --- a/drivers/ieee1394/csr.c    Wed Aug 20 14:21:56 2003
22267 +++ b/drivers/ieee1394/csr.c    Mon Sep  1 17:00:00 2003
22268 @@ -21,6 +21,7 @@
22269  #include <linux/module.h>
22270  #include <linux/moduleparam.h>
22271  #include <linux/param.h>
22272 +#include <linux/spinlock.h>
22273  
22274  #include "ieee1394_types.h"
22275  #include "hosts.h"
22276 diff -Nru a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
22277 --- a/drivers/ieee1394/eth1394.c        Tue Aug 19 20:56:01 2003
22278 +++ b/drivers/ieee1394/eth1394.c        Mon Sep  1 17:00:00 2003
22279 @@ -89,7 +89,7 @@
22280  #define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__)
22281  
22282  static char version[] __devinitdata =
22283 -       "$Rev: 1020 $ Ben Collins <bcollins@debian.org>";
22284 +       "$Rev: 1043 $ Ben Collins <bcollins@debian.org>";
22285  
22286  struct fragment_info {
22287         struct list_head list;
22288 @@ -1349,21 +1349,20 @@
22289                                                ptask->dest_node,
22290                                                ptask->addr, ptask->skb->data,
22291                                                tx_len)) {
22292 -               goto fail;
22293 +               free_hpsb_packet(packet);
22294 +               return -1;
22295         }
22296  
22297         ptask->packet = packet;
22298         hpsb_set_packet_complete_task(ptask->packet, ether1394_complete_cb,
22299                                       ptask);
22300  
22301 -       if (hpsb_send_packet(packet))
22302 -               return 0;
22303 -
22304 -fail:
22305 -       if (packet)
22306 +       if (!hpsb_send_packet(packet)) {
22307                 ether1394_free_packet(packet);
22308 +               return -1;
22309 +       }
22310  
22311 -       return -1;
22312 +       return 0;
22313  }
22314  
22315  
22316 @@ -1600,7 +1599,7 @@
22317                 case ETHTOOL_GDRVINFO: {
22318                         struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
22319                         strcpy (info.driver, driver_name);
22320 -                       strcpy (info.version, "$Rev: 1020 $");
22321 +                       strcpy (info.version, "$Rev: 1043 $");
22322                         /* FIXME XXX provide sane businfo */
22323                         strcpy (info.bus_info, "ieee1394");
22324                         if (copy_to_user (useraddr, &info, sizeof (info)))
22325 diff -Nru a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
22326 --- a/drivers/ieee1394/ieee1394_core.c  Sun Aug  3 17:00:00 2003
22327 +++ b/drivers/ieee1394/ieee1394_core.c  Mon Sep  1 17:00:00 2003
22328 @@ -1124,7 +1124,7 @@
22329            to get the index of the ieee1394_driver
22330            we want */
22331  
22332 -       blocknum = (minor(inode->i_rdev) >> 4) & 0xF;
22333 +       blocknum = (iminor(inode) >> 4) & 0xF;
22334  
22335         /* look up the driver */
22336  
22337 @@ -1237,6 +1237,7 @@
22338  EXPORT_SYMBOL(hpsb_free_tlabel);
22339  EXPORT_SYMBOL(hpsb_make_readpacket);
22340  EXPORT_SYMBOL(hpsb_make_writepacket);
22341 +EXPORT_SYMBOL(hpsb_make_streampacket);
22342  EXPORT_SYMBOL(hpsb_make_lockpacket);
22343  EXPORT_SYMBOL(hpsb_make_lock64packet);
22344  EXPORT_SYMBOL(hpsb_make_phypacket);
22345 diff -Nru a/drivers/ieee1394/ieee1394_core.h b/drivers/ieee1394/ieee1394_core.h
22346 --- a/drivers/ieee1394/ieee1394_core.h  Thu Jul 24 17:00:00 2003
22347 +++ b/drivers/ieee1394/ieee1394_core.h  Tue Aug 26 09:25:41 2003
22348 @@ -202,7 +202,7 @@
22349  /* return the index (within a minor number block) of a file */
22350  static inline unsigned char ieee1394_file_to_instance(struct file *file)
22351  {
22352 -       unsigned char minor = minor(file->f_dentry->d_inode->i_rdev);
22353 +       unsigned char minor = iminor(file->f_dentry->d_inode);
22354         
22355         /* return lower 4 bits */
22356         return minor & 0xF;
22357 diff -Nru a/drivers/ieee1394/ieee1394_transactions.c b/drivers/ieee1394/ieee1394_transactions.c
22358 --- a/drivers/ieee1394/ieee1394_transactions.c  Tue Aug  5 10:11:00 2003
22359 +++ b/drivers/ieee1394/ieee1394_transactions.c  Mon Sep  1 17:00:00 2003
22360 @@ -104,7 +104,7 @@
22361                                      int channel, int tag, int sync)
22362  {
22363         packet->header[0] = (length << 16) | (tag << 14) | (channel << 8)
22364 -               | (TCODE_STREAM_DATA << 4) | sync;
22365 +                         | (TCODE_STREAM_DATA << 4) | sync;
22366  
22367         packet->header_size = 4;
22368         packet->data_size = length;
22369 @@ -317,6 +317,35 @@
22370         return packet;
22371  }
22372  
22373 +struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 *buffer, int length,
22374 +                                           int channel, int tag, int sync)
22375 +{
22376 +       struct hpsb_packet *packet;
22377 +
22378 +       if (length == 0)
22379 +               return NULL;
22380 +
22381 +       packet = alloc_hpsb_packet(length + (length % 4 ? 4 - (length % 4) : 0));
22382 +       if (!packet)
22383 +               return NULL;
22384 +
22385 +       if (length % 4) { /* zero padding bytes */
22386 +               packet->data[length >> 2] = 0;
22387 +       }
22388 +       packet->host = host;
22389 +    
22390 +       if (hpsb_get_tlabel(packet)) {
22391 +               free_hpsb_packet(packet);
22392 +               return NULL;
22393 +       }
22394 +
22395 +       fill_async_stream_packet(packet, length, channel, tag, sync);
22396 +       if (buffer)
22397 +               memcpy(packet->data, buffer, length);
22398 +
22399 +       return packet;
22400 +}
22401 +
22402  struct hpsb_packet *hpsb_make_lockpacket(struct hpsb_host *host, nodeid_t node,
22403                                           u64 addr, int extcode, quadlet_t *data,
22404                                          quadlet_t arg)
22405 @@ -580,25 +609,18 @@
22406         u16 specifier_id_hi = (specifier_id & 0x00ffff00) >> 8;
22407         u8 specifier_id_lo = specifier_id & 0xff;
22408  
22409 -       HPSB_VERBOSE("Send GASP: channel = %d, length = %d", channel, length);
22410 +       HPSB_VERBOSE("Send GASP: channel = %d, length = %Zd", channel, length);
22411  
22412         length += 8;
22413 -
22414 -       packet = alloc_hpsb_packet(length + (length % 4 ? 4 - (length % 4) : 0));
22415 +    
22416 +       packet = hpsb_make_streampacket(host, NULL, length, channel, 3, 0);
22417         if (!packet)
22418                 return -ENOMEM;
22419  
22420 -       if (length % 4) {
22421 -               packet->data[length / 4] = 0;
22422 -       }
22423 -
22424 -       packet->host = host;
22425 -       fill_async_stream_packet(packet, length, channel, 3, 0);
22426 -        
22427         packet->data[0] = cpu_to_be32((host->node_id << 16) | specifier_id_hi);
22428         packet->data[1] = cpu_to_be32((specifier_id_lo << 24) | (version & 0x00ffffff));
22429  
22430 -       memcpy(&(packet->data[2]), buffer, length - 4);
22431 +       memcpy(&(packet->data[2]), buffer, length - 8);
22432  
22433         packet->generation = generation;
22434  
22435 diff -Nru a/drivers/ieee1394/ieee1394_transactions.h b/drivers/ieee1394/ieee1394_transactions.h
22436 --- a/drivers/ieee1394/ieee1394_transactions.h  Sun Aug  3 17:00:00 2003
22437 +++ b/drivers/ieee1394/ieee1394_transactions.h  Mon Sep  1 17:00:00 2003
22438 @@ -25,6 +25,8 @@
22439                                         int tag, int sync);
22440  struct hpsb_packet *hpsb_make_writepacket (struct hpsb_host *host, nodeid_t node,
22441                                            u64 addr, quadlet_t *buffer, size_t length);
22442 +struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 *buffer,
22443 +                                           int length, int channel, int tag, int sync);
22444  
22445  /*
22446   * hpsb_packet_success - Make sense of the ack and reply codes and
22447 diff -Nru a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
22448 --- a/drivers/ieee1394/nodemgr.c        Sat Aug 16 05:08:09 2003
22449 +++ b/drivers/ieee1394/nodemgr.c        Mon Sep  1 17:00:00 2003
22450 @@ -1304,12 +1304,14 @@
22451                  * unregister all the unit directories. */
22452                 nodemgr_remove_node_uds(ne);
22453  
22454 +               /* With all the ud's gone, mark the generation current,
22455 +                * this way the probe will succeed. */
22456 +               ne->generation = generation;
22457 +
22458                 /* This will re-register our unitdir's */
22459                 nodemgr_process_config_rom (hi, ne, busoptions);
22460 -       }
22461 -
22462 -       /* Since that's done, we can declare this record current */
22463 -       ne->generation = generation;
22464 +       } else
22465 +               ne->generation = generation;
22466  
22467         /* Update unit_dirs with attached drivers */
22468         bus_for_each_dev(&ieee1394_bus_type, NULL, ne,
22469 diff -Nru a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
22470 --- a/drivers/ieee1394/ohci1394.c       Sun Aug  3 17:00:00 2003
22471 +++ b/drivers/ieee1394/ohci1394.c       Mon Sep  1 17:00:00 2003
22472 @@ -161,7 +161,7 @@
22473  printk(level "%s_%d: " fmt "\n" , OHCI1394_DRIVER_NAME, card , ## args)
22474  
22475  static char version[] __devinitdata =
22476 -       "$Rev: 1023 $ Ben Collins <bcollins@debian.org>";
22477 +       "$Rev: 1045 $ Ben Collins <bcollins@debian.org>";
22478  
22479  /* Module Parameters */
22480  static int phys_dma = 1;
22481 @@ -1451,7 +1451,7 @@
22482         if (sync != -1) {
22483                 /* set sync flag on first DMA descriptor */
22484                 struct dma_cmd *cmd = &recv->block[recv->block_dma];
22485 -               cmd->control |= DMA_CTL_WAIT;
22486 +               cmd->control |= cpu_to_le32(DMA_CTL_WAIT);
22487  
22488                 /* match sync field */
22489                 contextMatch |= (sync&0xf)<<8;
22490 @@ -1675,10 +1675,10 @@
22491                 struct dma_cmd *im = &recv->block[recv->block_dma];
22492                 
22493                 /* check the DMA descriptor for new writes to xferStatus */
22494 -               u16 xferstatus = im->status >> 16;
22495 +               u16 xferstatus = le32_to_cpu(im->status) >> 16;
22496                 
22497                 /* rescount is the number of bytes *remaining to be written* in the block */
22498 -               u16 rescount = im->status & 0xFFFF;
22499 +               u16 rescount = le32_to_cpu(im->status) & 0xFFFF;
22500  
22501                 unsigned char event = xferstatus & 0x1F;
22502  
22503 diff -Nru a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c
22504 --- a/drivers/ieee1394/pcilynx.c        Sat Aug 16 05:08:53 2003
22505 +++ b/drivers/ieee1394/pcilynx.c        Tue Aug 26 09:25:41 2003
22506 @@ -875,7 +875,7 @@
22507  
22508  static int mem_open(struct inode *inode, struct file *file)
22509  {
22510 -        int cid = minor(inode->i_rdev);
22511 +        int cid = iminor(inode);
22512          enum { t_rom, t_aux, t_ram } type;
22513          struct memdata *md;
22514          
22515 diff -Nru a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
22516 --- a/drivers/ieee1394/raw1394.c        Sun Aug  3 17:00:00 2003
22517 +++ b/drivers/ieee1394/raw1394.c        Mon Sep  1 17:00:00 2003
22518 @@ -180,6 +180,7 @@
22519  
22520          if ((req->req.type == RAW1394_REQ_ASYNC_READ) ||
22521             (req->req.type == RAW1394_REQ_ASYNC_WRITE) ||
22522 +           (req->req.type == RAW1394_REQ_ASYNC_STREAM) ||
22523             (req->req.type == RAW1394_REQ_LOCK) ||
22524             (req->req.type == RAW1394_REQ_LOCK64))
22525                  hpsb_free_tlabel(packet);
22526 @@ -689,6 +690,21 @@
22527                 req->req.length = 0;
22528             break;
22529  
22530 +       case RAW1394_REQ_ASYNC_STREAM:
22531 +               DBGMSG("stream_request called");
22532 +
22533 +               packet = hpsb_make_streampacket(fi->host, NULL, req->req.length, node & 0x3f/*channel*/,
22534 +                                        (req->req.misc >> 16) & 0x3, req->req.misc & 0xf);
22535 +               if (!packet)
22536 +                       return -ENOMEM;
22537 +
22538 +               if (copy_from_user(packet->data, int2ptr(req->req.sendb),
22539 +                                  req->req.length))
22540 +                       req->req.error = RAW1394_ERROR_MEMFAULT;
22541 +                       
22542 +               req->req.length = 0;
22543 +               break;
22544 +
22545          case RAW1394_REQ_LOCK:
22546                  DBGMSG("lock_request called");
22547                  if ((req->req.misc == EXTCODE_FETCH_ADD)
22548 @@ -892,7 +908,7 @@
22549          struct arm_request_response *arm_req_resp = NULL;
22550  
22551          DBGMSG("arm_read  called by node: %X"
22552 -              "addr: %4.4x %8.8x length: %u", nodeid,
22553 +              "addr: %4.4x %8.8x length: %Zu", nodeid,
22554                (u16) ((addr >>32) & 0xFFFF), (u32) (addr & 0xFFFFFFFF),
22555                length);
22556          spin_lock(&host_info_lock);
22557 @@ -1028,7 +1044,7 @@
22558          struct arm_request_response *arm_req_resp = NULL;
22559  
22560          DBGMSG("arm_write called by node: %X"
22561 -              "addr: %4.4x %8.8x length: %u", nodeid,
22562 +              "addr: %4.4x %8.8x length: %Zu", nodeid,
22563                (u16) ((addr >>32) & 0xFFFF), (u32) (addr & 0xFFFFFFFF),
22564                length);
22565          spin_lock(&host_info_lock);
22566 @@ -1566,8 +1582,8 @@
22567                req->req.length, ((req->req.misc >> 8) & 0xFF),
22568                (req->req.misc & 0xFF),((req->req.misc >> 16) & 0xFFFF));
22569          /* check addressrange */
22570 -        if ((((req->req.address) & ~((u64)0xFFFFFFFFFFFFLL)) != 0) ||
22571 -                (((req->req.address + req->req.length) & ~((u64)0xFFFFFFFFFFFFLL)) != 0)) {
22572 +        if ((((req->req.address) & ~(0xFFFFFFFFFFFFULL)) != 0) ||
22573 +                (((req->req.address + req->req.length) & ~(0xFFFFFFFFFFFFULL)) != 0)) {
22574                  req->req.length = 0;
22575                  return (-EINVAL);
22576          }
22577 @@ -1578,7 +1594,7 @@
22578                  return (-ENOMEM);
22579          } 
22580          /* allocation of addr_space_buffer */
22581 -        addr->addr_space_buffer = (u8 *)kmalloc(req->req.length,SLAB_KERNEL);
22582 +        addr->addr_space_buffer = (u8 *)vmalloc(req->req.length);
22583          if (!(addr->addr_space_buffer)) {
22584                  kfree(addr);
22585                  req->req.length = 0;
22586 @@ -1592,7 +1608,7 @@
22587                  /* init: user -> kernel */
22588                  if (copy_from_user(addr->addr_space_buffer,int2ptr(req->req.sendb),
22589                          req->req.length)) {
22590 -                        kfree(addr->addr_space_buffer);
22591 +                        vfree(addr->addr_space_buffer);
22592                          kfree(addr);
22593                          return (-EFAULT);
22594                  }
22595 @@ -1633,7 +1649,7 @@
22596          }
22597          if (same_host) {
22598                  /* addressrange occupied by same host */
22599 -                kfree(addr->addr_space_buffer);
22600 +                vfree(addr->addr_space_buffer);
22601                  kfree(addr);
22602                  spin_unlock_irqrestore(&host_info_lock, flags);
22603                  return (-EALREADY);
22604 @@ -1668,7 +1684,7 @@
22605                          int2ptr(&addr->start),sizeof(u64))) {
22606                          printk(KERN_ERR "raw1394: arm_register failed "
22607                                " address-range-entry is invalid -> EFAULT !!!\n");
22608 -                        kfree(addr->addr_space_buffer);
22609 +                        vfree(addr->addr_space_buffer);
22610                          kfree(addr);
22611                          spin_unlock_irqrestore(&host_info_lock, flags);
22612                          return (-EFAULT);
22613 @@ -1686,7 +1702,7 @@
22614                 list_add_tail(&addr->addr_list, &fi->addr_list);
22615          } else {
22616                  DBGMSG("arm_register failed errno: %d \n",retval);
22617 -                kfree(addr->addr_space_buffer);
22618 +                vfree(addr->addr_space_buffer);
22619                  kfree(addr);
22620                  spin_unlock_irqrestore(&host_info_lock, flags);
22621                  return (-EALREADY); 
22622 @@ -1760,7 +1776,7 @@
22623          if (another_host) {
22624                  DBGMSG("delete entry from list -> success");
22625                  list_del(&addr->addr_list);
22626 -                kfree(addr->addr_space_buffer);
22627 +                vfree(addr->addr_space_buffer);
22628                  kfree(addr);
22629                  free_pending_request(req); /* immediate success or fail */
22630                  spin_unlock_irqrestore(&host_info_lock, flags);
22631 @@ -1775,7 +1791,7 @@
22632          DBGMSG("delete entry from list -> success");
22633          list_del(&addr->addr_list);
22634          spin_unlock_irqrestore(&host_info_lock, flags);
22635 -        kfree(addr->addr_space_buffer);
22636 +        vfree(addr->addr_space_buffer);
22637          kfree(addr);
22638          free_pending_request(req); /* immediate success or fail */
22639          return sizeof(struct raw1394_request);
22640 @@ -2440,7 +2456,7 @@
22641                  }
22642                  DBGMSG("raw1394_release: delete addr_entry from list");
22643                  list_del(&addr->addr_list);
22644 -                kfree(addr->addr_space_buffer);
22645 +                vfree(addr->addr_space_buffer);
22646                  kfree(addr);
22647          } /* while */
22648          spin_unlock_irq(&host_info_lock);
22649 diff -Nru a/drivers/ieee1394/raw1394.h b/drivers/ieee1394/raw1394.h
22650 --- a/drivers/ieee1394/raw1394.h        Wed Feb 12 20:57:18 2003
22651 +++ b/drivers/ieee1394/raw1394.h        Mon Sep  1 17:00:00 2003
22652 @@ -19,6 +19,7 @@
22653  #define RAW1394_REQ_LOCK64          103
22654  #define RAW1394_REQ_ISO_SEND        104
22655  #define RAW1394_REQ_ASYNC_SEND      105
22656 +#define RAW1394_REQ_ASYNC_STREAM    106
22657  
22658  #define RAW1394_REQ_ISO_LISTEN      200
22659  #define RAW1394_REQ_FCP_LISTEN      201
22660 diff -Nru a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
22661 --- a/drivers/ieee1394/sbp2.c   Sun Aug 10 22:11:01 2003
22662 +++ b/drivers/ieee1394/sbp2.c   Mon Sep  1 17:00:00 2003
22663 @@ -80,7 +80,7 @@
22664  #include "sbp2.h"
22665  
22666  static char version[] __devinitdata =
22667 -       "$Rev: 1018 $ Ben Collins <bcollins@debian.org>";
22668 +       "$Rev: 1034 $ Ben Collins <bcollins@debian.org>";
22669  
22670  /*
22671   * Module load parameter definitions
22672 @@ -1002,9 +1002,8 @@
22673         sbp2scsi_complete_all_commands(scsi_id, DID_NO_CONNECT);
22674  
22675         /* Remove it from the scsi layer now */
22676 -       if (sdev) {
22677 +       if (sdev)
22678                 scsi_remove_device(sdev);
22679 -       }
22680  
22681         sbp2util_remove_command_orb_pool(scsi_id);
22682  
22683 diff -Nru a/drivers/input/evdev.c b/drivers/input/evdev.c
22684 --- a/drivers/input/evdev.c     Tue Aug 12 16:21:11 2003
22685 +++ b/drivers/input/evdev.c     Sun Aug 31 16:14:28 2003
22686 @@ -122,7 +122,7 @@
22687  static int evdev_open(struct inode * inode, struct file * file)
22688  {
22689         struct evdev_list *list;
22690 -       int i = minor(inode->i_rdev) - EVDEV_MINOR_BASE;
22691 +       int i = iminor(inode) - EVDEV_MINOR_BASE;
22692         int accept_err;
22693  
22694         if (i >= EVDEV_MINORS || !evdev_table[i])
22695 @@ -305,6 +305,7 @@
22696                                         case EV_KEY: bits = dev->keybit; len = KEY_MAX; break;
22697                                         case EV_REL: bits = dev->relbit; len = REL_MAX; break;
22698                                         case EV_ABS: bits = dev->absbit; len = ABS_MAX; break;
22699 +                                       case EV_MSC: bits = dev->mscbit; len = MSC_MAX; break;
22700                                         case EV_LED: bits = dev->ledbit; len = LED_MAX; break;
22701                                         case EV_SND: bits = dev->sndbit; len = SND_MAX; break;
22702                                         case EV_FF:  bits = dev->ffbit;  len = FF_MAX;  break;
22703 diff -Nru a/drivers/input/input.c b/drivers/input/input.c
22704 --- a/drivers/input/input.c     Tue Aug 12 13:29:25 2003
22705 +++ b/drivers/input/input.c     Tue Aug 26 09:25:41 2003
22706 @@ -280,7 +280,7 @@
22707                         if (id->id.product != dev->id.product)
22708                                 continue;
22709                 
22710 -               if (id->flags & INPUT_DEVICE_ID_MATCH_BUS)
22711 +               if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION)
22712                         if (id->id.version != dev->id.version)
22713                                 continue;
22714  
22715 @@ -527,7 +527,7 @@
22716  
22717  static int input_open_file(struct inode *inode, struct file *file)
22718  {
22719 -       struct input_handler *handler = input_table[minor(inode->i_rdev) >> 5];
22720 +       struct input_handler *handler = input_table[iminor(inode) >> 5];
22721         struct file_operations *old_fops, *new_fops = NULL;
22722         int err;
22723  
22724 diff -Nru a/drivers/input/joydev.c b/drivers/input/joydev.c
22725 --- a/drivers/input/joydev.c    Fri May  2 06:55:04 2003
22726 +++ b/drivers/input/joydev.c    Tue Aug 26 09:25:41 2003
22727 @@ -170,7 +170,7 @@
22728  static int joydev_open(struct inode *inode, struct file *file)
22729  {
22730         struct joydev_list *list;
22731 -       int i = minor(inode->i_rdev) - JOYDEV_MINOR_BASE;
22732 +       int i = iminor(inode) - JOYDEV_MINOR_BASE;
22733  
22734         if (i >= JOYDEV_MINORS || !joydev_table[i])
22735                 return -ENODEV;
22736 diff -Nru a/drivers/input/mousedev.c b/drivers/input/mousedev.c
22737 --- a/drivers/input/mousedev.c  Fri May  2 06:55:04 2003
22738 +++ b/drivers/input/mousedev.c  Tue Aug 26 09:25:41 2003
22739 @@ -228,11 +228,11 @@
22740         int i;
22741  
22742  #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
22743 -       if (major(inode->i_rdev) == MISC_MAJOR)
22744 +       if (imajor(inode) == MISC_MAJOR)
22745                 i = MOUSEDEV_MIX;
22746         else
22747  #endif
22748 -               i = minor(inode->i_rdev) - MOUSEDEV_MINOR_BASE;
22749 +               i = iminor(inode) - MOUSEDEV_MINOR_BASE;
22750  
22751         if (i >= MOUSEDEV_MINORS || !mousedev_table[i])
22752                 return -ENODEV;
22753 diff -Nru a/drivers/input/serio/sa1111ps2.c b/drivers/input/serio/sa1111ps2.c
22754 --- a/drivers/input/serio/sa1111ps2.c   Sat May 17 07:47:27 2003
22755 +++ b/drivers/input/serio/sa1111ps2.c   Sun Aug 24 07:45:05 2003
22756 @@ -62,9 +62,9 @@
22757  
22758                 serio_interrupt(&ps2if->io, scancode, flag, regs);
22759  
22760 -                       status = sa1111_readl(ps2if->base + SA1111_PS2STAT);
22761 +               status = sa1111_readl(ps2if->base + SA1111_PS2STAT);
22762  
22763 -                       handled = IRQ_HANDLED;
22764 +               handled = IRQ_HANDLED;
22765          }
22766  
22767          return handled;
22768 @@ -232,9 +232,8 @@
22769  /*
22770   * Add one device to this driver.
22771   */
22772 -static int ps2_probe(struct device *dev)
22773 +static int ps2_probe(struct sa1111_dev *dev)
22774  {
22775 -       struct sa1111_dev *sadev = SA1111_DEV(dev);
22776         struct ps2if *ps2if;
22777         int ret;
22778  
22779 @@ -249,20 +248,20 @@
22780         ps2if->io.write         = ps2_write;
22781         ps2if->io.open          = ps2_open;
22782         ps2if->io.close         = ps2_close;
22783 -       ps2if->io.name          = dev->name;
22784 -       ps2if->io.phys          = dev->bus_id;
22785 +       ps2if->io.name          = dev->dev.bus_id;
22786 +       ps2if->io.phys          = dev->dev.bus_id;
22787         ps2if->io.driver        = ps2if;
22788 -       ps2if->dev              = sadev;
22789 -       dev->driver_data        = ps2if;
22790 +       ps2if->dev              = dev;
22791 +       sa1111_set_drvdata(dev, ps2if);
22792  
22793         spin_lock_init(&ps2if->lock);
22794  
22795         /*
22796          * Request the physical region for this PS2 port.
22797          */
22798 -       if (!request_mem_region(sadev->res.start,
22799 -                               sadev->res.end - sadev->res.start + 1,
22800 -                               SA1111_DRIVER_NAME(sadev))) {
22801 +       if (!request_mem_region(dev->res.start,
22802 +                               dev->res.end - dev->res.start + 1,
22803 +                               SA1111_DRIVER_NAME(dev))) {
22804                 ret = -EBUSY;
22805                 goto free;
22806         }
22807 @@ -270,7 +269,7 @@
22808         /*
22809          * Our parent device has already mapped the region.
22810          */
22811 -       ps2if->base = (unsigned long)sadev->mapbase;
22812 +       ps2if->base = (unsigned long)dev->mapbase;
22813  
22814         sa1111_enable_device(ps2if->dev);
22815  
22816 @@ -301,10 +300,10 @@
22817  
22818   out:
22819         sa1111_disable_device(ps2if->dev);
22820 -       release_mem_region(sadev->res.start,
22821 -                          sadev->res.end - sadev->res.start + 1);
22822 +       release_mem_region(dev->res.start,
22823 +                          dev->res.end - dev->res.start + 1);
22824   free:
22825 -       dev->driver_data = NULL;
22826 +       sa1111_set_drvdata(dev, NULL);
22827         kfree(ps2if);
22828         return ret;
22829  }
22830 @@ -312,31 +311,17 @@
22831  /*
22832   * Remove one device from this driver.
22833   */
22834 -static int ps2_remove(struct device *dev)
22835 +static int ps2_remove(struct sa1111_dev *dev)
22836  {
22837 -       struct ps2if *ps2if = dev->driver_data;
22838 -       struct sa1111_dev *sadev = SA1111_DEV(dev);
22839 +       struct ps2if *ps2if = sa1111_get_drvdata(dev);
22840  
22841         serio_unregister_port(&ps2if->io);
22842 -       release_mem_region(sadev->res.start,
22843 -                          sadev->res.end - sadev->res.start + 1);
22844 -       kfree(ps2if);
22845 -
22846 -       dev->driver_data = NULL;
22847 -
22848 -       return 0;
22849 -}
22850 +       release_mem_region(dev->res.start,
22851 +                          dev->res.end - dev->res.start + 1);
22852 +       sa1111_set_drvdata(dev, NULL);
22853  
22854 -/*
22855 - * We should probably do something here, but what?
22856 - */
22857 -static int ps2_suspend(struct device *dev, u32 state, u32 level)
22858 -{
22859 -       return 0;
22860 -}
22861 +       kfree(ps2if);
22862  
22863 -static int ps2_resume(struct device *dev, u32 level)
22864 -{
22865         return 0;
22866  }
22867  
22868 @@ -345,24 +330,21 @@
22869   */
22870  static struct sa1111_driver ps2_driver = {
22871         .drv = {
22872 -               .name           = "sa1111-ps2",
22873 -               .bus            = &sa1111_bus_type,
22874 -               .probe          = ps2_probe,
22875 -               .remove         = ps2_remove,
22876 -               .suspend        = ps2_suspend,
22877 -               .resume         = ps2_resume,
22878 +               .name   = "sa1111-ps2",
22879         },
22880 -       .devid                  = SA1111_DEVID_PS2,
22881 +       .devid          = SA1111_DEVID_PS2,
22882 +       .probe          = ps2_probe,
22883 +       .remove         = ps2_remove,
22884  };
22885  
22886  static int __init ps2_init(void)
22887  {
22888 -       return driver_register(&ps2_driver.drv);
22889 +       return sa1111_driver_register(&ps2_driver);
22890  }
22891  
22892  static void __exit ps2_exit(void)
22893  {
22894 -       driver_unregister(&ps2_driver.drv);
22895 +       sa1111_driver_unregister(&ps2_driver);
22896  }
22897  
22898  module_init(ps2_init);
22899 diff -Nru a/drivers/input/tsdev.c b/drivers/input/tsdev.c
22900 --- a/drivers/input/tsdev.c     Fri May  2 06:55:04 2003
22901 +++ b/drivers/input/tsdev.c     Tue Aug 26 09:25:41 2003
22902 @@ -96,7 +96,7 @@
22903  
22904  static int tsdev_open(struct inode *inode, struct file *file)
22905  {
22906 -       int i = minor(inode->i_rdev) - TSDEV_MINOR_BASE;
22907 +       int i = iminor(inode) - TSDEV_MINOR_BASE;
22908         struct tsdev_list *list;
22909  
22910         if (i >= TSDEV_MINORS || !tsdev_table[i])
22911 diff -Nru a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
22912 --- a/drivers/isdn/capi/capi.c  Wed Jun 11 12:32:56 2003
22913 +++ b/drivers/isdn/capi/capi.c  Tue Aug 26 09:25:41 2003
22914 @@ -964,7 +964,7 @@
22915  {
22916         struct capiminor *mp;
22917  
22918 -       if ((mp = capiminor_find(minor(file->f_dentry->d_inode->i_rdev))) == 0)
22919 +       if ((mp = capiminor_find(iminor(file->f_dentry->d_inode))) == 0)
22920                 return -ENXIO;
22921         if (mp->nccip == 0)
22922                 return -ENXIO;
22923 diff -Nru a/drivers/isdn/hardware/eicon/divasi.c b/drivers/isdn/hardware/eicon/divasi.c
22924 --- a/drivers/isdn/hardware/eicon/divasi.c      Mon Jul 21 12:08:32 2003
22925 +++ b/drivers/isdn/hardware/eicon/divasi.c      Tue Aug 26 09:25:41 2003
22926 @@ -432,7 +432,7 @@
22927  
22928  static int um_idi_release(struct inode *inode, struct file *file)
22929  {
22930 -       unsigned int adapter_nr = minor(inode->i_rdev);
22931 +       unsigned int adapter_nr = iminor(inode);
22932         int ret = 0;
22933  
22934         if (!(file->private_data)) {
22935 diff -Nru a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
22936 --- a/drivers/isdn/i4l/isdn_common.c    Mon Jul 21 11:39:14 2003
22937 +++ b/drivers/isdn/i4l/isdn_common.c    Tue Aug 26 09:25:41 2003
22938 @@ -1432,7 +1432,7 @@
22939  static int
22940  isdn_ctrl_open(struct inode *ino, struct file *file)
22941  {
22942 -       unsigned int minor = minor(ino->i_rdev);
22943 +       unsigned int minor = iminor(ino);
22944         struct isdn_slot *slot = get_slot_by_minor(minor - ISDN_MINOR_CTRL);
22945  
22946         if (!slot)
22947 @@ -1795,7 +1795,7 @@
22948  static int
22949  isdn_open(struct inode * inode, struct file * file)
22950  {
22951 -       int minor = minor(inode->i_rdev);
22952 +       int minor = iminor(inode);
22953         int err = -ENODEV;
22954         struct file_operations *old_fops, *new_fops = NULL;
22955         
22956 diff -Nru a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
22957 --- a/drivers/isdn/i4l/isdn_ppp.c       Tue Jul 15 10:01:29 2003
22958 +++ b/drivers/isdn/i4l/isdn_ppp.c       Tue Aug 26 09:25:41 2003
22959 @@ -119,7 +119,7 @@
22960  ipppd_open(struct inode *ino, struct file *file)
22961  {
22962         unsigned long flags;
22963 -       unsigned int minor = minor(ino->i_rdev) - ISDN_MINOR_PPP;
22964 +       unsigned int minor = iminor(ino) - ISDN_MINOR_PPP;
22965         struct ipppd *ipppd;
22966  
22967         ipppd = kmalloc(sizeof(*ipppd), GFP_KERNEL);
22968 diff -Nru a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
22969 --- a/drivers/macintosh/adb.c   Sat Jun  7 00:45:03 2003
22970 +++ b/drivers/macintosh/adb.c   Tue Aug 26 09:25:41 2003
22971 @@ -712,7 +712,7 @@
22972  {
22973         struct adbdev_state *state;
22974  
22975 -       if (minor(inode->i_rdev) > 0 || adb_controller == NULL)
22976 +       if (iminor(inode) > 0 || adb_controller == NULL)
22977                 return -ENXIO;
22978         state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL);
22979         if (state == 0)
22980 diff -Nru a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
22981 --- a/drivers/macintosh/macio_asic.c    Sat Aug 16 11:47:51 2003
22982 +++ b/drivers/macintosh/macio_asic.c    Tue Aug 26 06:35:38 2003
22983 @@ -23,6 +23,8 @@
22984  #include <asm/prom.h>
22985  #include <asm/pci-bridge.h>
22986  
22987 +static struct macio_chip      *macio_on_hold;
22988 +
22989  static int
22990  macio_bus_match(struct device *dev, struct device_driver *drv) 
22991  {
22992 @@ -36,21 +38,27 @@
22993         return of_match_device(matches, &macio_dev->ofdev) != NULL;
22994  }
22995  
22996 -struct bus_type macio_bus_type = {
22997 -       name:   "macio",
22998 -       match:  macio_bus_match,
22999 -};
23000 +struct macio_dev *macio_dev_get(struct macio_dev *dev)
23001 +{
23002 +       struct device *tmp;
23003  
23004 -static int __init
23005 -macio_bus_driver_init(void)
23006 +       if (!dev)
23007 +               return NULL;
23008 +       tmp = get_device(&dev->ofdev.dev);
23009 +       if (tmp)
23010 +               return to_macio_device(tmp);
23011 +       else
23012 +               return NULL;
23013 +}
23014 +
23015 +void macio_dev_put(struct macio_dev *dev)
23016  {
23017 -       return bus_register(&macio_bus_type);
23018 +       if (dev)
23019 +               put_device(&dev->ofdev.dev);
23020  }
23021  
23022 -postcore_initcall(macio_bus_driver_init);
23023  
23024 -static int
23025 -macio_device_probe(struct device *dev)
23026 +static int macio_device_probe(struct device *dev)
23027  {
23028         int error = -ENODEV;
23029         struct macio_driver *drv;
23030 @@ -63,55 +71,89 @@
23031         if (!drv->probe)
23032                 return error;
23033  
23034 -/*     if (!try_module_get(driver->owner)) {
23035 -               printk(KERN_ERR "Can't get a module reference for %s\n", driver->name);
23036 -               return error;
23037 -       }
23038 -*/
23039 +       macio_dev_get(macio_dev);
23040 +
23041         match = of_match_device(drv->match_table, &macio_dev->ofdev);
23042         if (match)
23043                 error = drv->probe(macio_dev, match);
23044 -/*
23045 -       module_put(driver->owner);
23046 -*/     
23047 +       if (error)
23048 +               macio_dev_put(macio_dev);
23049 +
23050         return error;
23051  }
23052  
23053 -static int
23054 -macio_device_remove(struct device *dev)
23055 +static int macio_device_remove(struct device *dev)
23056  {
23057         struct macio_dev * macio_dev = to_macio_device(dev);
23058         struct macio_driver * drv = to_macio_driver(macio_dev->ofdev.dev.driver);
23059  
23060         if (drv && drv->remove)
23061                 drv->remove(macio_dev);
23062 +       macio_dev_put(macio_dev);
23063 +
23064         return 0;
23065  }
23066  
23067 -static int
23068 -macio_device_suspend(struct device *dev, u32 state, u32 level)
23069 +static int macio_device_suspend(struct device *dev, u32 state)
23070  {
23071         struct macio_dev * macio_dev = to_macio_device(dev);
23072 -       struct macio_driver * drv = to_macio_driver(macio_dev->ofdev.dev.driver);
23073 +       struct macio_driver * drv;
23074         int error = 0;
23075  
23076 -       if (drv && drv->suspend)
23077 -               error = drv->suspend(macio_dev, state, level);
23078 +       if (macio_dev->ofdev.dev.driver == NULL)
23079 +               return 0;
23080 +       drv = to_macio_driver(macio_dev->ofdev.dev.driver);
23081 +       if (drv->suspend)
23082 +               error = drv->suspend(macio_dev, state);
23083         return error;
23084  }
23085  
23086 -static int
23087 -macio_device_resume(struct device * dev, u32 level)
23088 +static int macio_device_resume(struct device * dev)
23089  {
23090         struct macio_dev * macio_dev = to_macio_device(dev);
23091 -       struct macio_driver * drv = to_macio_driver(macio_dev->ofdev.dev.driver);
23092 +       struct macio_driver * drv;
23093         int error = 0;
23094  
23095 -       if (drv && drv->resume)
23096 -               error = drv->resume(macio_dev, level);
23097 +       if (macio_dev->ofdev.dev.driver == NULL)
23098 +               return 0;
23099 +       drv = to_macio_driver(macio_dev->ofdev.dev.driver);
23100 +       if (drv->resume)
23101 +               error = drv->resume(macio_dev);
23102         return error;
23103  }
23104  
23105 +struct bus_type macio_bus_type = {
23106 +       .name   = "macio",
23107 +       .match  = macio_bus_match,
23108 +       .suspend        = macio_device_suspend,
23109 +       .resume = macio_device_resume,
23110 +};
23111 +
23112 +static int __init
23113 +macio_bus_driver_init(void)
23114 +{
23115 +       return bus_register(&macio_bus_type);
23116 +}
23117 +
23118 +postcore_initcall(macio_bus_driver_init);
23119 +
23120 +
23121 +/**
23122 + * macio_release_dev - free a macio device structure when all users of it are finished.
23123 + * @dev: device that's been disconnected
23124 + *
23125 + * Will be called only by the device core when all users of this macio device are
23126 + * done. This currently means never as we don't hot remove any macio device yet,
23127 + * though that will happen with mediabay based devices in a later implementation.
23128 + */
23129 +static void macio_release_dev(struct device *dev)
23130 +{
23131 +       struct macio_dev *mdev;
23132 +
23133 +        mdev = to_macio_device(dev);
23134 +       kfree(mdev);
23135 +}
23136 +
23137  /**
23138   * macio_add_one_device - Add one device from OF node to the device tree
23139   * @chip: pointer to the macio_chip holding the device
23140 @@ -121,13 +163,15 @@
23141   * When media-bay is changed to hotswap drivers, this function will
23142   * be exposed to the bay driver some way...
23143   */
23144 -static struct macio_dev *
23145 -macio_add_one_device(struct macio_chip *chip, struct device *parent,
23146 +static struct macio_dev * macio_add_one_device(struct macio_chip *chip, struct device *parent,
23147                      struct device_node *np, struct macio_dev *in_bay)
23148  {
23149         struct macio_dev *dev;
23150         u32 *reg;
23151         
23152 +       if (np == NULL)
23153 +               return NULL;
23154 +
23155         dev = kmalloc(sizeof(*dev), GFP_KERNEL);
23156         if (!dev)
23157                 return NULL;
23158 @@ -140,6 +184,7 @@
23159         dev->ofdev.dev.dma_mask = &dev->ofdev.dma_mask;
23160         dev->ofdev.dev.parent = parent;
23161         dev->ofdev.dev.bus = &macio_bus_type;
23162 +       dev->ofdev.dev.release = macio_release_dev;
23163  
23164         /* MacIO itself has a different reg, we use it's PCI base */
23165         if (np == chip->of_node) {
23166 @@ -164,8 +209,7 @@
23167         return dev;
23168  }
23169  
23170 -static int
23171 -macio_skip_device(struct device_node *np)
23172 +static int macio_skip_device(struct device_node *np)
23173  {
23174         if (strncmp(np->name, "battery", 7) == 0)
23175                 return 1;
23176 @@ -185,10 +229,9 @@
23177   * For now, childs of media-bay are added now as well. This will
23178   * change rsn though.
23179   */
23180 -static void
23181 -macio_pci_add_devices(struct macio_chip *chip)
23182 +static void macio_pci_add_devices(struct macio_chip *chip)
23183  {
23184 -       struct device_node *np;
23185 +       struct device_node *np, *pnode;
23186         struct macio_dev *rdev, *mdev, *mbdev = NULL, *sdev = NULL;
23187         struct device *parent = NULL;
23188         
23189 @@ -196,16 +239,23 @@
23190  #ifdef CONFIG_PCI
23191         if (chip->lbus.pdev)
23192                 parent = &chip->lbus.pdev->dev;
23193 -#endif         
23194 -       rdev = macio_add_one_device(chip, parent, chip->of_node, NULL);
23195 +#endif
23196 +       pnode = of_node_get(chip->of_node);
23197 +       if (pnode == NULL)
23198 +               return;
23199 +
23200 +       rdev = macio_add_one_device(chip, parent, pnode, NULL);
23201         if (rdev == NULL)
23202                 return;
23203  
23204         /* First scan 1st level */
23205 -       for (np = chip->of_node->child; np != NULL; np = np->sibling) {
23206 +       for (np = NULL; (np = of_get_next_child(pnode, np)) != NULL;) {
23207                 if (!macio_skip_device(np)) {
23208 +                       of_node_get(np);
23209                         mdev = macio_add_one_device(chip, &rdev->ofdev.dev, np, NULL);
23210 -                       if (strncmp(np->name, "media-bay", 9) == 0)
23211 +                       if (mdev == NULL)
23212 +                               of_node_put(np);
23213 +                       else if (strncmp(np->name, "media-bay", 9) == 0)
23214                                 mbdev = mdev;
23215                         else if (strncmp(np->name, "escc", 4) == 0)
23216                                 sdev = mdev;
23217 @@ -213,17 +263,21 @@
23218         }
23219  
23220         /* Add media bay devices if any */
23221 -       if (mbdev) {
23222 -               for (np = mbdev->ofdev.node->child; np != NULL; np = np->sibling)
23223 -                       if (!macio_skip_device(np))
23224 -                               macio_add_one_device(chip, &mbdev->ofdev.dev, np, mbdev);
23225 -       }
23226 +       if (mbdev)
23227 +               for (np = NULL; (np = of_get_next_child(mbdev->ofdev.node, np)) != NULL;)
23228 +                       if (!macio_skip_device(np)) {
23229 +                               of_node_get(np);
23230 +                               if (macio_add_one_device(chip, &mbdev->ofdev.dev, np, mbdev) == NULL)
23231 +                                       of_node_put(np);
23232 +                       }
23233         /* Add serial ports if any */
23234 -       if (sdev) {
23235 -               for (np = sdev->ofdev.node->child; np != NULL; np = np->sibling)
23236 -                       if (!macio_skip_device(np))
23237 -                               macio_add_one_device(chip, &sdev->ofdev.dev, np, NULL);
23238 -       }
23239 +       if (sdev)
23240 +               for (np = NULL; (np = of_get_next_child(sdev->ofdev.node, np)) != NULL;)
23241 +                       if (!macio_skip_device(np)) {
23242 +                               of_node_get(np);
23243 +                               if (macio_add_one_device(chip, &sdev->ofdev.dev, np, NULL) == NULL)
23244 +                                       of_node_put(np);
23245 +                       }
23246  }
23247  
23248  
23249 @@ -231,8 +285,7 @@
23250   * macio_register_driver - Registers a new MacIO device driver
23251   * @drv: pointer to the driver definition structure
23252   */
23253 -int
23254 -macio_register_driver(struct macio_driver *drv)
23255 +int macio_register_driver(struct macio_driver *drv)
23256  {
23257         int count = 0;
23258  
23259 @@ -240,8 +293,6 @@
23260         drv->driver.name = drv->name;
23261         drv->driver.bus = &macio_bus_type;
23262         drv->driver.probe = macio_device_probe;
23263 -       drv->driver.resume = macio_device_resume;
23264 -       drv->driver.suspend = macio_device_suspend;
23265         drv->driver.remove = macio_device_remove;
23266  
23267         /* register with core */
23268 @@ -253,16 +304,14 @@
23269   * macio_unregister_driver - Unregisters a new MacIO device driver
23270   * @drv: pointer to the driver definition structure
23271   */
23272 -void
23273 -macio_unregister_driver(struct macio_driver *drv)
23274 +void macio_unregister_driver(struct macio_driver *drv)
23275  {
23276         driver_unregister(&drv->driver);
23277  }
23278  
23279  #ifdef CONFIG_PCI
23280  
23281 -static int __devinit
23282 -macio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
23283 +static int __devinit macio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
23284  {
23285         struct device_node* np;
23286         struct macio_chip* chip;
23287 @@ -270,19 +319,27 @@
23288         if (ent->vendor != PCI_VENDOR_ID_APPLE)
23289                 return -ENODEV;
23290  
23291 +       /* Note regarding refcounting: We assume pci_device_to_OF_node() is ported
23292 +        * to new OF APIs and returns a node with refcount incremented. This isn't
23293 +        * the case today, but on the other hand ppc32 doesn't do refcounting. This
23294 +        * will have to be fixed when going to ppc64. --BenH.
23295 +        */
23296         np = pci_device_to_OF_node(pdev);
23297         if (np == NULL)
23298                 return -ENODEV;
23299  
23300 +       /* We also assume that pmac_feature will have done a get() on nodes stored
23301 +        * in the macio chips array
23302 +        */
23303         chip = macio_find(np, macio_unknown);
23304 +               of_node_put(np);
23305         if (chip == NULL)
23306                 return -ENODEV;
23307  
23308 -       /* XXX Need locking */
23309 +       /* XXX Need locking ??? */
23310         if (chip->lbus.pdev == NULL) {
23311                 chip->lbus.pdev = pdev;
23312                 chip->lbus.chip = chip;
23313 -//             INIT_LIST_HEAD(&chip->lbus.devices);
23314                 pci_set_drvdata(pdev, &chip->lbus);
23315                 pci_set_master(pdev);
23316         }
23317 @@ -290,13 +347,28 @@
23318         printk(KERN_INFO "MacIO PCI driver attached to %s chipset\n",
23319                 chip->name);
23320  
23321 +       /*
23322 +        * HACK ALERT: The WallStreet PowerBook and some OHare based machines
23323 +        * have 2 macio ASICs. I must probe the "main" one first or IDE ordering
23324 +        * will be incorrect. So I put on "hold" the second one since it seem to
23325 +        * appear first on PCI
23326 +        */
23327 +       if (chip->type == macio_gatwick || chip->type == macio_ohareII)
23328 +               if (macio_chips[0].lbus.pdev == NULL) {
23329 +                       macio_on_hold = chip;
23330 +                       return 0;
23331 +               }
23332 +
23333         macio_pci_add_devices(chip);
23334 +       if (macio_on_hold && macio_chips[0].lbus.pdev != NULL) {
23335 +               macio_pci_add_devices(macio_on_hold);
23336 +               macio_on_hold = NULL;
23337 +       }
23338  
23339         return 0;
23340  }
23341  
23342 -static void __devexit
23343 -macio_pci_remove(struct pci_dev* pdev)
23344 +static void __devexit macio_pci_remove(struct pci_dev* pdev)
23345  {
23346         panic("removing of macio-asic not supported !\n");
23347  }
23348 @@ -306,10 +378,10 @@
23349   * will then decide wether it applies or not
23350   */
23351  static const struct pci_device_id __devinitdata pci_ids [] = { {
23352 -       .vendor =       PCI_VENDOR_ID_APPLE,
23353 -       .device =       PCI_ANY_ID,
23354 -       .subvendor =    PCI_ANY_ID,
23355 -       .subdevice =    PCI_ANY_ID,
23356 +       .vendor         = PCI_VENDOR_ID_APPLE,
23357 +       .device         = PCI_ANY_ID,
23358 +       .subvendor      = PCI_ANY_ID,
23359 +       .subdevice      = PCI_ANY_ID,
23360  
23361         }, { /* end: all zeroes */ }
23362  };
23363 @@ -317,17 +389,16 @@
23364  
23365  /* pci driver glue; this is a "new style" PCI driver module */
23366  static struct pci_driver macio_pci_driver = {
23367 -       .name =         (char *) "macio",
23368 -       .id_table =     pci_ids,
23369 +       .name           = (char *) "macio",
23370 +       .id_table       = pci_ids,
23371  
23372 -       .probe =        macio_pci_probe,
23373 -       .remove =       macio_pci_remove,
23374 +       .probe          = macio_pci_probe,
23375 +       .remove         = macio_pci_remove,
23376  };
23377  
23378  #endif /* CONFIG_PCI */
23379  
23380 -static int __init
23381 -macio_module_init (void) 
23382 +static int __init macio_module_init (void) 
23383  {
23384  #ifdef CONFIG_PCI
23385         int rc;
23386 @@ -339,17 +410,9 @@
23387         return 0;
23388  }
23389  
23390 -/*
23391 -static void __exit
23392 -macio_module_cleanup (void) 
23393 -{      
23394 -#ifdef CONFIG_PCI
23395 -       pci_unregister_driver(&macio_pci_driver);
23396 -#endif
23397 -}
23398 -module_exit(macio_module_cleanup);
23399 -*/
23400  module_init(macio_module_init);
23401  
23402  EXPORT_SYMBOL(macio_register_driver);
23403  EXPORT_SYMBOL(macio_unregister_driver);
23404 +EXPORT_SYMBOL(macio_dev_get);
23405 +EXPORT_SYMBOL(macio_dev_put);
23406 diff -Nru a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c
23407 --- a/drivers/macintosh/mediabay.c      Sat Mar 22 01:11:14 2003
23408 +++ b/drivers/macintosh/mediabay.c      Mon Aug 25 09:51:43 2003
23409 @@ -37,15 +37,7 @@
23410  #include <linux/adb.h>
23411  #include <linux/pmu.h>
23412  
23413 -#ifdef CONFIG_PMAC_PBOOK
23414 -static int mb_notify_sleep(struct pmu_sleep_notifier *self, int when);
23415 -static struct pmu_sleep_notifier mb_sleep_notifier = {
23416 -       mb_notify_sleep,
23417 -       SLEEP_LEVEL_MEDIABAY,
23418 -};
23419 -#endif
23420  
23421 -#undef MB_USE_INTERRUPTS
23422  #define MB_DEBUG
23423  #define MB_IGNORE_SIGNALS
23424  
23425 @@ -55,13 +47,6 @@
23426  #define MBDBG(fmt, arg...)     do { } while (0)
23427  #endif
23428  
23429 -/* Type of media bay */
23430 -enum {
23431 -       mb_ohare,
23432 -       mb_heathrow,
23433 -       mb_keylargo
23434 -};
23435 -
23436  #define MB_FCR32(bay, r)       ((bay)->base + ((r) >> 2))
23437  #define MB_FCR8(bay, r)                (((volatile u8*)((bay)->base)) + (r))
23438  
23439 @@ -76,11 +61,12 @@
23440  
23441  struct mb_ops {
23442         char*   name;
23443 -       u8      (*content)(struct media_bay_info* bay);
23444 -       void    (*power)(struct media_bay_info* bay, int on_off);
23445 -       int     (*setup_bus)(struct media_bay_info* bay, u8 device_id);
23446 -       void    (*un_reset)(struct media_bay_info* bay);
23447 -       void    (*un_reset_ide)(struct media_bay_info* bay);
23448 +       void    (*init)(struct media_bay_info *bay);
23449 +       u8      (*content)(struct media_bay_info *bay);
23450 +       void    (*power)(struct media_bay_info *bay, int on_off);
23451 +       int     (*setup_bus)(struct media_bay_info *bay, u8 device_id);
23452 +       void    (*un_reset)(struct media_bay_info *bay);
23453 +       void    (*un_reset_ide)(struct media_bay_info *bay);
23454  };
23455  
23456  struct media_bay_info {
23457 @@ -90,11 +76,12 @@
23458         int                             last_value;
23459         int                             value_count;
23460         int                             timer;
23461 -       struct device_node*             dev_node;
23462 -       int                             mb_type;
23463 +       struct macio_dev                *mdev;
23464         struct mb_ops*                  ops;
23465         int                             index;
23466         int                             cached_gpio;
23467 +       int                             sleeping;
23468 +       struct semaphore                lock;
23469  #ifdef CONFIG_BLK_DEV_IDE
23470         unsigned long                   cd_base;
23471         int                             cd_index;
23472 @@ -111,13 +98,13 @@
23473  #ifdef CONFIG_BLK_DEV_IDE
23474  /* check the busy bit in the media-bay ide interface
23475     (assumes the media-bay contains an ide device) */
23476 -#define MB_IDE_READY(i)        ((inb(media_bays[i].cd_base + 0x70) & 0x80) == 0)
23477 +#define MB_IDE_READY(i)        ((readb(media_bays[i].cd_base + 0x70) & 0x80) == 0)
23478  #endif
23479  
23480  /* Note: All delays are not in milliseconds and converted to HZ relative
23481   * values by the macro below
23482   */
23483 -#define MS_TO_HZ(ms)   ((ms * HZ) / 1000)
23484 +#define MS_TO_HZ(ms)   ((ms * HZ + 999) / 1000)
23485  
23486  /*
23487   * Consider the media-bay ID value stable if it is the same for
23488 @@ -352,38 +339,37 @@
23489         MB_BIS(bay, OHARE_FCR, OH_BAY_RESET_N);
23490  }
23491  
23492 -static void __pmac
23493 -heathrow_mb_un_reset(struct media_bay_info* bay)
23494 +static void __pmac keylargo_mb_init(struct media_bay_info *bay)
23495 +{
23496 +       MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE);
23497 +}
23498 +
23499 +static void __pmac heathrow_mb_un_reset(struct media_bay_info* bay)
23500  {
23501         MB_BIS(bay, HEATHROW_FCR, HRW_BAY_RESET_N);
23502  }
23503  
23504 -static void __pmac
23505 -keylargo_mb_un_reset(struct media_bay_info* bay)
23506 +static void __pmac keylargo_mb_un_reset(struct media_bay_info* bay)
23507  {
23508         MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_DEV_RESET);
23509  }
23510  
23511 -static void __pmac
23512 -ohare_mb_un_reset_ide(struct media_bay_info* bay)
23513 +static void __pmac ohare_mb_un_reset_ide(struct media_bay_info* bay)
23514  {
23515         MB_BIS(bay, OHARE_FCR, OH_IDE1_RESET_N);
23516  }
23517  
23518 -static void __pmac
23519 -heathrow_mb_un_reset_ide(struct media_bay_info* bay)
23520 +static void __pmac heathrow_mb_un_reset_ide(struct media_bay_info* bay)
23521  {
23522         MB_BIS(bay, HEATHROW_FCR, HRW_IDE1_RESET_N);
23523  }
23524  
23525 -static void __pmac
23526 -keylargo_mb_un_reset_ide(struct media_bay_info* bay)
23527 +static void __pmac keylargo_mb_un_reset_ide(struct media_bay_info* bay)
23528  {
23529         MB_BIS(bay, KEYLARGO_FCR1, KL1_EIDE0_RESET_N);
23530  }
23531  
23532 -static inline void __pmac
23533 -set_mb_power(struct media_bay_info* bay, int onoff)
23534 +static inline void __pmac set_mb_power(struct media_bay_info* bay, int onoff)
23535  {
23536         /* Power up up and assert the bay reset line */
23537         if (onoff) {
23538 @@ -399,8 +385,7 @@
23539         bay->timer = MS_TO_HZ(MB_POWER_DELAY);
23540  }
23541  
23542 -static void __pmac
23543 -poll_media_bay(struct media_bay_info* bay)
23544 +static void __pmac poll_media_bay(struct media_bay_info* bay)
23545  {
23546         int id = bay->ops->content(bay);
23547  
23548 @@ -429,15 +414,13 @@
23549         }
23550  }
23551  
23552 -int __pmac
23553 -check_media_bay(struct device_node *which_bay, int what)
23554 +int __pmac check_media_bay(struct device_node *which_bay, int what)
23555  {
23556  #ifdef CONFIG_BLK_DEV_IDE
23557         int     i;
23558  
23559         for (i=0; i<media_bay_count; i++)
23560 -               if (which_bay == media_bays[i].dev_node)
23561 -               {
23562 +               if (media_bays[i].mdev && which_bay == media_bays[i].mdev->ofdev.node) {
23563                         if ((what == media_bays[i].content_id) && media_bays[i].state == mb_up)
23564                                 return 0;
23565                         media_bays[i].cd_index = -1;
23566 @@ -447,15 +430,13 @@
23567         return -ENODEV;
23568  }
23569  
23570 -int __pmac
23571 -check_media_bay_by_base(unsigned long base, int what)
23572 +int __pmac check_media_bay_by_base(unsigned long base, int what)
23573  {
23574  #ifdef CONFIG_BLK_DEV_IDE
23575         int     i;
23576  
23577         for (i=0; i<media_bay_count; i++)
23578 -               if (base == media_bays[i].cd_base)
23579 -               {
23580 +               if (media_bays[i].mdev && base == media_bays[i].cd_base) {
23581                         if ((what == media_bays[i].content_id) && media_bays[i].state == mb_up)
23582                                 return 0;
23583                         media_bays[i].cd_index = -1;
23584 @@ -466,42 +447,47 @@
23585         return -ENODEV;
23586  }
23587  
23588 -int __pmac
23589 -media_bay_set_ide_infos(struct device_node* which_bay, unsigned long base,
23590 +int __pmac media_bay_set_ide_infos(struct device_node* which_bay, unsigned long base,
23591         int irq, int index)
23592  {
23593  #ifdef CONFIG_BLK_DEV_IDE
23594         int     i;
23595  
23596 -       for (i=0; i<media_bay_count; i++)
23597 -               if (which_bay == media_bays[i].dev_node)
23598 -               {
23599 +       for (i=0; i<media_bay_count; i++) {
23600 +               struct media_bay_info* bay = &media_bays[i];
23601 +
23602 +               if (bay->mdev && which_bay == bay->mdev->ofdev.node) {
23603                         int timeout = 5000;
23604                         
23605 -                       media_bays[i].cd_base   = base;
23606 -                       media_bays[i].cd_irq    = irq;
23607 +                       down(&bay->lock);
23608  
23609 -                       if ((MB_CD != media_bays[i].content_id) || media_bays[i].state != mb_up)
23610 -                               return 0;
23611 +                       bay->cd_base    = base;
23612 +                       bay->cd_irq     = irq;
23613  
23614 -                       printk(KERN_DEBUG "Registered ide %d for media bay %d\n", index, i);
23615 +                       if ((MB_CD != bay->content_id) || bay->state != mb_up) {
23616 +                               up(&bay->lock);
23617 +                               return 0;
23618 +                       }
23619 +                       printk(KERN_DEBUG "Registered ide%d for media bay %d\n", index, i);
23620                         do {
23621                                 if (MB_IDE_READY(i)) {
23622 -                                       media_bays[i].cd_index  = index;
23623 +                                       bay->cd_index   = index;
23624 +                                       up(&bay->lock);
23625                                         return 0;
23626                                 }
23627                                 mdelay(1);
23628                         } while(--timeout);
23629                         printk(KERN_DEBUG "Timeount waiting IDE in bay %d\n", i);
23630 +                       up(&bay->lock);
23631                         return -ENODEV;
23632                 }
23633 -#endif
23634 +       }
23635 +#endif /* CONFIG_BLK_DEV_IDE */
23636         
23637         return -ENODEV;
23638  }
23639  
23640 -static void __pmac
23641 -media_bay_step(int i)
23642 +static void __pmac media_bay_step(int i)
23643  {
23644         struct media_bay_info* bay = &media_bays[i];
23645  
23646 @@ -567,6 +553,7 @@
23647                         if (bay->cd_index < 0) {
23648                                 hw_regs_t hw;
23649  
23650 +                               printk("mediabay %d, registering IDE...\n", i);
23651                                 pmu_suspend();
23652                                 ide_init_hwif_ports(&hw, (unsigned long) bay->cd_base, (unsigned long) 0, NULL);
23653                                 hw.irq = bay->cd_irq;
23654 @@ -580,13 +567,15 @@
23655                                 printk("IDE register error\n");
23656                                 set_mb_power(bay, 0);
23657                         } else {
23658 -                               printk(KERN_DEBUG "media-bay %d is ide %d\n", i, bay->cd_index);
23659 +                               printk(KERN_DEBUG "media-bay %d is ide%d\n", i, bay->cd_index);
23660                                 MBDBG("mediabay %d IDE ready\n", i);
23661                         }
23662                         break;
23663 -               }
23664 +               } else if (bay->timer > 0)
23665 +                       bay->timer--;
23666                 if (bay->timer == 0) {
23667 -                       printk("\nIDE Timeout in bay %d !\n", i);
23668 +                       printk("\nIDE Timeout in bay %d !, IDE state is: 0x%02x\n",
23669 +                              i, readb(bay->cd_base + 0x70));
23670                         MBDBG("mediabay%d: nIDE Timeout !\n", i);
23671                         set_mb_power(bay, 0);
23672                 }
23673 @@ -623,8 +612,7 @@
23674   * with the IDE driver.  It needs to be a thread because
23675   * ide_register can't be called from interrupt context.
23676   */
23677 -static int __pmac
23678 -media_bay_task(void *x)
23679 +static int __pmac media_bay_task(void *x)
23680  {
23681         int     i;
23682  
23683 @@ -634,75 +622,140 @@
23684  #endif
23685  
23686         for (;;) {
23687 -               for (i = 0; i < media_bay_count; ++i)
23688 -                       media_bay_step(i);
23689 +               for (i = 0; i < media_bay_count; ++i) {
23690 +                       down(&media_bays[i].lock);
23691 +                       if (!media_bays[i].sleeping)
23692 +                               media_bay_step(i);
23693 +                       up(&media_bays[i].lock);
23694 +               }
23695  
23696                 current->state = TASK_INTERRUPTIBLE;
23697 -               schedule_timeout(1);
23698 +               schedule_timeout(MS_TO_HZ(10));
23699                 if (signal_pending(current))
23700                         return 0;
23701         }
23702  }
23703  
23704 -#ifdef MB_USE_INTERRUPTS
23705 -static void __pmac
23706 -media_bay_intr(int irq, void *devid, struct pt_regs *regs)
23707 -{
23708 -}
23709 -#endif
23710 -
23711 -#ifdef CONFIG_PMAC_PBOOK
23712 -/*
23713 - * notify clients before sleep and reset bus afterwards
23714 - */
23715 -int __pmac
23716 -mb_notify_sleep(struct pmu_sleep_notifier *self, int when)
23717 +static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_match *match)
23718  {
23719         struct media_bay_info* bay;
23720 +       volatile u32 *regbase;
23721 +       struct device_node *ofnode;
23722         int i;
23723 +
23724 +       ofnode = mdev->ofdev.node;
23725 +
23726 +       if (!request_OF_resource(ofnode, 0, NULL))
23727 +               return -ENXIO;
23728 +
23729 +       /* Media bay registers are located at the beginning of the
23730 +         * mac-io chip, we get the parent address for now (hrm...)
23731 +         */
23732 +       if (ofnode->parent->n_addrs == 0)
23733 +               return -ENODEV;
23734 +       regbase = (volatile u32 *)ioremap(ofnode->parent->addrs[0].address, 0x100);
23735 +       if (regbase == NULL) {
23736 +               release_OF_resource(ofnode, 0);
23737 +               return -ENOMEM;
23738 +       }
23739         
23740 -       switch (when) {
23741 -       case PBOOK_SLEEP_REQUEST:
23742 -       case PBOOK_SLEEP_REJECT:
23743 -               break;
23744 -               
23745 -       case PBOOK_SLEEP_NOW:
23746 -               for (i=0; i<media_bay_count; i++) {
23747 -                       bay = &media_bays[i];
23748 -                       set_mb_power(bay, 0);
23749 -                       mdelay(10);
23750 -               }
23751 -               break;
23752 -       case PBOOK_WAKE:
23753 -               for (i=0; i<media_bay_count; i++) {
23754 -                       bay = &media_bays[i];
23755 -                       /* We re-enable the bay using it's previous content
23756 -                          only if it did not change. Note those bozo timings,
23757 -                          they seem to help the 3400 get it right.
23758 -                        */
23759 -                       /* Force MB power to 0 */
23760 -                       set_mb_power(bay, 0);
23761 -                       mdelay(MB_POWER_DELAY);
23762 -                       if (bay->ops->content(bay) != bay->content_id)
23763 -                               continue;
23764 -                       set_mb_power(bay, 1);
23765 -                       bay->last_value = bay->content_id;
23766 -                       bay->value_count = MS_TO_HZ(MB_STABLE_DELAY);
23767 -                       bay->timer = MS_TO_HZ(MB_POWER_DELAY);
23768 -#ifdef CONFIG_BLK_DEV_IDE
23769 -                       bay->cd_retry = 0;
23770 -#endif
23771 -                       do {
23772 -                               mdelay(1000/HZ);
23773 -                               media_bay_step(i);
23774 -                       } while((media_bays[i].state != mb_empty) &&
23775 -                               (media_bays[i].state != mb_up));
23776 -               }
23777 -               break;
23778 +       i = media_bay_count++;
23779 +       bay = &media_bays[i];
23780 +       bay->mdev = mdev;
23781 +       bay->base = regbase;
23782 +       bay->index = i;
23783 +       bay->ops = match->data;
23784 +       bay->sleeping = 0;
23785 +       init_MUTEX(&bay->lock);
23786 +
23787 +       /* Init HW probing */
23788 +       if (bay->ops->init)
23789 +               bay->ops->init(bay);
23790 +
23791 +       printk(KERN_INFO "mediabay%d: Registered %s media-bay\n", i, bay->ops->name);
23792 +
23793 +       /* Force an immediate detect */
23794 +       set_mb_power(bay, 0);
23795 +       set_current_state(TASK_UNINTERRUPTIBLE);
23796 +       schedule_timeout(MS_TO_HZ(MB_POWER_DELAY));
23797 +       bay->content_id = MB_NO;
23798 +       bay->last_value = bay->ops->content(bay);
23799 +       bay->value_count = MS_TO_HZ(MB_STABLE_DELAY);
23800 +       bay->state = mb_empty;
23801 +       do {
23802 +               set_current_state(TASK_UNINTERRUPTIBLE);
23803 +               schedule_timeout(MS_TO_HZ(10));
23804 +               media_bay_step(i);
23805 +       } while((bay->state != mb_empty) &&
23806 +               (bay->state != mb_up));
23807 +
23808 +       /* Mark us ready by filling our mdev data */
23809 +       dev_set_drvdata(&mdev->ofdev.dev, bay);
23810 +
23811 +       /* Startup kernel thread */
23812 +       if (i == 0)
23813 +               kernel_thread(media_bay_task, NULL,
23814 +                             CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
23815 +
23816 +       return 0;
23817 +
23818 +}
23819 +
23820 +static int __pmac media_bay_suspend(struct macio_dev *mdev, u32 state)
23821 +{
23822 +       struct media_bay_info   *bay = dev_get_drvdata(&mdev->ofdev.dev);
23823 +
23824 +       if (state != mdev->ofdev.dev.power_state && state >= 2) {
23825 +               down(&bay->lock);
23826 +               bay->sleeping = 1;
23827 +               set_mb_power(bay, 0);
23828 +               up(&bay->lock);
23829 +               set_current_state(TASK_UNINTERRUPTIBLE);
23830 +               schedule_timeout(MS_TO_HZ(10));
23831 +               mdev->ofdev.dev.power_state = state;
23832         }
23833 -       return PBOOK_SLEEP_OK;
23834 +       return 0;
23835 +}
23836 +
23837 +static int __pmac media_bay_resume(struct macio_dev *mdev)
23838 +{
23839 +       struct media_bay_info   *bay = dev_get_drvdata(&mdev->ofdev.dev);
23840 +
23841 +       if (mdev->ofdev.dev.power_state != 0) {
23842 +               mdev->ofdev.dev.power_state = 0;
23843 +
23844 +               /* We re-enable the bay using it's previous content
23845 +                  only if it did not change. Note those bozo timings,
23846 +                  they seem to help the 3400 get it right.
23847 +                */
23848 +               /* Force MB power to 0 */
23849 +               down(&bay->lock);
23850 +               set_mb_power(bay, 0);
23851 +               set_current_state(TASK_UNINTERRUPTIBLE);
23852 +               schedule_timeout(MS_TO_HZ(MB_POWER_DELAY));
23853 +               if (bay->ops->content(bay) != bay->content_id) {
23854 +                       printk("mediabay%d: content changed during sleep...\n", bay->index);
23855 +                       up(&bay->lock);
23856 +                       return 0;
23857 +               }
23858 +               set_mb_power(bay, 1);
23859 +               bay->last_value = bay->content_id;
23860 +               bay->value_count = MS_TO_HZ(MB_STABLE_DELAY);
23861 +               bay->timer = MS_TO_HZ(MB_POWER_DELAY);
23862 +#ifdef CONFIG_BLK_DEV_IDE
23863 +               bay->cd_retry = 0;
23864 +#endif
23865 +               do {
23866 +                       set_current_state(TASK_UNINTERRUPTIBLE);
23867 +                       schedule_timeout(MS_TO_HZ(10));
23868 +                       media_bay_step(bay->index);
23869 +               } while((bay->state != mb_empty) &&
23870 +                       (bay->state != mb_up));
23871 +               bay->sleeping = 0;
23872 +               up(&bay->lock);
23873 +       }
23874 +       return 0;
23875  }
23876 -#endif /* CONFIG_PMAC_PBOOK */
23877  
23878  
23879  /* Definitions of "ops" structures.
23880 @@ -727,6 +780,7 @@
23881  
23882  static struct mb_ops keylargo_mb_ops __pmacdata = {
23883         .name           = "KeyLargo",
23884 +       .init           = keylargo_mb_init,
23885         .content        = keylargo_mb_content,
23886         .power          = keylargo_mb_power,
23887         .setup_bus      = keylargo_mb_setup_bus,
23888 @@ -743,12 +797,42 @@
23889   * Therefore we do it all by polling the media bay once each tick.
23890   */
23891  
23892 -static int __init
23893 -media_bay_init(void)
23894 +static struct of_match media_bay_match[] =
23895  {
23896 -       struct device_node *np;
23897 -       int             n,i;
23898 -       
23899 +       {
23900 +       .name           = "media-bay",
23901 +       .type           = OF_ANY_MATCH,
23902 +       .compatible     = "keylargo-media-bay",
23903 +       .data           = &keylargo_mb_ops,
23904 +       },
23905 +       {
23906 +       .name           = "media-bay",
23907 +       .type           = OF_ANY_MATCH,
23908 +       .compatible     = "heathrow-media-bay",
23909 +       .data           = &heathrow_mb_ops,
23910 +       },
23911 +       {
23912 +       .name           = "media-bay",
23913 +       .type           = OF_ANY_MATCH,
23914 +       .compatible     = "ohare-media-bay",
23915 +       .data           = &ohare_mb_ops,
23916 +       },
23917 +       {},
23918 +};
23919 +
23920 +static struct macio_driver media_bay_driver =
23921 +{
23922 +       .name           = "media-bay",
23923 +       .match_table    = media_bay_match,
23924 +       .probe          = media_bay_attach,
23925 +       .suspend        = media_bay_suspend,
23926 +       .resume         = media_bay_resume
23927 +};
23928 +
23929 +static int __init media_bay_init(void)
23930 +{
23931 +       int i;
23932 +
23933         for (i=0; i<MAX_BAYS; i++) {
23934                 memset((char *)&media_bays[i], 0, sizeof(struct media_bay_info));
23935                 media_bays[i].content_id        = -1;
23936 @@ -756,84 +840,12 @@
23937                 media_bays[i].cd_index          = -1;
23938  #endif
23939         }
23940 -       
23941 -       np = find_devices("media-bay");
23942 -       n = 0;
23943 -       while(np && (n<MAX_BAYS)) {
23944 -               struct media_bay_info* bay = &media_bays[n];
23945 -               if (!np->parent || np->n_addrs == 0 || !request_OF_resource(np, 0, NULL)) {
23946 -                       np = np->next;
23947 -                       printk(KERN_ERR "media-bay: Can't request IO resource !\n");
23948 -                       continue;
23949 -               }
23950 -               bay->mb_type = mb_ohare;
23951 -
23952 -               if (device_is_compatible(np, "keylargo-media-bay")) {
23953 -                       bay->mb_type = mb_keylargo;
23954 -                       bay->ops = &keylargo_mb_ops;
23955 -               } else if (device_is_compatible(np, "heathrow-media-bay")) {
23956 -                       bay->mb_type = mb_heathrow;
23957 -                       bay->ops = &heathrow_mb_ops;
23958 -               } else if (device_is_compatible(np, "ohare-media-bay")) {
23959 -                       bay->mb_type = mb_ohare;
23960 -                       bay->ops = &ohare_mb_ops;
23961 -               } else {
23962 -                       printk(KERN_ERR "mediabay: Unknown bay type !\n");
23963 -                       np = np->next;
23964 -                       continue;
23965 -               }
23966 -               bay->base = (volatile u32*)ioremap(np->parent->addrs[0].address, 0x1000);
23967 -
23968 -               /* Enable probe logic on keylargo */
23969 -               if (bay->mb_type == mb_keylargo)
23970 -                       MB_BIS(bay, KEYLARGO_MBCR, KL_MBCR_MB0_ENABLE);
23971 -#ifdef MB_USE_INTERRUPTS
23972 -               if (np->n_intrs == 0) {
23973 -                       printk(KERN_ERR "media bay %d has no irq\n",n);
23974 -                       np = np->next;
23975 -                       continue;
23976 -               }
23977 -
23978 -               if (request_irq(np->intrs[0].line, media_bay_intr, 0, "Media bay", (void *)n)) {
23979 -                       printk(KERN_ERR "Couldn't get IRQ %d for media bay %d\n",
23980 -                               np->intrs[0].line, n);
23981 -                       np = np->next;
23982 -                       continue;
23983 -               }
23984 -#endif 
23985 -               media_bay_count++;
23986 -       
23987 -               printk(KERN_INFO "mediabay%d: Registered %s media-bay\n", n, bay->ops->name);
23988 -               bay->dev_node = np;
23989 -               bay->index = n;
23990 -
23991 -               /* Force an immediate detect */
23992 -               set_mb_power(bay, 0);
23993 -               mdelay(MB_POWER_DELAY);
23994 -               bay->content_id = MB_NO;
23995 -               bay->last_value = bay->ops->content(bay);
23996 -               bay->value_count = MS_TO_HZ(MB_STABLE_DELAY);
23997 -               bay->state = mb_empty;
23998 -               do {
23999 -                       mdelay(1000/HZ);
24000 -                       media_bay_step(n);
24001 -               } while((bay->state != mb_empty) &&
24002 -                       (bay->state != mb_up));
24003 -
24004 -               n++;
24005 -               np=np->next;
24006 -       }
24007 +       if (_machine != _MACH_Pmac)
24008 +               return -ENODEV;
24009  
24010 -       if (media_bay_count)
24011 -       {
24012 -#ifdef CONFIG_PMAC_PBOOK
24013 -               pmu_register_sleep_notifier(&mb_sleep_notifier);
24014 -#endif /* CONFIG_PMAC_PBOOK */
24015 +       macio_register_driver(&media_bay_driver);       
24016  
24017 -               kernel_thread(media_bay_task, NULL,
24018 -                             CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
24019 -       }
24020         return 0;
24021  }
24022  
24023 -subsys_initcall(media_bay_init);
24024 +device_initcall(media_bay_init);
24025 diff -Nru a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
24026 --- a/drivers/macintosh/via-pmu.c       Sat Jun  7 00:46:48 2003
24027 +++ b/drivers/macintosh/via-pmu.c       Mon Aug 25 10:06:34 2003
24028 @@ -11,6 +11,14 @@
24029   * Copyright (C) 1998 Paul Mackerras and Fabio Riccardi.
24030   * Copyright (C) 2001-2002 Benjamin Herrenschmidt
24031   *
24032 + * THIS DRIVER IS BECOMING A TOTAL MESS !
24033 + *  - Cleanup atomically disabling reply to PMU events after
24034 + *    a sleep or a freq. switch
24035 + *  - Move sleep code out of here to pmac_pm, merge into new
24036 + *    common PM infrastructure
24037 + *  - Move backlight code out as well
24038 + *  - Save/Restore PCI space properly
24039 + *
24040   */
24041  #include <stdarg.h>
24042  #include <linux/config.h>
24043 @@ -34,6 +42,8 @@
24044  #include <linux/proc_fs.h>
24045  #include <linux/init.h>
24046  #include <linux/interrupt.h>
24047 +#include <linux/device.h>
24048 +#include <linux/suspend.h>
24049  #include <asm/prom.h>
24050  #include <asm/machdep.h>
24051  #include <asm/io.h>
24052 @@ -47,6 +57,7 @@
24053  #include <asm/mmu_context.h>
24054  #include <asm/cputable.h>
24055  #include <asm/time.h>
24056 +#include <asm/xmon.h>
24057  #ifdef CONFIG_PMAC_BACKLIGHT
24058  #include <asm/backlight.h>
24059  #endif
24060 @@ -55,7 +66,6 @@
24061  #undef SUSPEND_USES_PMU
24062  #define DEBUG_SLEEP
24063  #undef HACKED_PCI_SAVE
24064 -#define NEW_OHARE_CODE
24065  
24066  /* Misc minor number allocated for /dev/pmu */
24067  #define PMU_MINOR              154
24068 @@ -63,6 +73,13 @@
24069  /* How many iterations between battery polls */
24070  #define BATTERY_POLLING_COUNT  2
24071  
24072 +/* Some debugging tools */
24073 +#ifdef CONFIG_XMON
24074 +//#define LIVE_DEBUG(req) ((req) && (req)->data[0] == 0x7d)
24075 +#define LIVE_DEBUG(req) (0)
24076 +static int whacky_debug;
24077 +#endif /* CONFIG_XMON */
24078 +
24079  static volatile unsigned char *via;
24080  
24081  /* VIA registers - spaced 0x200 bytes apart */
24082 @@ -106,6 +123,7 @@
24083         intack,
24084         reading,
24085         reading_intr,
24086 +       locked,
24087  } pmu_state;
24088  
24089  static volatile enum int_data_state {
24090 @@ -133,6 +151,7 @@
24091  static int pmu_has_adb;
24092  static unsigned char *gpio_reg = NULL;
24093  static int gpio_irq = -1;
24094 +static int gpio_irq_enabled = -1;
24095  static volatile int pmu_suspended = 0;
24096  static spinlock_t pmu_lock;
24097  static u8 pmu_intr_mask;
24098 @@ -143,9 +162,11 @@
24099  static int sleep_in_progress;
24100  static int can_sleep;
24101  #endif /* CONFIG_PMAC_PBOOK */
24102 +static unsigned int pmu_irq_stats[11];
24103  
24104  static struct proc_dir_entry *proc_pmu_root;
24105  static struct proc_dir_entry *proc_pmu_info;
24106 +static struct proc_dir_entry *proc_pmu_irqstats;
24107  static struct proc_dir_entry *proc_pmu_options;
24108  
24109  #ifdef CONFIG_PMAC_PBOOK
24110 @@ -184,6 +205,8 @@
24111  static irqreturn_t gpio1_interrupt(int irq, void *arg, struct pt_regs *regs);
24112  static int proc_get_info(char *page, char **start, off_t off,
24113                           int count, int *eof, void *data);
24114 +static int proc_get_irqstats(char *page, char **start, off_t off,
24115 +                         int count, int *eof, void *data);
24116  #ifdef CONFIG_PMAC_BACKLIGHT
24117  static int pmu_set_backlight_level(int level, void* data);
24118  static int pmu_set_backlight_enable(int on, int level, void* data);
24119 @@ -205,16 +228,12 @@
24120         pmu_init,
24121         pmu_send_request,
24122         pmu_adb_autopoll,
24123 -       pmu_poll,
24124 +       pmu_poll_adb,
24125         pmu_adb_reset_bus
24126  };
24127  #endif /* CONFIG_ADB */
24128  
24129  extern void low_sleep_handler(void);
24130 -extern void pmac_sleep_save_intrs(int);
24131 -extern void pmac_sleep_restore_intrs(void);
24132 -extern void openpic_sleep_save_intrs(void);
24133 -extern void openpic_sleep_restore_intrs(void);
24134  extern void enable_kernel_altivec(void);
24135  extern void enable_kernel_fp(void);
24136  
24137 @@ -223,14 +242,6 @@
24138  int pmu_wink(struct adb_request *req);
24139  #endif
24140  
24141 -#if defined(CONFIG_PMAC_PBOOK) && defined(CONFIG_PM)
24142 -static int generic_notify_sleep(struct pmu_sleep_notifier *self, int when);
24143 -static struct pmu_sleep_notifier generic_sleep_notifier = {
24144 -       generic_notify_sleep,
24145 -       SLEEP_LEVEL_MISC,
24146 -};
24147 -#endif /* defined(CONFIG_PMAC_PBOOK) && defined(CONFIG_PM) */
24148 -
24149  /*
24150   * This table indicates for each PMU opcode:
24151   * - the number of data bytes to be sent with the command, or -1
24152 @@ -361,11 +372,6 @@
24153                
24154         sys_ctrler = SYS_CTRLER_PMU;
24155         
24156 -#if defined(CONFIG_PMAC_PBOOK) && defined(CONFIG_PM)
24157 -       pmu_register_sleep_notifier(&generic_sleep_notifier);
24158 -       pm_active = 1;
24159 -#endif 
24160 -
24161         return 1;
24162  }
24163  
24164 @@ -416,6 +422,7 @@
24165         if (pmu_kind == PMU_KEYLARGO_BASED && gpio_irq != -1) {
24166                 if (request_irq(gpio_irq, gpio1_interrupt, 0, "GPIO1/ADB", (void *)0))
24167                         printk(KERN_ERR "pmu: can't get irq %d (GPIO1)\n", gpio_irq);
24168 +               gpio_irq_enabled = 1;
24169         }
24170  
24171         /* Enable interrupts */
24172 @@ -489,6 +496,8 @@
24173                 int i;
24174                 proc_pmu_info = create_proc_read_entry("info", 0, proc_pmu_root,
24175                                         proc_get_info, NULL);
24176 +               proc_pmu_irqstats = create_proc_read_entry("interrupts", 0, proc_pmu_root,
24177 +                                       proc_get_irqstats, NULL);
24178  #ifdef CONFIG_PMAC_PBOOK
24179                 for (i=0; i<pmu_battery_count; i++) {
24180                         char title[16];
24181 @@ -552,15 +561,14 @@
24182  
24183         /* Read PMU version */
24184         pmu_request(&req, NULL, 1, PMU_GET_VERSION);
24185 -       while (!req.complete)
24186 -               pmu_poll();
24187 +       pmu_wait_complete(&req);
24188         if (req.reply_len > 0)
24189                 pmu_version = req.reply[0];
24190  
24191         return 1;
24192  }
24193  
24194 -int __pmac
24195 +int
24196  pmu_get_model(void)
24197  {
24198         return pmu_kind;
24199 @@ -774,6 +782,33 @@
24200         return p - page;
24201  }
24202  
24203 +static int __pmac
24204 +proc_get_irqstats(char *page, char **start, off_t off,
24205 +                 int count, int *eof, void *data)
24206 +{
24207 +       int i;
24208 +       char* p = page;
24209 +       static const char *irq_names[] = {
24210 +               "Total CB1 triggered events",
24211 +               "Total GPIO1 triggered events",
24212 +               "PC-Card eject button",
24213 +               "Sound/Brightness button",
24214 +               "ADB message",
24215 +               "Battery state change",
24216 +               "Environment interrupt",
24217 +               "Tick timer",
24218 +               "Ghost interrupt (zero len)",
24219 +               "Empty interrupt (empty mask)",
24220 +               "Max irqs in a row"
24221 +        };
24222 +
24223 +       for (i=0; i<11; i++) {
24224 +               p += sprintf(p, " %2u: %10u (%s)\n",
24225 +                            i, pmu_irq_stats[i], irq_names[i]);
24226 +       }
24227 +       return p - page;
24228 +}
24229 +
24230  #ifdef CONFIG_PMAC_PBOOK
24231  static int __pmac
24232  proc_get_batt(char *page, char **start, off_t off,
24233 @@ -982,8 +1017,7 @@
24234                 printk(KERN_ERR "pmu_adb_reset_bus: pmu_queue_request failed\n");
24235                 return -EIO;
24236         }
24237 -       while (!req.complete)
24238 -               pmu_poll();
24239 +       pmu_wait_complete(&req);
24240  
24241         if (save_autopoll != 0)
24242                 pmu_adb_autopoll(save_autopoll);
24243 @@ -1133,6 +1167,12 @@
24244         wait_for_ack();
24245         /* set the shift register to shift out and send a byte */
24246         send_byte(req->data[0]);
24247 +#ifdef CONFIG_XMON
24248 +       if (LIVE_DEBUG(req))
24249 +               xmon_printf("R");
24250 +       else
24251 +               whacky_debug = 0;
24252 +#endif /* CONFIG_XMON */
24253  }
24254  
24255  void __openfirmware
24256 @@ -1142,15 +1182,33 @@
24257                 return;
24258         if (disable_poll)
24259                 return;
24260 +       via_pmu_interrupt(0, 0, 0);
24261 +}
24262 +
24263 +void __openfirmware
24264 +pmu_poll_adb(void)
24265 +{
24266 +       if (!via)
24267 +               return;
24268 +       if (disable_poll)
24269 +               return;
24270         /* Kicks ADB read when PMU is suspended */
24271 -       if (pmu_suspended)
24272 -               adb_int_pending = 1;
24273 +       adb_int_pending = 1;
24274         do {
24275                 via_pmu_interrupt(0, 0, 0);
24276         } while (pmu_suspended && (adb_int_pending || pmu_state != idle
24277                 || req_awaiting_reply));
24278  }
24279  
24280 +void __openfirmware
24281 +pmu_wait_complete(struct adb_request *req)
24282 +{
24283 +       if (!via)
24284 +               return;
24285 +       while((pmu_state != idle && pmu_state != locked) || !req->complete)
24286 +               via_pmu_interrupt(0, 0, 0);
24287 +}
24288 +
24289  /* This function loops until the PMU is idle and prevents it from
24290   * anwsering to ADB interrupts. pmu_request can still be called.
24291   * This is done to avoid spurrious shutdowns when we know we'll have
24292 @@ -1175,6 +1233,8 @@
24293  
24294         do {
24295                 spin_unlock_irqrestore(&pmu_lock, flags);
24296 +               if (req_awaiting_reply)
24297 +                       adb_int_pending = 1;
24298                 via_pmu_interrupt(0, 0, 0);
24299                 spin_lock_irqsave(&pmu_lock, flags);
24300                 if (!adb_int_pending && pmu_state == idle && !req_awaiting_reply) {
24301 @@ -1185,7 +1245,7 @@
24302                                 pmu_poll();
24303  #else /* SUSPEND_USES_PMU */
24304                         if (gpio_irq >= 0)
24305 -                               disable_irq(gpio_irq);
24306 +                               disable_irq_nosync(gpio_irq);
24307                         out_8(&via[IER], CB1_INT | IER_CLR);
24308                         spin_unlock_irqrestore(&pmu_lock, flags);
24309  #endif /* SUSPEND_USES_PMU */
24310 @@ -1227,16 +1287,47 @@
24311  static void __pmac
24312  pmu_handle_data(unsigned char *data, int len, struct pt_regs *regs)
24313  {
24314 +       unsigned char ints, pirq;
24315 +       int i = 0;
24316 +
24317         asleep = 0;
24318         if (drop_interrupts || len < 1) {
24319                 adb_int_pending = 0;
24320 +               pmu_irq_stats[8]++;
24321 +               return;
24322 +       }
24323 +
24324 +       /* Get PMU interrupt mask */
24325 +       ints = data[0];
24326 +
24327 +       /* Record zero interrupts for stats */
24328 +       if (ints == 0)
24329 +               pmu_irq_stats[9]++;
24330 +
24331 +       /* Hack to deal with ADB autopoll flag */
24332 +       if (ints & PMU_INT_ADB)
24333 +               ints &= ~(PMU_INT_ADB_AUTO | PMU_INT_AUTO_SRQ_POLL);
24334 +
24335 +next:
24336 +
24337 +       if (ints == 0) {
24338 +               if (i > pmu_irq_stats[10])
24339 +                       pmu_irq_stats[10] = i;
24340                 return;
24341         }
24342 +
24343 +       for (pirq = 0; pirq < 8; pirq++)
24344 +               if (ints & (1 << pirq))
24345 +                       break;
24346 +       pmu_irq_stats[pirq]++;
24347 +       i++;
24348 +       ints &= ~(1 << pirq);
24349 +
24350         /* Note: for some reason, we get an interrupt with len=1,
24351          * data[0]==0 after each normal ADB interrupt, at least
24352          * on the Pismo. Still investigating...  --BenH
24353          */
24354 -       if (data[0] & PMU_INT_ADB) {
24355 +       if ((1 << pirq) & PMU_INT_ADB) {
24356                 if ((data[0] & PMU_INT_ADB_AUTO) == 0) {
24357                         struct adb_request *req = req_awaiting_reply;
24358                         if (req == 0) {
24359 @@ -1274,29 +1365,37 @@
24360                                 adb_input(data+1, len-1, regs, 1);
24361  #endif /* CONFIG_ADB */                
24362                 }
24363 -       } else {
24364 -               /* Sound/brightness button pressed */
24365 -               if ((data[0] & PMU_INT_SNDBRT) && len == 3) {
24366 +       }
24367 +       /* Sound/brightness button pressed */
24368 +       else if ((1 << pirq) & PMU_INT_SNDBRT) {
24369  #ifdef CONFIG_PMAC_BACKLIGHT
24370 +               if (len == 3)
24371  #ifdef CONFIG_INPUT_ADBHID
24372                         if (!disable_kernel_backlight)
24373  #endif /* CONFIG_INPUT_ADBHID */
24374                                 set_backlight_level(data[1] >> 4);
24375  #endif /* CONFIG_PMAC_BACKLIGHT */
24376 -               }
24377 +       }
24378 +       /* Tick interrupt */
24379 +       else if ((1 << pirq) & PMU_INT_TICK) {
24380  #ifdef CONFIG_PMAC_PBOOK
24381                 /* Environement or tick interrupt, query batteries */
24382 -               if (pmu_battery_count && (data[0] & PMU_INT_TICK)) {
24383 +               if (pmu_battery_count) {
24384                         if ((--query_batt_timer) == 0) {
24385                                 query_battery_state();
24386                                 query_batt_timer = BATTERY_POLLING_COUNT;
24387                         }
24388 -               } else if (pmu_battery_count && (data[0] & PMU_INT_ENVIRONMENT))
24389 +               }
24390 +        }
24391 +       else if ((1 << pirq) & PMU_INT_ENVIRONMENT) {
24392 +               if (pmu_battery_count)
24393                         query_battery_state();
24394 -               if (data[0])
24395 -                       pmu_pass_intr(data, len);
24396 +               pmu_pass_intr(data, len);
24397 +       } else
24398 +              pmu_pass_intr(data, len);
24399 +
24400  #endif /* CONFIG_PMAC_PBOOK */
24401 -       }
24402 +       goto next;
24403  }
24404  
24405  static struct adb_request* __pmac
24406 @@ -1326,17 +1425,29 @@
24407         case sending:
24408                 req = current_req;
24409                 if (data_len < 0) {
24410 +#ifdef CONFIG_XMON
24411 +                       if (LIVE_DEBUG(req))
24412 +                               xmon_printf("s");
24413 +#endif /* CONFIG_XMON */
24414                         data_len = req->nbytes - 1;
24415                         send_byte(data_len);
24416                         break;
24417                 }
24418                 if (data_index <= data_len) {
24419 +#ifdef CONFIG_XMON
24420 +                       if (LIVE_DEBUG(req))
24421 +                               xmon_printf("S");
24422 +#endif /* CONFIG_XMON */
24423                         send_byte(req->data[data_index++]);
24424                         break;
24425                 }
24426                 req->sent = 1;
24427                 data_len = pmu_data_len[req->data[0]][1];
24428                 if (data_len == 0) {
24429 +#ifdef CONFIG_XMON
24430 +                       if (LIVE_DEBUG(req))
24431 +                               xmon_printf("D");
24432 +#endif /* CONFIG_XMON */
24433                         pmu_state = idle;
24434                         current_req = req->next;
24435                         if (req->reply_expected)
24436 @@ -1344,6 +1455,10 @@
24437                         else
24438                                 return req;
24439                 } else {
24440 +#ifdef CONFIG_XMON
24441 +                       if (LIVE_DEBUG(req))
24442 +                               xmon_printf("-");
24443 +#endif /* CONFIG_XMON */
24444                         pmu_state = reading;
24445                         data_index = 0;
24446                         reply_ptr = req->reply + req->reply_len;
24447 @@ -1357,15 +1472,27 @@
24448                 pmu_state = reading_intr;
24449                 reply_ptr = interrupt_data[int_data_last];
24450                 recv_byte();
24451 +               if (gpio_irq >= 0 && !gpio_irq_enabled) {
24452 +                       enable_irq(gpio_irq);
24453 +                       gpio_irq_enabled = 1;
24454 +               }
24455                 break;
24456  
24457         case reading:
24458         case reading_intr:
24459                 if (data_len == -1) {
24460 +#ifdef CONFIG_XMON
24461 +                       if (LIVE_DEBUG(current_req))
24462 +                               xmon_printf("r");
24463 +#endif /* CONFIG_XMON */
24464                         data_len = bite;
24465                         if (bite > 32)
24466                                 printk(KERN_ERR "PMU: bad reply len %d\n", bite);
24467                 } else if (data_index < 32) {
24468 +#ifdef CONFIG_XMON
24469 +                       if (LIVE_DEBUG(current_req))
24470 +                               xmon_printf("R");
24471 +#endif /* CONFIG_XMON */
24472                         reply_ptr[data_index++] = bite;
24473                 }
24474                 if (data_index < data_len) {
24475 @@ -1373,15 +1500,29 @@
24476                         break;
24477                 }
24478  
24479 +#ifdef CONFIG_XMON
24480 +               if (LIVE_DEBUG(current_req)) {
24481 +                       whacky_debug = 1;
24482 +                       xmon_printf("D");
24483 +               }
24484 +#endif /* CONFIG_XMON */
24485                 if (pmu_state == reading_intr) {
24486                         pmu_state = idle;
24487                         int_data_state[int_data_last] = int_data_ready;
24488                         interrupt_data_len[int_data_last] = data_len;
24489                 } else {
24490                         req = current_req;
24491 +                       /* 
24492 +                        * For PMU sleep and freq change requests, we lock the
24493 +                        * PMU until it's explicitely unlocked. This avoids any
24494 +                        * spurrious event polling getting in
24495 +                        */
24496                         current_req = req->next;
24497                         req->reply_len += data_index;
24498 -                       pmu_state = idle;
24499 +                       if (req->data[0] == PMU_SLEEP || req->data[0] == PMU_CPU_SPEED)
24500 +                               pmu_state = locked;
24501 +                       else
24502 +                               pmu_state = idle;
24503                         return req;
24504                 }
24505                 break;
24506 @@ -1411,6 +1552,10 @@
24507                 intr = in_8(&via[IFR]) & (SR_INT | CB1_INT);
24508                 if (intr == 0)
24509                         break;
24510 +#ifdef CONFIG_XMON
24511 +               if (whacky_debug)
24512 +                       xmon_printf("|%02x|", intr);
24513 +#endif /* CONFIG_XMON */
24514                 handled = 1;
24515                 if (++nloop > 1000) {
24516                         printk(KERN_DEBUG "PMU: stuck in intr loop, "
24517 @@ -1419,8 +1564,10 @@
24518                         break;
24519                 }
24520                 out_8(&via[IFR], intr);
24521 -               if (intr & CB1_INT)
24522 +               if (intr & CB1_INT) {
24523                         adb_int_pending = 1;
24524 +                       pmu_irq_stats[0]++;
24525 +               }
24526                 if (intr & SR_INT) {
24527                         req = pmu_sr_intr(regs);
24528                         if (req)
24529 @@ -1431,6 +1578,10 @@
24530  recheck:
24531         if (pmu_state == idle) {
24532                 if (adb_int_pending) {
24533 +#ifdef CONFIG_XMON
24534 +                       if (whacky_debug)
24535 +                               xmon_printf("!A!");
24536 +#endif /* CONFIG_XMON */
24537                         if (int_data_state[0] == int_data_empty)
24538                                 int_data_last = 0;
24539                         else if (int_data_state[1] == int_data_empty)
24540 @@ -1479,11 +1630,33 @@
24541         return IRQ_RETVAL(handled);
24542  }
24543  
24544 +void __pmac
24545 +pmu_unlock(void)
24546 +{
24547 +       unsigned long flags;
24548 +
24549 +       spin_lock_irqsave(&pmu_lock, flags);
24550 +       if (pmu_state == locked)
24551 +               pmu_state = idle;
24552 +       adb_int_pending = 1;
24553 +       spin_unlock_irqrestore(&pmu_lock, flags);
24554 +}
24555 +
24556 +
24557  static irqreturn_t __pmac
24558  gpio1_interrupt(int irq, void *arg, struct pt_regs *regs)
24559  {
24560 +       unsigned long flags;
24561 +
24562         if ((in_8(gpio_reg + 0x9) & 0x02) == 0) {
24563 +               spin_lock_irqsave(&pmu_lock, flags);
24564 +               if (gpio_irq_enabled > 0) {
24565 +                       disable_irq_nosync(gpio_irq);
24566 +                       gpio_irq_enabled = 0;
24567 +               }
24568 +               pmu_irq_stats[1]++;
24569                 adb_int_pending = 1;
24570 +               spin_unlock_irqrestore(&pmu_lock, flags);
24571                 via_pmu_interrupt(0, 0, 0);
24572                 return IRQ_HANDLED;
24573         }
24574 @@ -1507,13 +1680,11 @@
24575         if (on) {
24576                 pmu_request(&req, NULL, 2, PMU_BACKLIGHT_BRIGHT,
24577                             backlight_to_bright[level]);
24578 -               while (!req.complete)
24579 -                       pmu_poll();
24580 +               pmu_wait_complete(&req);
24581         }
24582         pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
24583                     PMU_POW_BACKLIGHT | (on ? PMU_POW_ON : PMU_POW_OFF));
24584 -       while (!req.complete)
24585 -               pmu_poll();
24586 +               pmu_wait_complete(&req);
24587  
24588         return 0;
24589  }
24590 @@ -1549,8 +1720,7 @@
24591  
24592         pmu_request(&req, NULL, 2, PMU_POWER_CTRL, PMU_POW_IRLED |
24593             (on ? PMU_POW_ON : PMU_POW_OFF));
24594 -       while (!req.complete)
24595 -               pmu_poll();
24596 +       pmu_wait_complete(&req);
24597  }
24598  
24599  void __pmac
24600 @@ -1570,8 +1740,7 @@
24601         }
24602  
24603         pmu_request(&req, NULL, 1, PMU_RESET);
24604 -       while(!req.complete || (pmu_state != idle))
24605 -               pmu_poll();
24606 +       pmu_wait_complete(&req);
24607         for (;;)
24608                 ;
24609  }
24610 @@ -1588,14 +1757,12 @@
24611         if (pmu_kind != PMU_KEYLARGO_BASED) {
24612                 pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, PMU_INT_ADB |
24613                                                 PMU_INT_TICK );
24614 -               while(!req.complete)
24615 -                       pmu_poll();
24616 +               pmu_wait_complete(&req);
24617         }
24618  
24619         pmu_request(&req, NULL, 5, PMU_SHUTDOWN,
24620                     'M', 'A', 'T', 'T');
24621 -       while(!req.complete || (pmu_state != idle))
24622 -               pmu_poll();
24623 +       pmu_wait_complete(&req);
24624         for (;;)
24625                 ;
24626  }
24627 @@ -1606,25 +1773,261 @@
24628         return via != 0;
24629  }
24630  
24631 -#ifdef CONFIG_PMAC_PBOOK
24632 +struct pmu_i2c_hdr {
24633 +       u8      bus;
24634 +       u8      mode;
24635 +       u8      bus2;
24636 +       u8      address;
24637 +       u8      sub_addr;
24638 +       u8      comb_addr;
24639 +       u8      count;
24640 +};
24641  
24642 -static LIST_HEAD(sleep_notifiers);
24643 +int
24644 +pmu_i2c_combined_read(int bus, int addr, int subaddr,  u8* data, int len)
24645 +{
24646 +       struct adb_request      req;
24647 +       struct pmu_i2c_hdr      *hdr = (struct pmu_i2c_hdr *)&req.data[1];
24648 +       int retry;
24649 +       int rc;
24650 +
24651 +       for (retry=0; retry<16; retry++) {
24652 +               memset(&req, 0, sizeof(req));
24653 +
24654 +               hdr->bus = bus;
24655 +               hdr->address = addr & 0xfe;
24656 +               hdr->mode = PMU_I2C_MODE_COMBINED;
24657 +               hdr->bus2 = 0;
24658 +               hdr->sub_addr = subaddr;
24659 +               hdr->comb_addr = addr | 1;
24660 +               hdr->count = len;
24661 +               
24662 +               req.nbytes = sizeof(struct pmu_i2c_hdr) + 1;
24663 +               req.reply_expected = 0;
24664 +               req.reply_len = 0;
24665 +               req.data[0] = PMU_I2C_CMD;
24666 +               req.reply[0] = 0xff;
24667 +               rc = pmu_queue_request(&req);
24668 +               if (rc)
24669 +                       return rc;
24670 +               while(!req.complete)
24671 +                       pmu_poll();
24672 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
24673 +                       break;
24674 +               mdelay(15);
24675 +       }
24676 +       if (req.reply[0] != PMU_I2C_STATUS_OK)
24677 +               return -1;
24678  
24679 -#ifdef CONFIG_PM
24680 -static int __pmac
24681 -generic_notify_sleep(struct pmu_sleep_notifier *self, int when)
24682 +       for (retry=0; retry<16; retry++) {
24683 +               memset(&req, 0, sizeof(req));
24684 +
24685 +               mdelay(15);
24686 +
24687 +               hdr->bus = PMU_I2C_BUS_STATUS;
24688 +               req.reply[0] = 0xff;
24689 +               
24690 +               req.nbytes = 2;
24691 +               req.reply_expected = 0;
24692 +               req.reply_len = 0;
24693 +               req.data[0] = PMU_I2C_CMD;
24694 +               rc = pmu_queue_request(&req);
24695 +               if (rc)
24696 +                       return rc;
24697 +               while(!req.complete)
24698 +                       pmu_poll();
24699 +               if (req.reply[0] == PMU_I2C_STATUS_DATAREAD) {
24700 +                       memcpy(data, &req.reply[1], req.reply_len - 1);
24701 +                       return req.reply_len - 1;
24702 +               }
24703 +       }
24704 +       return -1;
24705 +}
24706 +
24707 +int
24708 +pmu_i2c_stdsub_write(int bus, int addr, int subaddr,  u8* data, int len)
24709  {
24710 -       switch (when) {
24711 -               case PBOOK_SLEEP_NOW:
24712 -                       if (pm_send_all(PM_SUSPEND, (void *)3))
24713 -                               return PBOOK_SLEEP_REJECT;
24714 +       struct adb_request      req;
24715 +       struct pmu_i2c_hdr      *hdr = (struct pmu_i2c_hdr *)&req.data[1];
24716 +       int retry;
24717 +       int rc;
24718 +
24719 +       for (retry=0; retry<16; retry++) {
24720 +               memset(&req, 0, sizeof(req));
24721 +
24722 +               hdr->bus = bus;
24723 +               hdr->address = addr & 0xfe;
24724 +               hdr->mode = PMU_I2C_MODE_STDSUB;
24725 +               hdr->bus2 = 0;
24726 +               hdr->sub_addr = subaddr;
24727 +               hdr->comb_addr = addr & 0xfe;
24728 +               hdr->count = len;
24729 +
24730 +               req.data[0] = PMU_I2C_CMD;
24731 +               memcpy(&req.data[sizeof(struct pmu_i2c_hdr) + 1], data, len);
24732 +               req.nbytes = sizeof(struct pmu_i2c_hdr) + len + 1;
24733 +               req.reply_expected = 0;
24734 +               req.reply_len = 0;
24735 +               req.reply[0] = 0xff;
24736 +               rc = pmu_queue_request(&req);
24737 +               if (rc)
24738 +                       return rc;
24739 +               while(!req.complete)
24740 +                       pmu_poll();
24741 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
24742                         break;
24743 -               case PBOOK_WAKE:
24744 -                       (void) pm_send_all(PM_RESUME, (void *)0);
24745 +               mdelay(15);
24746         }
24747 -       return PBOOK_SLEEP_OK;
24748 +       if (req.reply[0] != PMU_I2C_STATUS_OK)
24749 +               return -1;
24750 +
24751 +       for (retry=0; retry<16; retry++) {
24752 +               memset(&req, 0, sizeof(req));
24753 +
24754 +               mdelay(15);
24755 +
24756 +               hdr->bus = PMU_I2C_BUS_STATUS;
24757 +               req.reply[0] = 0xff;
24758 +               
24759 +               req.nbytes = 2;
24760 +               req.reply_expected = 0;
24761 +               req.reply_len = 0;
24762 +               req.data[0] = PMU_I2C_CMD;
24763 +               rc = pmu_queue_request(&req);
24764 +               if (rc)
24765 +                       return rc;
24766 +               while(!req.complete)
24767 +                       pmu_poll();
24768 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
24769 +                       return len;
24770 +       }
24771 +       return -1;
24772  }
24773 -#endif /* CONFIG_PM */
24774 +
24775 +int
24776 +pmu_i2c_simple_read(int bus, int addr,  u8* data, int len)
24777 +{
24778 +       struct adb_request      req;
24779 +       struct pmu_i2c_hdr      *hdr = (struct pmu_i2c_hdr *)&req.data[1];
24780 +       int retry;
24781 +       int rc;
24782 +
24783 +       for (retry=0; retry<16; retry++) {
24784 +               memset(&req, 0, sizeof(req));
24785 +
24786 +               hdr->bus = bus;
24787 +               hdr->address = addr | 1;
24788 +               hdr->mode = PMU_I2C_MODE_SIMPLE;
24789 +               hdr->bus2 = 0;
24790 +               hdr->sub_addr = 0;
24791 +               hdr->comb_addr = 0;
24792 +               hdr->count = len;
24793 +
24794 +               req.data[0] = PMU_I2C_CMD;
24795 +               req.nbytes = sizeof(struct pmu_i2c_hdr) + 1;
24796 +               req.reply_expected = 0;
24797 +               req.reply_len = 0;
24798 +               req.reply[0] = 0xff;
24799 +               rc = pmu_queue_request(&req);
24800 +               if (rc)
24801 +                       return rc;
24802 +               while(!req.complete)
24803 +                       pmu_poll();
24804 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
24805 +                       break;
24806 +               mdelay(15);
24807 +       }
24808 +       if (req.reply[0] != PMU_I2C_STATUS_OK)
24809 +               return -1;
24810 +
24811 +       for (retry=0; retry<16; retry++) {
24812 +               memset(&req, 0, sizeof(req));
24813 +
24814 +               mdelay(15);
24815 +
24816 +               hdr->bus = PMU_I2C_BUS_STATUS;
24817 +               req.reply[0] = 0xff;
24818 +               
24819 +               req.nbytes = 2;
24820 +               req.reply_expected = 0;
24821 +               req.reply_len = 0;
24822 +               req.data[0] = PMU_I2C_CMD;
24823 +               rc = pmu_queue_request(&req);
24824 +               if (rc)
24825 +                       return rc;
24826 +               while(!req.complete)
24827 +                       pmu_poll();
24828 +               if (req.reply[0] == PMU_I2C_STATUS_DATAREAD) {
24829 +                       memcpy(data, &req.reply[1], req.reply_len - 1);
24830 +                       return req.reply_len - 1;
24831 +               }
24832 +       }
24833 +       return -1;
24834 +}
24835 +
24836 +int
24837 +pmu_i2c_simple_write(int bus, int addr,  u8* data, int len)
24838 +{
24839 +       struct adb_request      req;
24840 +       struct pmu_i2c_hdr      *hdr = (struct pmu_i2c_hdr *)&req.data[1];
24841 +       int retry;
24842 +       int rc;
24843 +
24844 +       for (retry=0; retry<16; retry++) {
24845 +               memset(&req, 0, sizeof(req));
24846 +
24847 +               hdr->bus = bus;
24848 +               hdr->address = addr & 0xfe;
24849 +               hdr->mode = PMU_I2C_MODE_SIMPLE;
24850 +               hdr->bus2 = 0;
24851 +               hdr->sub_addr = 0;
24852 +               hdr->comb_addr = 0;
24853 +               hdr->count = len;
24854 +
24855 +               req.data[0] = PMU_I2C_CMD;
24856 +               memcpy(&req.data[sizeof(struct pmu_i2c_hdr) + 1], data, len);
24857 +               req.nbytes = sizeof(struct pmu_i2c_hdr) + len + 1;
24858 +               req.reply_expected = 0;
24859 +               req.reply_len = 0;
24860 +               req.reply[0] = 0xff;
24861 +               rc = pmu_queue_request(&req);
24862 +               if (rc)
24863 +                       return rc;
24864 +               while(!req.complete)
24865 +                       pmu_poll();
24866 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
24867 +                       break;
24868 +               mdelay(15);
24869 +       }
24870 +       if (req.reply[0] != PMU_I2C_STATUS_OK)
24871 +               return -1;
24872 +
24873 +       for (retry=0; retry<16; retry++) {
24874 +               memset(&req, 0, sizeof(req));
24875 +
24876 +               mdelay(15);
24877 +
24878 +               hdr->bus = PMU_I2C_BUS_STATUS;
24879 +               req.reply[0] = 0xff;
24880 +               
24881 +               req.nbytes = 2;
24882 +               req.reply_expected = 0;
24883 +               req.reply_len = 0;
24884 +               req.data[0] = PMU_I2C_CMD;
24885 +               rc = pmu_queue_request(&req);
24886 +               if (rc)
24887 +                       return rc;
24888 +               while(!req.complete)
24889 +                       pmu_poll();
24890 +               if (req.reply[0] == PMU_I2C_STATUS_OK)
24891 +                       return len;
24892 +       }
24893 +       return -1;
24894 +}
24895 +
24896 +#ifdef CONFIG_PMAC_PBOOK
24897 +
24898 +static LIST_HEAD(sleep_notifiers);
24899  
24900  int
24901  pmu_register_sleep_notifier(struct pmu_sleep_notifier *n)
24902 @@ -1885,90 +2288,166 @@
24903  }
24904  
24905  extern long sys_sync(void);
24906 +extern void pm_prepare_console(void);
24907 +extern void pm_restore_console(void);
24908  
24909 -#define        GRACKLE_PM      (1<<7)
24910 -#define GRACKLE_DOZE   (1<<5)
24911 -#define        GRACKLE_NAP     (1<<4)
24912 -#define        GRACKLE_SLEEP   (1<<3)
24913 -
24914 -int __pmac
24915 -powerbook_sleep_G3(void)
24916 +static int __pmac
24917 +pmac_suspend_devices(void)
24918  {
24919 -       unsigned long save_l2cr;
24920 -       unsigned short pmcr1;
24921 -       struct adb_request req;
24922         int ret;
24923 -       struct pci_dev *grackle;
24924 -
24925 -       grackle = pci_find_slot(0, 0);
24926 -       if (!grackle)
24927 -               return -ENODEV;
24928 -
24929 -       /* Notify device drivers */
24930 +       
24931 +       pm_prepare_console();
24932 +       
24933 +       /* Notify old-style device drivers & userland */
24934         ret = broadcast_sleep(PBOOK_SLEEP_REQUEST, PBOOK_SLEEP_REJECT);
24935         if (ret != PBOOK_SLEEP_OK) {
24936 -               printk("pmu: sleep rejected\n");
24937 +               printk(KERN_ERR "Sleep rejected by drivers\n");
24938                 return -EBUSY;
24939         }
24940  
24941         /* Sync the disks. */
24942         /* XXX It would be nice to have some way to ensure that
24943 -        * nobody is dirtying any new buffers while we wait.
24944 -        * BenH: Moved to _after_ sleep request and changed video
24945 -        * drivers to vmalloc() during sleep request. This way, all
24946 -        * vmalloc's are done before actual sleep of block drivers */
24947 +        * nobody is dirtying any new buffers while we wait. That
24948 +        * could be acheived using the refrigerator for processes
24949 +        * that swsusp uses
24950 +        */
24951         sys_sync();
24952  
24953         /* Sleep can fail now. May not be very robust but useful for debugging */
24954         ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
24955         if (ret != PBOOK_SLEEP_OK) {
24956 -               printk("pmu: sleep failed\n");
24957 +               printk(KERN_ERR "Driver sleep failed\n");
24958                 return -EBUSY;
24959         }
24960  
24961 -       /* Wait for completion of async backlight requests */
24962 -       while (!bright_req_1.complete || !bright_req_2.complete ||
24963 -               !bright_req_3.complete || !batt_req.complete)
24964 -               pmu_poll();
24965 +       /* Send suspend call to devices, hold the device core's dpm_sem */
24966 +       ret = device_suspend(PM_SUSPEND_MEM);
24967 +       if (ret) {
24968 +               printk(KERN_ERR "Driver sleep failed\n");
24969 +               broadcast_wake();
24970 +               return -EBUSY;
24971 +       }
24972         
24973 -       /* Turn off various things. Darwin does some retry tests here... */
24974 -       pmu_request(&req, NULL, 2, PMU_POWER_CTRL0, PMU_POW0_OFF|PMU_POW0_HARD_DRIVE);
24975 -       while (!req.complete)
24976 -               pmu_poll();
24977 -       pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
24978 -               PMU_POW_OFF|PMU_POW_BACKLIGHT|PMU_POW_IRLED|PMU_POW_MEDIABAY);
24979 -       while (!req.complete)
24980 -               pmu_poll();
24981 -
24982 -       /* Disable all interrupts */
24983 -       pmac_sleep_save_intrs(-1);
24984 -
24985 -       /* Make sure the PMU is idle */
24986 -       while (pmu_state != idle)
24987 -               pmu_poll();
24988 -
24989         /* Make sure the decrementer won't interrupt us */
24990         asm volatile("mtdec %0" : : "r" (0x7fffffff));
24991         /* Make sure any pending DEC interrupt occurring while we did
24992          * the above didn't re-enable the DEC */
24993         mb();
24994         asm volatile("mtdec %0" : : "r" (0x7fffffff));
24995 -       
24996 -       /* We can now disable MSR_EE */
24997 +
24998 +       /* We can now disable MSR_EE. This code of course works properly only
24999 +        * on UP machines... For SMP, if we ever implement sleep, we'll have to
25000 +        * stop the "other" CPUs way before we do all that stuff.
25001 +        */
25002         local_irq_disable();
25003  
25004 -       /* Giveup the FPU */
25005 +       /* Broadcast power down irq
25006 +        * This isn't that useful in most cases (only directly wired devices can
25007 +        * use this but still... This will take care of sysdev's as well, so
25008 +        * we exit from here with local irqs disabled and PIC off.
25009 +        */
25010 +       ret = device_power_down(PM_SUSPEND_MEM);
25011 +       if (ret) {
25012 +               wakeup_decrementer();
25013 +               local_irq_enable();
25014 +               device_resume();
25015 +               broadcast_wake();
25016 +               printk(KERN_ERR "Driver powerdown failed\n");
25017 +               return -EBUSY;
25018 +       }
25019 +
25020 +       /* Wait for completion of async backlight requests */
25021 +       while (!bright_req_1.complete || !bright_req_2.complete ||
25022 +               !bright_req_3.complete || !batt_req.complete)
25023 +               pmu_poll();
25024 +
25025 +       /* Giveup the lazy FPU & vec so we don't have to back them
25026 +        * up from the low level code
25027 +        */
25028         enable_kernel_fp();
25029  
25030 +#ifdef CONFIG_ALTIVEC
25031 +       if (cur_cpu_spec[0]->cpu_features & CPU_FTR_ALTIVEC)
25032 +               enable_kernel_altivec();
25033 +#endif /* CONFIG_ALTIVEC */
25034 +
25035 +       return 0;
25036 +}
25037 +
25038 +static int __pmac
25039 +pmac_wakeup_devices(void)
25040 +{
25041 +       mdelay(100);
25042 +
25043 +       /* Power back up system devices (including the PIC) */
25044 +       device_power_up();
25045 +
25046 +       pmu_blink(1);
25047 +
25048 +       /* Force a poll of ADB interrupts */
25049 +       adb_int_pending = 1;
25050 +       via_pmu_interrupt(0, 0, 0);
25051 +
25052 +       /* Restart jiffies & scheduling */
25053 +       wakeup_decrementer();
25054 +
25055 +       /* Re-enable local CPU interrupts */
25056 +       local_irq_enable();
25057 +
25058 +       pmu_blink(1);
25059 +
25060 +       /* Resume devices */
25061 +       device_resume();
25062 +
25063 +       /* Notify old style drivers */
25064 +       broadcast_wake();
25065 +
25066 +       pm_restore_console();
25067 +
25068 +       return 0;
25069 +}
25070 +
25071 +#define        GRACKLE_PM      (1<<7)
25072 +#define GRACKLE_DOZE   (1<<5)
25073 +#define        GRACKLE_NAP     (1<<4)
25074 +#define        GRACKLE_SLEEP   (1<<3)
25075 +
25076 +int __pmac
25077 +powerbook_sleep_grackle(void)
25078 +{
25079 +       unsigned long save_l2cr;
25080 +       unsigned short pmcr1;
25081 +       struct adb_request req;
25082 +       int ret;
25083 +       struct pci_dev *grackle;
25084 +
25085 +       grackle = pci_find_slot(0, 0);
25086 +       if (!grackle)
25087 +               return -ENODEV;
25088 +
25089 +       ret = pmac_suspend_devices();
25090 +       if (ret) {
25091 +               printk(KERN_ERR "Sleep rejected by devices\n");
25092 +               return ret;
25093 +       }
25094 +       
25095 +       /* Turn off various things. Darwin does some retry tests here... */
25096 +       pmu_request(&req, NULL, 2, PMU_POWER_CTRL0, PMU_POW0_OFF|PMU_POW0_HARD_DRIVE);
25097 +       pmu_wait_complete(&req);
25098 +       pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
25099 +               PMU_POW_OFF|PMU_POW_BACKLIGHT|PMU_POW_IRLED|PMU_POW_MEDIABAY);
25100 +       pmu_wait_complete(&req);
25101 +
25102         /* For 750, save backside cache setting and disable it */
25103         save_l2cr = _get_L2CR();        /* (returns -1 if not available) */
25104         if (save_l2cr != 0xffffffff && (save_l2cr & L2CR_L2E) != 0)
25105                 _set_L2CR(save_l2cr & 0x7fffffff);
25106  
25107 -       /* Ask the PMU to put us to sleep */
25108 -       pmu_request(&req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T');
25109 -       while (!req.complete)
25110 -               pmu_poll();
25111 +       if (!__fake_sleep) {
25112 +               /* Ask the PMU to put us to sleep */
25113 +               pmu_request(&req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T');
25114 +               pmu_wait_complete(&req);
25115 +       }
25116  
25117         /* The VIA is supposed not to be restored correctly*/
25118         save_via_state();
25119 @@ -1982,7 +2461,10 @@
25120         pci_write_config_word(grackle, 0x70, pmcr1);
25121  
25122         /* Call low-level ASM sleep handler */
25123 -       low_sleep_handler();
25124 +       if (__fake_sleep)
25125 +               mdelay(5000);
25126 +       else
25127 +               low_sleep_handler();
25128  
25129         /* We're awake again, stop grackle PM */
25130         pci_read_config_word(grackle, 0x70, &pmcr1);
25131 @@ -2001,36 +2483,17 @@
25132         set_context(current->active_mm->context, current->active_mm->pgd);
25133  
25134         /* Power things up */
25135 -       pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0xfc);
25136 -       while (!req.complete)
25137 -               pmu_poll();
25138 +       pmu_unlock();
25139 +       pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, pmu_intr_mask);
25140 +       pmu_wait_complete(&req);
25141         pmu_request(&req, NULL, 2, PMU_POWER_CTRL0,
25142                         PMU_POW0_ON|PMU_POW0_HARD_DRIVE);
25143 -       while (!req.complete)
25144 -               pmu_poll();
25145 +       pmu_wait_complete(&req);
25146         pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
25147                         PMU_POW_ON|PMU_POW_BACKLIGHT|PMU_POW_CHARGER|PMU_POW_IRLED|PMU_POW_MEDIABAY);
25148 -       while (!req.complete)
25149 -               pmu_poll();
25150 -
25151 -       /* reenable interrupt controller */
25152 -       pmac_sleep_restore_intrs();
25153 +       pmu_wait_complete(&req);
25154  
25155 -       /* Leave some time for HW to settle down */
25156 -       mdelay(100);
25157 -
25158 -       /* Restart jiffies & scheduling */
25159 -       wakeup_decrementer();
25160 -
25161 -       /* Force a poll of ADB interrupts */
25162 -       adb_int_pending = 1;
25163 -       via_pmu_interrupt(0, 0, 0);
25164 -
25165 -       /* Re-enable local CPU interrupts */
25166 -       local_irq_enable();
25167 -
25168 -       /* Notify drivers */
25169 -       broadcast_wake();
25170 +       pmac_wakeup_devices();
25171  
25172         return 0;
25173  }
25174 @@ -2048,68 +2511,20 @@
25175                 return -ENOSYS;
25176         }
25177         
25178 -       /* Notify device drivers */
25179 -       ret = broadcast_sleep(PBOOK_SLEEP_REQUEST, PBOOK_SLEEP_REJECT);
25180 -       if (ret != PBOOK_SLEEP_OK) {
25181 -               printk("pmu: sleep rejected\n");
25182 -               return -EBUSY;
25183 -       }
25184 -
25185 -       /* Sync the disks. */
25186 -       /* XXX It would be nice to have some way to ensure that
25187 -        * nobody is dirtying any new buffers while we wait.
25188 -        * BenH: Moved to _after_ sleep request and changed video
25189 -        * drivers to vmalloc() during sleep request. This way, all
25190 -        * vmalloc's are done before actual sleep of block drivers */
25191 -       sys_sync();
25192 -
25193 -       /* Sleep can fail now. May not be very robust but useful for debugging */
25194 -       ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
25195 -       if (ret != PBOOK_SLEEP_OK) {
25196 -               printk("pmu: sleep failed\n");
25197 -               return -EBUSY;
25198 +       ret = pmac_suspend_devices();
25199 +       if (ret) {
25200 +               printk(KERN_ERR "Sleep rejected by devices\n");
25201 +               return ret;
25202         }
25203 -       /* Wait for completion of async backlight requests */
25204 -       while (!bright_req_1.complete || !bright_req_2.complete ||
25205 -               !bright_req_3.complete || !batt_req.complete)
25206 -               pmu_poll();
25207 -
25208 +       
25209         /* Tell PMU what events will wake us up */
25210         pmu_request(&req, NULL, 4, PMU_POWER_EVENTS, PMU_PWR_CLR_WAKEUP_EVENTS,
25211                 0xff, 0xff);
25212 -       while (!req.complete)
25213 -               pmu_poll();
25214 -
25215 +       pmu_wait_complete(&req);
25216         pmu_request(&req, NULL, 4, PMU_POWER_EVENTS, PMU_PWR_SET_WAKEUP_EVENTS,
25217                 0, PMU_PWR_WAKEUP_KEY |
25218                 (option_lid_wakeup ? PMU_PWR_WAKEUP_LID_OPEN : 0));
25219 -       while (!req.complete)
25220 -               pmu_poll();
25221 -               
25222 -       /* Save & disable all interrupts */
25223 -       openpic_sleep_save_intrs();
25224 -
25225 -       /* Make sure the PMU is idle */
25226 -       while (pmu_state != idle)
25227 -               pmu_poll();
25228 -
25229 -       /* Make sure the decrementer won't interrupt us */
25230 -       asm volatile("mtdec %0" : : "r" (0x7fffffff));
25231 -       /* Make sure any pending DEC interrupt occurring while we did
25232 -        * the above didn't re-enable the DEC */
25233 -       mb();
25234 -       asm volatile("mtdec %0" : : "r" (0x7fffffff));
25235 -
25236 -       /* We can now disable MSR_EE */
25237 -       local_irq_disable();
25238 -
25239 -       /* Giveup the FPU & vec */
25240 -       enable_kernel_fp();
25241 -
25242 -#ifdef CONFIG_ALTIVEC
25243 -       if (cur_cpu_spec[0]->cpu_features & CPU_FTR_ALTIVEC)
25244 -               enable_kernel_altivec();
25245 -#endif /* CONFIG_ALTIVEC */
25246 +       pmu_wait_complete(&req);
25247  
25248         /* Save & disable L2 and L3 caches*/
25249         save_l3cr = _get_L3CR();        /* (returns -1 if not available) */
25250 @@ -2125,13 +2540,9 @@
25251         if (!__fake_sleep) {
25252                 /* Ask the PMU to put us to sleep */
25253                 pmu_request(&req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T');
25254 -               while (!req.complete && pmu_state != idle)
25255 -                       pmu_poll();
25256 +               pmu_wait_complete(&req);
25257         }
25258  
25259 -       out_8(&via[B], in_8(&via[B]) | TREQ);
25260 -       wait_for_ack();
25261 -
25262         /* The VIA is supposed not to be restored correctly*/
25263         save_via_state();
25264  
25265 @@ -2161,8 +2572,6 @@
25266         /* Don't restore PCI for now, it crashes. Maybe unnecessary on pbook */
25267         //pbook_pci_restore();
25268  
25269 -       pmu_blink(2);
25270 -               
25271         /* Restore L2 cache */
25272         if (save_l2cr != 0xffffffff && (save_l2cr & L2CR_L2E) != 0)
25273                 _set_L2CR(save_l2cr);
25274 @@ -2174,31 +2583,15 @@
25275         set_context(current->active_mm->context, current->active_mm->pgd);
25276  
25277         /* Tell PMU we are ready */
25278 +       pmu_unlock();
25279         pmu_request(&req, NULL, 2, PMU_SYSTEM_READY, 2);
25280 -       while (!req.complete)
25281 -               pmu_poll();
25282 -       pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0xfc);
25283 -       while (!req.complete)
25284 -               pmu_poll();
25285 -               
25286 -       /* reenable interrupt controller */
25287 -       openpic_sleep_restore_intrs();
25288 -
25289 -       /* Leave some time for HW to settle down */
25290 -       mdelay(100);
25291 -
25292 -       /* Restart jiffies & scheduling */
25293 -       wakeup_decrementer();
25294 +       pmu_wait_complete(&req);
25295 +       pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, pmu_intr_mask);
25296 +       pmu_wait_complete(&req);
25297  
25298 -       /* Force a poll of ADB interrupts */
25299 -       adb_int_pending = 1;
25300 -       via_pmu_interrupt(0, 0, 0);
25301 +       pmu_blink(1);
25302  
25303 -       /* Re-enable local CPU interrupts */
25304 -       local_irq_enable();
25305 -
25306 -       /* Notify drivers */
25307 -       broadcast_wake();
25308 +       pmac_wakeup_devices();
25309  
25310         return 0;
25311  }
25312 @@ -2227,45 +2620,13 @@
25313         /* Allocate room for PCI save */
25314         pbook_alloc_pci_save();
25315  
25316 -       /* Notify device drivers */
25317 -       ret = broadcast_sleep(PBOOK_SLEEP_REQUEST, PBOOK_SLEEP_REJECT);
25318 -       if (ret != PBOOK_SLEEP_OK) {
25319 -               pbook_free_pci_save();
25320 -               printk("pmu: sleep rejected\n");
25321 -               return -EBUSY;
25322 -       }
25323 -
25324 -       /* Sync the disks. */
25325 -       /* XXX It would be nice to have some way to ensure that
25326 -        * nobody is dirtying any new buffers while we wait.
25327 -        * BenH: Moved to _after_ sleep request and changed video
25328 -        * drivers to vmalloc() during sleep request. This way, all
25329 -        * vmalloc's are done before actual sleep of block drivers */
25330 -       sys_sync();
25331 -
25332 -       /* Sleep can fail now. May not be very robust but useful for debugging */
25333 -       ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
25334 -       if (ret != PBOOK_SLEEP_OK) {
25335 -               printk("pmu: sleep failed\n");
25336 +       ret = pmac_suspend_devices();
25337 +       if (ret) {
25338                 pbook_free_pci_save();
25339 -               return -EBUSY;
25340 +               printk(KERN_ERR "Sleep rejected by devices\n");
25341 +               return ret;
25342         }
25343  
25344 -       /* Wait for completion of async backlight requests */
25345 -       while (!bright_req_1.complete || !bright_req_2.complete ||
25346 -               !bright_req_3.complete || !batt_req.complete)
25347 -               pmu_poll();
25348 -
25349 -       /* Disable all interrupts except pmu */
25350 -       pmac_sleep_save_intrs(vias->intrs[0].line);
25351 -
25352 -       /* Make sure the decrementer won't interrupt us */
25353 -       asm volatile("mtdec %0" : : "r" (0x7fffffff));
25354 -       /* Make sure any pending DEC interrupt occurring while we did
25355 -        * the above didn't re-enable the DEC */
25356 -       mb();
25357 -       asm volatile("mtdec %0" : : "r" (0x7fffffff));
25358 -
25359         /* Save the state of PCI config space for some slots */
25360         pbook_pci_save();
25361  
25362 @@ -2303,25 +2664,13 @@
25363         out_be32(mem_ctrl_sleep, 0x3f);
25364         pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,0);
25365         pbook_pci_restore();
25366 +       pmu_unlock();
25367  
25368         /* wait for the PMU interrupt sequence to complete */
25369         while (asleep)
25370                 mb();
25371  
25372 -       /* reenable interrupts */
25373 -       pmac_sleep_restore_intrs();
25374 -
25375 -       /* Leave some time for HW to settle down */
25376 -       mdelay(100);
25377 -
25378 -       /* Restart jiffies & scheduling */
25379 -       wakeup_decrementer();
25380 -
25381 -       /* Re-enable local CPU interrupts */
25382 -       local_irq_enable();
25383 -
25384 -       /* Notify drivers */
25385 -       broadcast_wake();
25386 +       pmac_wakeup_devices();
25387  
25388         pbook_free_pci_save();
25389         iounmap(mem_ctrl);
25390 @@ -2524,7 +2873,7 @@
25391                         break;
25392                 case PMU_HEATHROW_BASED:
25393                 case PMU_PADDINGTON_BASED:
25394 -                       error = powerbook_sleep_G3();
25395 +                       error = powerbook_sleep_grackle();
25396                         break;
25397                 case PMU_KEYLARGO_BASED:
25398                         error = powerbook_sleep_Core99();
25399 @@ -2676,8 +3025,15 @@
25400  
25401  EXPORT_SYMBOL(pmu_request);
25402  EXPORT_SYMBOL(pmu_poll);
25403 +EXPORT_SYMBOL(pmu_poll_adb);
25404 +EXPORT_SYMBOL(pmu_wait_complete);
25405  EXPORT_SYMBOL(pmu_suspend);
25406  EXPORT_SYMBOL(pmu_resume);
25407 +EXPORT_SYMBOL(pmu_unlock);
25408 +EXPORT_SYMBOL(pmu_i2c_combined_read);
25409 +EXPORT_SYMBOL(pmu_i2c_stdsub_write);
25410 +EXPORT_SYMBOL(pmu_i2c_simple_read);
25411 +EXPORT_SYMBOL(pmu_i2c_simple_write);
25412  #ifdef CONFIG_PMAC_PBOOK
25413  EXPORT_SYMBOL(pmu_register_sleep_notifier);
25414  EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
25415 diff -Nru a/drivers/md/md.c b/drivers/md/md.c
25416 --- a/drivers/md/md.c   Thu Aug  7 02:25:25 2003
25417 +++ b/drivers/md/md.c   Tue Aug 26 09:25:41 2003
25418 @@ -179,7 +179,6 @@
25419                 mddev_map[mdidx(mddev)] = NULL;
25420                 blk_put_queue(mddev->queue);
25421                 kfree(mddev);
25422 -               MOD_DEC_USE_COUNT;
25423         }
25424         spin_unlock(&all_mddevs_lock);
25425  }
25426 @@ -201,7 +200,6 @@
25427                 mddev_map[unit] = new;
25428                 list_add(&new->all_mddevs, &all_mddevs);
25429                 spin_unlock(&all_mddevs_lock);
25430 -               MOD_INC_USE_COUNT;
25431                 return new;
25432         }
25433         spin_unlock(&all_mddevs_lock);
25434 @@ -640,14 +638,13 @@
25435         /* make rdev->sb match mddev data..
25436          *
25437          * 1/ zero out disks
25438 -        * 2/ Add info for each disk, keeping track of highest desc_nr
25439 -        * 3/ any empty disks < highest become removed
25440 +        * 2/ Add info for each disk, keeping track of highest desc_nr (next_spare);
25441 +        * 3/ any empty disks < next_spare become removed
25442          *
25443          * disks[0] gets initialised to REMOVED because
25444          * we cannot be sure from other fields if it has
25445          * been initialised or not.
25446          */
25447 -       int highest = 0;
25448         int i;
25449         int active=0, working=0,failed=0,spare=0,nr_disks=0;
25450  
25451 @@ -718,17 +715,17 @@
25452                         spare++;
25453                         working++;
25454                 }
25455 -               if (rdev2->desc_nr > highest)
25456 -                       highest = rdev2->desc_nr;
25457         }
25458         
25459 -       /* now set the "removed" bit on any non-trailing holes */
25460 -       for (i=0; i<highest; i++) {
25461 +       /* now set the "removed" and "faulty" bits on any missing devices */
25462 +       for (i=0 ; i < mddev->raid_disks ; i++) {
25463                 mdp_disk_t *d = &sb->disks[i];
25464                 if (d->state == 0 && d->number == 0) {
25465                         d->number = i;
25466                         d->raid_disk = i;
25467                         d->state = (1<<MD_DISK_REMOVED);
25468 +                       d->state |= (1<<MD_DISK_FAULTY);
25469 +                       failed++;
25470                 }
25471         }
25472         sb->nr_disks = nr_disks;
25473 @@ -1612,12 +1609,6 @@
25474         spin_unlock(&pers_lock);
25475  
25476         blk_queue_make_request(mddev->queue, mddev->pers->make_request);
25477 -       printk("%s: setting max_sectors to %d, segment boundary to %d\n",
25478 -               disk->disk_name,
25479 -               chunk_size >> 9,
25480 -               (chunk_size>>1)-1);
25481 -       blk_queue_max_sectors(mddev->queue, chunk_size >> 9);
25482 -       blk_queue_segment_boundary(mddev->queue, (chunk_size>>1) - 1);
25483         mddev->queue->queuedata = mddev;
25484  
25485         err = mddev->pers->run(mddev);
25486 @@ -2366,17 +2357,14 @@
25487                         unsigned int cmd, unsigned long arg)
25488  {
25489         char b[BDEVNAME_SIZE];
25490 -       unsigned int minor;
25491 +       unsigned int minor = iminor(inode);
25492         int err = 0;
25493         struct hd_geometry *loc = (struct hd_geometry *) arg;
25494         mddev_t *mddev = NULL;
25495 -       kdev_t dev;
25496  
25497         if (!capable(CAP_SYS_ADMIN))
25498                 return -EACCES;
25499  
25500 -       dev = inode->i_rdev;
25501 -       minor = minor(dev);
25502         if (minor >= MAX_MD_DEVS) {
25503                 MD_BUG();
25504                 return -EINVAL;
25505 @@ -2615,7 +2603,7 @@
25506         /*
25507          * Succeed if we can find or allocate a mddev structure.
25508          */
25509 -       mddev_t *mddev = mddev_find(minor(inode->i_rdev));
25510 +       mddev_t *mddev = mddev_find(iminor(inode));
25511         int err = -ENOMEM;
25512  
25513         if (!mddev)
25514 @@ -3590,6 +3578,7 @@
25515                 if (!disks[i])
25516                         continue;
25517                 mddev = disk->private_data;
25518 +               export_array(mddev);
25519                 del_gendisk(disk);
25520                 put_disk(disk);
25521                 mddev_put(mddev);
25522 diff -Nru a/drivers/md/raid0.c b/drivers/md/raid0.c
25523 --- a/drivers/md/raid0.c        Thu Aug 14 18:16:17 2003
25524 +++ b/drivers/md/raid0.c        Sat Aug 23 15:07:18 2003
25525 @@ -231,6 +231,13 @@
25526         mdk_rdev_t *rdev;
25527         struct list_head *tmp;
25528  
25529 +       printk("md%d: setting max_sectors to %d, segment boundary to %d\n",
25530 +              mdidx(mddev),
25531 +              mddev->chunk_size >> 9,
25532 +              (mddev->chunk_size>>1)-1);
25533 +       blk_queue_max_sectors(mddev->queue, mddev->chunk_size >> 9);
25534 +       blk_queue_segment_boundary(mddev->queue, (mddev->chunk_size>>1) - 1);
25535 +
25536         conf = kmalloc(sizeof (raid0_conf_t), GFP_KERNEL);
25537         if (!conf)
25538                 goto out;
25539 diff -Nru a/drivers/md/raid5.c b/drivers/md/raid5.c
25540 --- a/drivers/md/raid5.c        Sun Aug 10 16:01:44 2003
25541 +++ b/drivers/md/raid5.c        Sat Aug 23 15:07:16 2003
25542 @@ -1326,7 +1326,7 @@
25543                         (unsigned long long)new_sector, 
25544                         (unsigned long long)logical_sector);
25545  
25546 -               sh = get_active_stripe(conf, new_sector, pd_idx, 0/*(bi->bi_rw&RWA_MASK)*/);
25547 +               sh = get_active_stripe(conf, new_sector, pd_idx, (bi->bi_rw&RWA_MASK));
25548                 if (sh) {
25549  
25550                         add_stripe_bio(sh, bi, dd_idx, (bi->bi_rw&RW_MASK));
25551 @@ -1334,7 +1334,12 @@
25552                         raid5_plug_device(conf);
25553                         handle_stripe(sh);
25554                         release_stripe(sh);
25555 +               } else {
25556 +                       /* cannot get stripe for read-ahead, just give-up */
25557 +                       clear_bit(BIO_UPTODATE, &bi->bi_flags);
25558 +                       break;
25559                 }
25560 +                       
25561         }
25562         spin_lock_irq(&conf->device_lock);
25563         if (--bi->bi_phys_segments == 0) {
25564 diff -Nru a/drivers/md/xor.c b/drivers/md/xor.c
25565 --- a/drivers/md/xor.c  Wed Jul 24 08:36:02 2002
25566 +++ b/drivers/md/xor.c  Sat Aug 23 15:07:12 2003
25567 @@ -134,7 +134,10 @@
25568         return 0;
25569  }
25570  
25571 +static __exit void xor_exit(void) { }
25572 +
25573  EXPORT_SYMBOL(xor_block);
25574  MODULE_LICENSE("GPL");
25575  
25576  module_init(calibrate_xor_block);
25577 +module_exit(xor_exit);
25578 diff -Nru a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
25579 --- a/drivers/media/common/saa7146_fops.c       Mon Jul  7 04:28:54 2003
25580 +++ b/drivers/media/common/saa7146_fops.c       Tue Aug 26 09:25:41 2003
25581 @@ -157,7 +157,7 @@
25582  
25583  static int fops_open(struct inode *inode, struct file *file)
25584  {
25585 -       unsigned int minor = minor(inode->i_rdev);
25586 +       unsigned int minor = iminor(inode);
25587         struct saa7146_dev *h = NULL, *dev = NULL;
25588         struct list_head *list;
25589         struct saa7146_fh *fh = NULL;
25590 diff -Nru a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
25591 --- a/drivers/media/common/saa7146_video.c      Thu Jul 31 16:47:19 2003
25592 +++ b/drivers/media/common/saa7146_video.c      Sun Aug 31 16:14:08 2003
25593 @@ -359,41 +359,41 @@
25594  
25595  static struct v4l2_queryctrl controls[] = {
25596         {
25597 -               id:            V4L2_CID_BRIGHTNESS,
25598 -               name:          "Brightness",
25599 -               minimum:       0,
25600 -               maximum:       255,
25601 -               step:          1,
25602 -               default_value: 128,
25603 -               type:          V4L2_CTRL_TYPE_INTEGER,
25604 +               .id            = V4L2_CID_BRIGHTNESS,
25605 +               .name          = "Brightness",
25606 +               .minimum       = 0,
25607 +               .maximum       = 255,
25608 +               .step          = 1,
25609 +               .default_value = 128,
25610 +               .type          = V4L2_CTRL_TYPE_INTEGER,
25611         },{
25612 -               id:            V4L2_CID_CONTRAST,
25613 -               name:          "Contrast",
25614 -               minimum:       0,
25615 -               maximum:       127,
25616 -               step:          1,
25617 -               default_value: 64,
25618 -               type:          V4L2_CTRL_TYPE_INTEGER,
25619 +               .id            = V4L2_CID_CONTRAST,
25620 +               .name          = "Contrast",
25621 +               .minimum       = 0,
25622 +               .maximum       = 127,
25623 +               .step          = 1,
25624 +               .default_value = 64,
25625 +               .type          = V4L2_CTRL_TYPE_INTEGER,
25626         },{
25627 -               id:            V4L2_CID_SATURATION,
25628 -               name:          "Saturation",
25629 -               minimum:       0,
25630 -               maximum:       127,
25631 -               step:          1,
25632 -               default_value: 64,
25633 -               type:          V4L2_CTRL_TYPE_INTEGER,
25634 +               .id            = V4L2_CID_SATURATION,
25635 +               .name          = "Saturation",
25636 +               .minimum       = 0,
25637 +               .maximum       = 127,
25638 +               .step          = 1,
25639 +               .default_value = 64,
25640 +               .type          = V4L2_CTRL_TYPE_INTEGER,
25641         },{
25642 -               id:            V4L2_CID_VFLIP,
25643 -               name:          "Vertical flip",
25644 -               minimum:       0,
25645 -               maximum:       1,
25646 -               type:          V4L2_CTRL_TYPE_BOOLEAN,
25647 +               .id            = V4L2_CID_VFLIP,
25648 +               .name          = "Vertical flip",
25649 +               .minimum       = 0,
25650 +               .maximum       = 1,
25651 +               .type          = V4L2_CTRL_TYPE_BOOLEAN,
25652         },{
25653 -               id:            V4L2_CID_HFLIP,
25654 -               name:          "Horizontal flip",
25655 -               minimum:       0,
25656 -               maximum:       1,
25657 -               type:          V4L2_CTRL_TYPE_BOOLEAN,
25658 +               .id            = V4L2_CID_HFLIP,
25659 +               .name          = "Horizontal flip",
25660 +               .minimum       = 0,
25661 +               .maximum       = 1,
25662 +               .type          = V4L2_CTRL_TYPE_BOOLEAN,
25663         },
25664  };
25665  static int NUM_CONTROLS = sizeof(controls)/sizeof(struct v4l2_queryctrl);
25666 diff -Nru a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
25667 --- a/drivers/media/dvb/dvb-core/dvbdev.c       Tue Aug 12 13:25:49 2003
25668 +++ b/drivers/media/dvb/dvb-core/dvbdev.c       Tue Aug 26 09:25:41 2003
25669 @@ -73,7 +73,7 @@
25670  {
25671         struct dvb_device *dvbdev;
25672         
25673 -       dvbdev = dvbdev_find_device (minor(inode->i_rdev));
25674 +       dvbdev = dvbdev_find_device (iminor(inode));
25675  
25676         if (dvbdev && dvbdev->fops) {
25677                 int err = 0;
25678 diff -Nru a/drivers/media/dvb/frontends/grundig_29504-401.c b/drivers/media/dvb/frontends/grundig_29504-401.c
25679 --- a/drivers/media/dvb/frontends/grundig_29504-401.c   Wed Jun 18 05:03:14 2003
25680 +++ b/drivers/media/dvb/frontends/grundig_29504-401.c   Sun Aug 31 16:14:08 2003
25681 @@ -37,15 +37,15 @@
25682  
25683  
25684  struct dvb_frontend_info grundig_29504_401_info = {
25685 -       name: "Grundig 29504-401",
25686 -       type: FE_OFDM,
25687 -/*     frequency_min: ???,*/
25688 -/*     frequency_max: ???,*/
25689 -       frequency_stepsize: 166666,
25690 -/*      frequency_tolerance: ???,*/
25691 -/*      symbol_rate_tolerance: ???,*/
25692 -       notifier_delay: 0,
25693 -       caps: FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 
25694 +       .name = "Grundig 29504-401",
25695 +       .type = FE_OFDM,
25696 +/*     .frequency_min = ???,*/
25697 +/*     .frequency_max = ???,*/
25698 +       .frequency_stepsize = 166666,
25699 +/*      .frequency_tolerance = ???,*/
25700 +/*      .symbol_rate_tolerance = ???,*/
25701 +       .notifier_delay = 0,
25702 +       .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
25703               FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
25704               FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
25705               FE_CAN_MUTE_TS /*| FE_CAN_CLEAN_SETUP*/
25706 diff -Nru a/drivers/media/dvb/frontends/ves1820.c b/drivers/media/dvb/frontends/ves1820.c
25707 --- a/drivers/media/dvb/frontends/ves1820.c     Thu Jun 19 23:48:36 2003
25708 +++ b/drivers/media/dvb/frontends/ves1820.c     Sun Aug 31 16:14:08 2003
25709 @@ -81,9 +81,9 @@
25710         .symbol_rate_min = (XIN/2)/64,     /* SACLK/64 == (XIN/2)/64 */
25711         .symbol_rate_max = (XIN/2)/4,      /* SACLK/4 */
25712  #if 0
25713 -       frequency_tolerance: ???,
25714 -       symbol_rate_tolerance: ???,  /* ppm */  /* == 8% (spec p. 5) */
25715 -       notifier_delay: ?,
25716 +       .frequency_tolerance = ???,
25717 +       .symbol_rate_tolerance = ???,  /* ppm */  /* == 8% (spec p. 5) */
25718 +       .notifier_delay = ?,
25719  #endif
25720         .caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
25721                 FE_CAN_QAM_128 | FE_CAN_QAM_256 | 
25722 diff -Nru a/drivers/media/dvb/ttusb-dec/dec2000_frontend.c b/drivers/media/dvb/ttusb-dec/dec2000_frontend.c
25723 --- a/drivers/media/dvb/ttusb-dec/dec2000_frontend.c    Mon Jul 14 02:56:39 2003
25724 +++ b/drivers/media/dvb/ttusb-dec/dec2000_frontend.c    Sun Aug 31 16:14:08 2003
25725 @@ -30,12 +30,12 @@
25726  #define dprintk        if (debug) printk
25727  
25728  static struct dvb_frontend_info dec2000_frontend_info = {
25729 -       name:                   "TechnoTrend/Hauppauge DEC-2000-t Frontend",
25730 -       type:                   FE_OFDM,
25731 -       frequency_min:          51000000,
25732 -       frequency_max:          858000000,
25733 -       frequency_stepsize:     62500,
25734 -       caps:   FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
25735 +       .name                   = "TechnoTrend/Hauppauge DEC-2000-t Frontend",
25736 +       .type                   = FE_OFDM,
25737 +       .frequency_min          = 51000000,
25738 +       .frequency_max          = 858000000,
25739 +       .frequency_stepsize     = 62500,
25740 +       .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
25741                 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
25742                 FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
25743                 FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
25744 diff -Nru a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
25745 --- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c   Sat Aug  9 06:43:04 2003
25746 +++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c   Sun Aug 31 16:14:08 2003
25747 @@ -1003,10 +1003,10 @@
25748  };
25749  
25750  static struct usb_driver ttusb_dec_driver = {
25751 -      name:            DRIVER_NAME,
25752 -      probe:           ttusb_dec_probe,
25753 -      disconnect:      ttusb_dec_disconnect,
25754 -      id_table:                ttusb_dec_table,
25755 +      .name            = DRIVER_NAME,
25756 +      .probe           = ttusb_dec_probe,
25757 +      .disconnect      = ttusb_dec_disconnect,
25758 +      .id_table                = ttusb_dec_table,
25759  };
25760  
25761  static int __init ttusb_dec_init(void)
25762 diff -Nru a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
25763 --- a/drivers/media/video/adv7170.c     Wed Aug 20 15:29:21 2003
25764 +++ b/drivers/media/video/adv7170.c     Sun Aug 31 16:14:05 2003
25765 @@ -104,6 +104,7 @@
25766                u8                 value)
25767  {
25768         struct adv7170 *encoder = i2c_get_clientdata(client);
25769 +
25770         encoder->reg[reg] = value;
25771         return i2c_smbus_write_byte_data(client, reg, value);
25772  }
25773 @@ -130,6 +131,7 @@
25774                 struct adv7170 *encoder = i2c_get_clientdata(client);
25775                 struct i2c_msg msg;
25776                 u8 block_data[32];
25777 +
25778                 msg.addr = client->addr;
25779                 msg.flags = client->flags;
25780                 while (len >= 2) {
25781 @@ -143,16 +145,16 @@
25782                                 data += 2;
25783                         } while (len >= 2 && data[0] == reg &&
25784                                  msg.len < 32);
25785 -                       if ((ret =
25786 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
25787 +                       if ((ret = i2c_transfer(client->adapter,
25788 +                                               &msg, 1)) < 0)
25789                                 break;
25790                 }
25791         } else {
25792                 /* do some slow I2C emulation kind of thing */
25793                 while (len >= 2) {
25794                         reg = *data++;
25795 -                       if ((ret =
25796 -                            adv7170_write(client, reg, *data++)) < 0)
25797 +                       if ((ret = adv7170_write(client, reg,
25798 +                                                *data++)) < 0)
25799                                 break;
25800                         len -= 2;
25801                 }
25802 @@ -442,6 +444,7 @@
25803                 dname = adv7171_name;
25804         } else {
25805                 /* We should never get here!!! */
25806 +               kfree(client);
25807                 return 0;
25808         }
25809         snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
25810 @@ -449,6 +452,7 @@
25811  
25812         encoder = kmalloc(sizeof(struct adv7170), GFP_KERNEL);
25813         if (encoder == NULL) {
25814 +               kfree(client);
25815                 return -ENOMEM;
25816         }
25817         memset(encoder, 0, sizeof(struct adv7170));
25818 diff -Nru a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
25819 --- a/drivers/media/video/adv7175.c     Wed Aug 20 15:29:21 2003
25820 +++ b/drivers/media/video/adv7175.c     Sun Aug 31 16:14:05 2003
25821 @@ -100,6 +100,7 @@
25822                u8                 value)
25823  {
25824         struct adv7175 *encoder = i2c_get_clientdata(client);
25825 +
25826         encoder->reg[reg] = value;
25827         return i2c_smbus_write_byte_data(client, reg, value);
25828  }
25829 @@ -126,6 +127,7 @@
25830                 struct adv7175 *encoder = i2c_get_clientdata(client);
25831                 struct i2c_msg msg;
25832                 u8 block_data[32];
25833 +
25834                 msg.addr = client->addr;
25835                 msg.flags = client->flags;
25836                 while (len >= 2) {
25837 @@ -139,16 +141,16 @@
25838                                 data += 2;
25839                         } while (len >= 2 && data[0] == reg &&
25840                                  msg.len < 32);
25841 -                       if ((ret =
25842 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
25843 +                       if ((ret = i2c_transfer(client->adapter,
25844 +                                               &msg, 1)) < 0)
25845                                 break;
25846                 }
25847         } else {
25848                 /* do some slow I2C emulation kind of thing */
25849                 while (len >= 2) {
25850                         reg = *data++;
25851 -                       if ((ret =
25852 -                            adv7175_write(client, reg, *data++)) < 0)
25853 +                       if ((ret = adv7175_write(client, reg,
25854 +                                                *data++)) < 0)
25855                                 break;
25856                         len -= 2;
25857                 }
25858 @@ -163,6 +165,7 @@
25859  {
25860         struct adv7175 *encoder = i2c_get_clientdata(client);
25861         int i, j;
25862 +
25863         printk(KERN_INFO "%s: registry dump\n", I2C_NAME(client));
25864         for (i = 0; i < 182 / 8; i++) {
25865                 printk("%s: 0x%02x -", I2C_NAME(client), i * 8);
25866 @@ -463,6 +466,7 @@
25867                 dname = adv7176_name;
25868         } else {
25869                 /* We should never get here!!! */
25870 +               kfree(client);
25871                 return 0;
25872         }
25873         snprintf(I2C_NAME(client), sizeof(I2C_NAME(client)) - 1,
25874 @@ -470,6 +474,7 @@
25875  
25876         encoder = kmalloc(sizeof(struct adv7175), GFP_KERNEL);
25877         if (encoder == NULL) {
25878 +               kfree(client);
25879                 return -ENOMEM;
25880         }
25881         memset(encoder, 0, sizeof(struct adv7175));
25882 diff -Nru a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
25883 --- a/drivers/media/video/bt819.c       Wed Aug 20 15:29:21 2003
25884 +++ b/drivers/media/video/bt819.c       Sun Aug 31 16:14:05 2003
25885 @@ -113,6 +113,7 @@
25886              u8                 value)
25887  {
25888         struct bt819 *decoder = i2c_get_clientdata(client);
25889 +
25890         decoder->reg[reg] = value;
25891         return i2c_smbus_write_byte_data(client, reg, value);
25892  }
25893 @@ -124,6 +125,7 @@
25894               u8                 value)
25895  {
25896         struct bt819 *decoder = i2c_get_clientdata(client);
25897 +
25898         return bt819_write(client, reg,
25899                            (decoder->
25900                             reg[reg] & ~(1 << bit)) |
25901 @@ -145,6 +147,7 @@
25902                 struct bt819 *decoder = i2c_get_clientdata(client);
25903                 struct i2c_msg msg;
25904                 u8 block_data[32];
25905 +
25906                 msg.addr = client->addr;
25907                 msg.flags = client->flags;
25908                 while (len >= 2) {
25909 @@ -158,8 +161,8 @@
25910                                 data += 2;
25911                         } while (len >= 2 && data[0] == reg &&
25912                                  msg.len < 32);
25913 -                       if ((ret =
25914 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
25915 +                       if ((ret = i2c_transfer(client->adapter,
25916 +                                               &msg, 1)) < 0)
25917                                 break;
25918                 }
25919         } else {
25920 diff -Nru a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
25921 --- a/drivers/media/video/bt856.c       Wed Aug 20 15:29:21 2003
25922 +++ b/drivers/media/video/bt856.c       Sun Aug 31 16:14:05 2003
25923 @@ -98,6 +98,7 @@
25924              u8                 value)
25925  {
25926         struct bt856 *encoder = i2c_get_clientdata(client);
25927 +
25928         encoder->reg[reg - REG_OFFSET] = value;
25929         return i2c_smbus_write_byte_data(client, reg, value);
25930  }
25931 @@ -109,6 +110,7 @@
25932               u8                 value)
25933  {
25934         struct bt856 *encoder = i2c_get_clientdata(client);
25935 +
25936         return bt856_write(client, reg,
25937                            (encoder->
25938                             reg[reg - REG_OFFSET] & ~(1 << bit)) |
25939 @@ -120,6 +122,7 @@
25940  {
25941         int i;
25942         struct bt856 *encoder = i2c_get_clientdata(client);
25943 +
25944         printk(KERN_INFO "%s: register dump:", I2C_NAME(client));
25945         for (i = 0xd6; i <= 0xde; i += 2)
25946                 printk(" %02x", encoder->reg[i - REG_OFFSET]);
25947 @@ -341,6 +344,7 @@
25948  
25949         encoder = kmalloc(sizeof(struct bt856), GFP_KERNEL);
25950         if (encoder == NULL) {
25951 +               kfree(client);
25952                 return -ENOMEM;
25953         }
25954         memset(encoder, 0, sizeof(struct bt856));
25955 diff -Nru a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
25956 --- a/drivers/media/video/bttv-driver.c Thu Aug  7 14:20:17 2003
25957 +++ b/drivers/media/video/bttv-driver.c Tue Aug 26 09:25:41 2003
25958 @@ -2758,7 +2758,7 @@
25959  
25960  static int bttv_open(struct inode *inode, struct file *file)
25961  {
25962 -       int minor = minor(inode->i_rdev);
25963 +       int minor = iminor(inode);
25964         struct bttv *btv = NULL;
25965         struct bttv_fh *fh;
25966         enum v4l2_buf_type type = 0;
25967 @@ -2894,7 +2894,7 @@
25968  
25969  static int radio_open(struct inode *inode, struct file *file)
25970  {
25971 -       int minor = minor(inode->i_rdev);
25972 +       int minor = iminor(inode);
25973         struct bttv *btv = NULL;
25974         u32 v = 400*16;
25975         unsigned int i;
25976 diff -Nru a/drivers/media/video/meye.c b/drivers/media/video/meye.c
25977 --- a/drivers/media/video/meye.c        Thu Jul 31 08:59:04 2003
25978 +++ b/drivers/media/video/meye.c        Wed Aug 27 04:24:51 2003
25979 @@ -920,7 +920,7 @@
25980  
25981         case VIDIOCGCAP: {
25982                 struct video_capability *b = arg;
25983 -               strcpy(b->name,meye.video_dev.name);
25984 +               strcpy(b->name,meye.video_dev->name);
25985                 b->type = VID_TYPE_CAPTURE;
25986                 b->channels = 1;
25987                 b->audios = 0;
25988 @@ -1225,6 +1225,8 @@
25989         .type           = VID_TYPE_CAPTURE,
25990         .hardware       = VID_HARDWARE_MEYE,
25991         .fops           = &meye_fops,
25992 +       .release        = video_device_release,
25993 +       .minor          = -1,
25994  };
25995  
25996  #ifdef CONFIG_PM
25997 @@ -1275,10 +1277,17 @@
25998                 goto out1;
25999         }
26000  
26001 -       sonypi_camera_command(SONYPI_COMMAND_SETCAMERA, 1);
26002 -
26003         meye.mchip_dev = pcidev;
26004 -       memcpy(&meye.video_dev, &meye_template, sizeof(meye_template));
26005 +       meye.video_dev = video_device_alloc();
26006 +       if (!meye.video_dev) {
26007 +               printk(KERN_ERR "meye: video_device_alloc() failed!\n");
26008 +               ret = -EBUSY;
26009 +               goto out1;
26010 +       }
26011 +       memcpy(meye.video_dev, &meye_template, sizeof(meye_template));
26012 +       meye.video_dev->dev = &meye.mchip_dev->dev;
26013 +
26014 +       sonypi_camera_command(SONYPI_COMMAND_SETCAMERA, 1);
26015  
26016         if ((ret = pci_enable_device(meye.mchip_dev))) {
26017                 printk(KERN_ERR "meye: pci_enable_device failed\n");
26018 @@ -1335,7 +1344,7 @@
26019         wait_ms(1);
26020         mchip_set(MCHIP_MM_INTA, MCHIP_MM_INTA_HIC_1_MASK);
26021  
26022 -       if (video_register_device(&meye.video_dev, VFL_TYPE_GRABBER, video_nr) < 0) {
26023 +       if (video_register_device(meye.video_dev, VFL_TYPE_GRABBER, video_nr) < 0) {
26024  
26025                 printk(KERN_ERR "meye: video_register_device failed\n");
26026                 ret = -EIO;
26027 @@ -1383,6 +1392,9 @@
26028  out3:
26029         pci_disable_device(meye.mchip_dev);
26030  out2:
26031 +       video_device_release(meye.video_dev);
26032 +       meye.video_dev = NULL;
26033 +
26034         sonypi_camera_command(SONYPI_COMMAND_SETCAMERA, 0);
26035  out1:
26036         return ret;
26037 @@ -1390,7 +1402,7 @@
26038  
26039  static void __devexit meye_remove(struct pci_dev *pcidev) {
26040  
26041 -       video_unregister_device(&meye.video_dev);
26042 +       video_unregister_device(meye.video_dev);
26043  
26044         mchip_hic_stop();
26045  
26046 diff -Nru a/drivers/media/video/meye.h b/drivers/media/video/meye.h
26047 --- a/drivers/media/video/meye.h        Wed Apr 16 03:01:38 2003
26048 +++ b/drivers/media/video/meye.h        Tue Aug 26 09:48:06 2003
26049 @@ -312,7 +312,7 @@
26050  
26051         struct meye_queue grabq;        /* queue for buffers to be grabbed */
26052  
26053 -       struct video_device video_dev;  /* video device parameters */
26054 +       struct video_device *video_dev; /* video device parameters */
26055         struct video_picture picture;   /* video picture parameters */
26056         struct meye_params params;      /* additional parameters */
26057  #ifdef CONFIG_PM
26058 diff -Nru a/drivers/media/video/planb.c b/drivers/media/video/planb.c
26059 --- a/drivers/media/video/planb.c       Tue Aug 12 13:24:31 2003
26060 +++ b/drivers/media/video/planb.c       Mon Sep  1 08:41:30 2003
26061 @@ -2158,6 +2158,7 @@
26062         unsigned int            old_base, new_base;
26063         unsigned int            irq;
26064         struct pci_dev          *pdev;
26065 +       int rc;
26066  
26067         if (_machine != _MACH_Pmac)
26068                 return 0;
26069 @@ -2211,18 +2212,25 @@
26070  
26071         pdev = pci_find_slot (bus, dev_fn);
26072         if (!pdev) {
26073 -               printk(KERN_ERR "cannot find slot\n");
26074 -               /* XXX handle error */
26075 +               printk(KERN_ERR "planb: cannot find slot\n");
26076 +               goto err_out;
26077         }
26078  
26079         /* Enable response in memory space, bus mastering,
26080            use memory write and invalidate */
26081 -       pci_write_config_word (pdev, PCI_COMMAND,
26082 -               PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
26083 -               PCI_COMMAND_INVALIDATE);
26084 -       /* Set PCI Cache line size & latency timer */
26085 -       pci_write_config_byte (pdev, PCI_CACHE_LINE_SIZE, 0x8);
26086 -       pci_write_config_byte (pdev, PCI_LATENCY_TIMER, 0x40);
26087 +       rc = pci_enable_device(pdev);
26088 +       if (rc) {
26089 +               printk(KERN_ERR "planb: cannot enable PCI device %s\n",
26090 +                      pci_name(pdev));
26091 +               goto err_out;
26092 +       }
26093 +       rc = pci_set_mwi(pdev);
26094 +       if (rc) {
26095 +               printk(KERN_ERR "planb: cannot enable MWI on PCI device %s\n",
26096 +                      pci_name(pdev));
26097 +               goto err_out_disable;
26098 +       }
26099 +       pci_set_master(pdev);
26100  
26101         /* Set the new base address */
26102         pci_write_config_dword (pdev, confreg, new_base);
26103 @@ -2234,6 +2242,12 @@
26104         pb->irq = irq;
26105         
26106         return planb_num;
26107 +
26108 +err_out_disable:
26109 +       pci_disable_device(pdev);
26110 +err_out:
26111 +       /* FIXME handle error */   /* comment moved from pci_find_slot, above */
26112 +       return 0;
26113  }
26114  
26115  static void release_planb(void)
26116 diff -Nru a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c
26117 --- a/drivers/media/video/saa7110.c     Wed Aug 20 15:29:21 2003
26118 +++ b/drivers/media/video/saa7110.c     Sun Aug 31 16:14:05 2003
26119 @@ -86,6 +86,7 @@
26120                u8                 value)
26121  {
26122         struct saa7110 *decoder = i2c_get_clientdata(client);
26123 +
26124         decoder->reg[reg] = value;
26125         return i2c_smbus_write_byte_data(client, reg, value);
26126  }
26127 @@ -97,6 +98,7 @@
26128  {
26129         int ret = -1;
26130         u8 reg = *data++;
26131 +
26132         len--;
26133  
26134         /* the saa7110 has an autoincrement function, use it if
26135 @@ -105,6 +107,7 @@
26136                 struct saa7110 *decoder = i2c_get_clientdata(client);
26137                 struct i2c_msg msg;
26138                 u8 block_data[54];
26139 +
26140                 msg.len = 0;
26141                 msg.buf = (char *) block_data;
26142                 msg.addr = client->addr;
26143 @@ -119,8 +122,8 @@
26144                 }
26145         } else {
26146                 while (len-- >= 1) {
26147 -                       if ((ret =
26148 -                            saa7110_write(client, reg++, *data++)) < 0)
26149 +                       if ((ret = saa7110_write(client, reg++,
26150 +                                                *data++)) < 0)
26151                                 break;
26152                 }
26153         }
26154 @@ -279,6 +282,7 @@
26155         case DECODER_GET_CAPABILITIES:
26156         {
26157                 struct video_decoder_capability *dc = arg;
26158 +
26159                 dc->flags =
26160                     VIDEO_DECODER_PAL | VIDEO_DECODER_NTSC |
26161                     VIDEO_DECODER_SECAM | VIDEO_DECODER_AUTO;
26162 diff -Nru a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
26163 --- a/drivers/media/video/saa7111.c     Thu Aug 21 10:13:46 2003
26164 +++ b/drivers/media/video/saa7111.c     Sun Aug 31 16:14:05 2003
26165 @@ -93,6 +93,7 @@
26166                u8                 value)
26167  {
26168         struct saa7111 *decoder = i2c_get_clientdata(client);
26169 +
26170         decoder->reg[reg] = value;
26171         return i2c_smbus_write_byte_data(client, reg, value);
26172  }
26173 @@ -112,6 +113,7 @@
26174                 struct saa7111 *decoder = i2c_get_clientdata(client);
26175                 struct i2c_msg msg;
26176                 u8 block_data[32];
26177 +
26178                 msg.addr = client->addr;
26179                 msg.flags = client->flags;
26180                 while (len >= 2) {
26181 @@ -125,16 +127,16 @@
26182                                 data += 2;
26183                         } while (len >= 2 && data[0] == reg &&
26184                                  msg.len < 32);
26185 -                       if ((ret =
26186 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
26187 +                       if ((ret = i2c_transfer(client->adapter,
26188 +                                               &msg, 1)) < 0)
26189                                 break;
26190                 }
26191         } else {
26192                 /* do some slow I2C emulation kind of thing */
26193                 while (len >= 2) {
26194                         reg = *data++;
26195 -                       if ((ret =
26196 -                            saa7111_write(client, reg, *data++)) < 0)
26197 +                       if ((ret = saa7111_write(client, reg,
26198 +                                                *data++)) < 0)
26199                                 break;
26200                         len -= 2;
26201                 }
26202 diff -Nru a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c
26203 --- a/drivers/media/video/saa7114.c     Wed Aug 20 15:29:21 2003
26204 +++ b/drivers/media/video/saa7114.c     Sun Aug 31 16:14:05 2003
26205 @@ -144,6 +144,7 @@
26206                u8                 value)
26207  {
26208         /*struct saa7114 *decoder = i2c_get_clientdata(client);*/
26209 +
26210         /*decoder->reg[reg] = value;*/
26211         return i2c_smbus_write_byte_data(client, reg, value);
26212  }
26213 @@ -163,6 +164,7 @@
26214                 /*struct saa7114 *decoder = i2c_get_clientdata(client);*/
26215                 struct i2c_msg msg;
26216                 u8 block_data[32];
26217 +
26218                 msg.addr = client->addr;
26219                 msg.flags = client->flags;
26220                 while (len >= 2) {
26221 @@ -176,16 +178,16 @@
26222                                 data += 2;
26223                         } while (len >= 2 && data[0] == reg &&
26224                                  msg.len < 32);
26225 -                       if ((ret =
26226 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
26227 +                       if ((ret = i2c_transfer(client->adapter,
26228 +                                               &msg, 1)) < 0)
26229                                 break;
26230                 }
26231         } else {
26232                 /* do some slow I2C emulation kind of thing */
26233                 while (len >= 2) {
26234                         reg = *data++;
26235 -                       if ((ret =
26236 -                            saa7114_write(client, reg, *data++)) < 0)
26237 +                       if ((ret = saa7114_write(client, reg,
26238 +                                                *data++)) < 0)
26239                                 break;
26240                         len -= 2;
26241                 }
26242 @@ -995,6 +997,8 @@
26243                                 KERN_ERR
26244                                 "%s_attach: init error %d at stage %d, leaving attach.\n",
26245                                 I2C_NAME(client), i, err[i]);
26246 +                       kfree(decoder);
26247 +                       kfree(client);
26248                         return 0;
26249                 }
26250         }
26251 @@ -1022,6 +1026,8 @@
26252                                 KERN_ERR
26253                                 "%s_attach: init error %d at stage %d, leaving attach.\n",
26254                                 I2C_NAME(client), i, err[i]);
26255 +                       kfree(decoder);
26256 +                       kfree(client);
26257                         return 0;
26258                 }
26259         }
26260 @@ -1068,6 +1074,8 @@
26261                                 KERN_ERR
26262                                 "%s_attach: init error %d at stage %d, leaving attach.\n",
26263                                 I2C_NAME(client), i, err[i]);
26264 +                       kfree(decoder);
26265 +                       kfree(client);
26266                         return 0;
26267                 }
26268         }
26269 @@ -1107,6 +1115,8 @@
26270                                 KERN_ERR
26271                                 "%s_attach: init error %d at stage %d, leaving attach.\n",
26272                                 I2C_NAME(client), i, err[i]);
26273 +                       kfree(decoder);
26274 +                       kfree(client);
26275                         return 0;
26276                 }
26277         }
26278 @@ -1127,6 +1137,8 @@
26279                                 KERN_ERR
26280                                 "%s_attach: init error %d at stage %d, leaving attach.\n",
26281                                 I2C_NAME(client), i, err[i]);
26282 +                       kfree(decoder);
26283 +                       kfree(client);
26284                         return 0;
26285                 }
26286         }
26287 diff -Nru a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c
26288 --- a/drivers/media/video/saa7134/saa7134-oss.c Sun May 25 17:00:00 2003
26289 +++ b/drivers/media/video/saa7134/saa7134-oss.c Tue Aug 26 09:25:41 2003
26290 @@ -215,7 +215,7 @@
26291  
26292  static int dsp_open(struct inode *inode, struct file *file)
26293  {
26294 -       int minor = minor(inode->i_rdev);
26295 +       int minor = iminor(inode);
26296         struct saa7134_dev *h,*dev = NULL;
26297         struct list_head *list;
26298         int err;
26299 @@ -598,7 +598,7 @@
26300  
26301  static int mixer_open(struct inode *inode, struct file *file)
26302  {
26303 -       int minor = minor(inode->i_rdev);
26304 +       int minor = iminor(inode);
26305         struct saa7134_dev *h,*dev = NULL;
26306         struct list_head *list;
26307  
26308 diff -Nru a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c
26309 --- a/drivers/media/video/saa7134/saa7134-ts.c  Thu Jul 31 16:47:19 2003
26310 +++ b/drivers/media/video/saa7134/saa7134-ts.c  Tue Aug 26 09:25:41 2003
26311 @@ -166,7 +166,7 @@
26312  
26313  static int ts_open(struct inode *inode, struct file *file)
26314  {
26315 -       int minor = minor(inode->i_rdev);
26316 +       int minor = iminor(inode);
26317         struct saa7134_dev *h,*dev = NULL;
26318         struct list_head *list;
26319         int err;
26320 diff -Nru a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
26321 --- a/drivers/media/video/saa7134/saa7134-video.c       Thu Jul 31 16:47:19 2003
26322 +++ b/drivers/media/video/saa7134/saa7134-video.c       Tue Aug 26 09:25:41 2003
26323 @@ -1131,7 +1131,7 @@
26324  
26325  static int video_open(struct inode *inode, struct file *file)
26326  {
26327 -       int minor = minor(inode->i_rdev);
26328 +       int minor = iminor(inode);
26329         struct saa7134_dev *h,*dev = NULL;
26330         struct saa7134_fh *fh;
26331         struct list_head *list;
26332 diff -Nru a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
26333 --- a/drivers/media/video/saa7185.c     Wed Aug 20 15:29:21 2003
26334 +++ b/drivers/media/video/saa7185.c     Sun Aug 31 16:14:05 2003
26335 @@ -98,6 +98,7 @@
26336                u8                 value)
26337  {
26338         struct saa7185 *encoder = i2c_get_clientdata(client);
26339 +
26340         dprintk(1, KERN_DEBUG "SAA7185: %02x set to %02x\n", reg, value);
26341         encoder->reg[reg] = value;
26342         return i2c_smbus_write_byte_data(client, reg, value);
26343 @@ -118,6 +119,7 @@
26344                 struct saa7185 *encoder = i2c_get_clientdata(client);
26345                 struct i2c_msg msg;
26346                 u8 block_data[32];
26347 +
26348                 msg.addr = client->addr;
26349                 msg.flags = client->flags;
26350                 while (len >= 2) {
26351 @@ -131,16 +133,16 @@
26352                                 data += 2;
26353                         } while (len >= 2 && data[0] == reg &&
26354                                  msg.len < 32);
26355 -                       if ((ret =
26356 -                            i2c_transfer(client->adapter, &msg, 1)) < 0)
26357 +                       if ((ret = i2c_transfer(client->adapter,
26358 +                                               &msg, 1)) < 0)
26359                                 break;
26360                 }
26361         } else {
26362                 /* do some slow I2C emulation kind of thing */
26363                 while (len >= 2) {
26364                         reg = *data++;
26365 -                       if ((ret =
26366 -                            saa7185_write(client, reg, *data++)) < 0)
26367 +                       if ((ret = saa7185_write(client, reg,
26368 +                                                *data++)) < 0)
26369                                 break;
26370                         len -= 2;
26371                 }
26372 @@ -434,6 +436,7 @@
26373  
26374         encoder = kmalloc(sizeof(struct saa7185), GFP_KERNEL);
26375         if (encoder == NULL) {
26376 +               kfree(client);
26377                 return -ENOMEM;
26378         }
26379         memset(encoder, 0, sizeof(struct saa7185));
26380 diff -Nru a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
26381 --- a/drivers/media/video/stradis.c     Thu Apr 24 03:35:23 2003
26382 +++ b/drivers/media/video/stradis.c     Tue Aug 26 09:25:41 2003
26383 @@ -1946,7 +1946,7 @@
26384  static int saa_open(struct inode *inode, struct file *file)
26385  {
26386         struct saa7146 *saa = NULL;
26387 -       unsigned int minor = minor(inode->i_rdev);
26388 +       unsigned int minor = iminor(inode);
26389         int i;
26390  
26391         for (i = 0; i < SAA7146_MAX; i++) {
26392 diff -Nru a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c
26393 --- a/drivers/media/video/tvmixer.c     Wed Aug 20 15:29:21 2003
26394 +++ b/drivers/media/video/tvmixer.c     Tue Aug 26 09:25:41 2003
26395 @@ -173,7 +173,7 @@
26396  
26397  static int tvmixer_open(struct inode *inode, struct file *file)
26398  {
26399 -        int i, minor = minor(inode->i_rdev);
26400 +        int i, minor = iminor(inode);
26401          struct TVMIXER *mix = NULL;
26402         struct i2c_client *client = NULL;
26403  
26404 diff -Nru a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
26405 --- a/drivers/media/video/videodev.c    Wed Aug  6 02:51:26 2003
26406 +++ b/drivers/media/video/videodev.c    Sun Aug 31 16:13:58 2003
26407 @@ -99,7 +99,7 @@
26408  
26409  struct video_device* video_devdata(struct file *file)
26410  {
26411 -       return video_device[minor(file->f_dentry->d_inode->i_rdev)];
26412 +       return video_device[iminor(file->f_dentry->d_inode)];
26413  }
26414  
26415  /*
26416 @@ -107,7 +107,7 @@
26417   */
26418  static int video_open(struct inode *inode, struct file *file)
26419  {
26420 -       unsigned int minor = minor(inode->i_rdev);
26421 +       unsigned int minor = iminor(inode);
26422         int err = 0;
26423         struct video_device *vfl;
26424         struct file_operations *old_fops;
26425 @@ -349,9 +349,9 @@
26426         if(video_device[vfd->minor]!=vfd)
26427                 panic("videodev: bad unregister");
26428  
26429 -       class_device_unregister(&vfd->class_dev);
26430         devfs_remove(vfd->devfs_name);
26431         video_device[vfd->minor]=NULL;
26432 +       class_device_unregister(&vfd->class_dev);
26433         up(&videodev_lock);
26434  }
26435  
26436 diff -Nru a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c
26437 --- a/drivers/media/video/vpx3220.c     Wed Aug 20 15:29:21 2003
26438 +++ b/drivers/media/video/vpx3220.c     Sun Aug 31 16:14:05 2003
26439 @@ -76,6 +76,7 @@
26440                u8                 value)
26441  {
26442         struct vpx3220 *decoder = i2c_get_clientdata(client);
26443 +
26444         decoder->reg[reg] = value;
26445         return i2c_smbus_write_byte_data(client, reg, value);
26446  }
26447 @@ -294,6 +295,7 @@
26448  {
26449         int len = sizeof(init_common);
26450         const unsigned char *data = init_common;
26451 +
26452         while (len > 1) {
26453                 dprintk(1,
26454                         KERN_DEBUG "vpx3216b i2c reg 0x%02x data 0x%02x\n",
26455 diff -Nru a/drivers/media/video/zoran.h b/drivers/media/video/zoran.h
26456 --- a/drivers/media/video/zoran.h       Wed Aug 20 15:29:21 2003
26457 +++ b/drivers/media/video/zoran.h       Sun Aug 31 16:14:06 2003
26458 @@ -146,7 +146,7 @@
26459  
26460  #define ZORAN_NAME    "ZORAN"  /* name of the device */
26461  
26462 -#define ZR_DEVNAME(zr) pci_name((zr)->pci_dev)
26463 +#define ZR_DEVNAME(zr) ((zr)->name)
26464  
26465  #define   BUZ_MAX_WIDTH   (zr->timing->Wa)
26466  #define   BUZ_MAX_HEIGHT  (zr->timing->Ha)
26467 @@ -383,7 +383,7 @@
26468  };
26469  
26470  struct zoran {
26471 -       struct video_device video_dev;
26472 +       struct video_device *video_dev;
26473  
26474         struct i2c_adapter i2c_adapter; /* */
26475         struct i2c_algo_bit_data i2c_algo;      /* */
26476 @@ -403,9 +403,7 @@
26477         struct tvnorm *timing;
26478  
26479         unsigned short id;      /* number of this device */
26480 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
26481         char name[32];          /* name of this device */
26482 -#endif
26483         struct pci_dev *pci_dev;        /* PCI device */
26484         unsigned char revision; /* revision of zr36057 */
26485         unsigned int zr36057_adr;       /* bus address of IO mem returned by PCI BIOS */
26486 diff -Nru a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
26487 --- a/drivers/media/video/zoran_card.c  Wed Aug 20 15:29:21 2003
26488 +++ b/drivers/media/video/zoran_card.c  Sun Aug 31 16:14:05 2003
26489 @@ -136,7 +136,8 @@
26490  MODULE_PARM_DESC(pass_through,
26491                  "Pass TV signal through to TV-out when idling");
26492  
26493 -int debug = 1;
26494 +static int debug = 1;
26495 +int *zr_debug = &debug;
26496  MODULE_PARM(debug, "i");
26497  MODULE_PARM_DESC(debug, "Debug level (0-4)");
26498  
26499 @@ -153,7 +154,7 @@
26500  
26501  #define dprintk(num, format, args...) \
26502         do { \
26503 -               if (debug >= num) \
26504 +               if (*zr_debug >= num) \
26505                         printk(format, ##args); \
26506         } while (0)
26507  
26508 @@ -623,6 +624,7 @@
26509  zoran_i2c_getsda (void *data)
26510  {
26511         struct zoran *zr = (struct zoran *) data;
26512 +
26513         return (btread(ZR36057_I2CBR) >> 1) & 1;
26514  }
26515  
26516 @@ -630,6 +632,7 @@
26517  zoran_i2c_getscl (void *data)
26518  {
26519         struct zoran *zr = (struct zoran *) data;
26520 +
26521         return btread(ZR36057_I2CBR) & 1;
26522  }
26523  
26524 @@ -638,6 +641,7 @@
26525                   int   state)
26526  {
26527         struct zoran *zr = (struct zoran *) data;
26528 +
26529         if (state)
26530                 zr->i2cbr |= 2;
26531         else
26532 @@ -650,6 +654,7 @@
26533                   int   state)
26534  {
26535         struct zoran *zr = (struct zoran *) data;
26536 +
26537         if (state)
26538                 zr->i2cbr |= 1;
26539         else
26540 @@ -766,6 +771,7 @@
26541                           struct zoran_jpg_settings *settings)
26542  {
26543         int err = 0, err0 = 0;
26544 +
26545         dprintk(4,
26546                 KERN_DEBUG
26547                 "%s: check_jpg_settings() - dec: %d, Hdcm: %d, Vdcm: %d, Tdcm: %d\n",
26548 @@ -977,7 +983,7 @@
26549         if (timeout) {
26550                 dprintk(1, ": time spent: %d\n", 1 * HZ - timeout);
26551         }
26552 -       if (debug > 1)
26553 +       if (*zr_debug > 1)
26554                 print_interrupts(zr);
26555         btwrite(icr, ZR36057_ICR);
26556  }
26557 @@ -986,6 +992,7 @@
26558  zr36057_init (struct zoran *zr)
26559  {
26560         unsigned long mem;
26561 +       void *vdev;
26562         unsigned mem_needed;
26563         int j;
26564         int two = 2;
26565 @@ -1040,11 +1047,16 @@
26566          * in case allocation fails */
26567         mem_needed = BUZ_NUM_STAT_COM * 4;
26568         mem = (unsigned long) kmalloc(mem_needed, GFP_KERNEL);
26569 -       if (!mem) {
26570 +       vdev = (void *) kmalloc(sizeof(struct video_device), GFP_KERNEL);
26571 +       if (!mem || !vdev) {
26572                 dprintk(1,
26573                         KERN_ERR
26574                         "%s: zr36057_init() - kmalloc (STAT_COM) failed\n",
26575                         ZR_DEVNAME(zr));
26576 +               if (vdev)
26577 +                       kfree(vdev);
26578 +               if (mem)
26579 +                       kfree((void *)mem);
26580                 return -ENOMEM;
26581         }
26582         memset((void *) mem, 0, mem_needed);
26583 @@ -1056,17 +1068,19 @@
26584         /*
26585          *   Now add the template and register the device unit.
26586          */
26587 -       memcpy(&zr->video_dev, &zoran_template, sizeof(zoran_template));
26588 -       strcpy(zr->video_dev.name, ZR_DEVNAME(zr));
26589 -       if (video_register_device
26590 -           (&zr->video_dev, VFL_TYPE_GRABBER, video_nr) < 0) {
26591 +       zr->video_dev = vdev;
26592 +       memcpy(zr->video_dev, &zoran_template, sizeof(zoran_template));
26593 +       strcpy(zr->video_dev->name, ZR_DEVNAME(zr));
26594 +       if (video_register_device(zr->video_dev, VFL_TYPE_GRABBER,
26595 +                                 video_nr) < 0) {
26596                 zoran_unregister_i2c(zr);
26597                 kfree((void *) zr->stat_com);
26598 +               kfree(vdev);
26599                 return -1;
26600         }
26601  
26602         zoran_init_hardware(zr);
26603 -       if (debug > 2)
26604 +       if (*zr_debug > 2)
26605                 detect_guest_activity(zr);
26606         test_interrupts(zr);
26607         if (!pass_through) {
26608 @@ -1109,7 +1123,14 @@
26609         kfree((void *) zr->stat_com);
26610         zoran_proc_cleanup(zr);
26611         iounmap(zr->zr36057_mem);
26612 -       video_unregister_device(&zr->video_dev);
26613 +       pci_disable_device(zr->pci_dev);
26614 +       video_unregister_device(zr->video_dev);
26615 +}
26616 +
26617 +void
26618 +zoran_vdev_release (struct video_device *vdev)
26619 +{
26620 +       kfree(vdev);
26621  }
26622  
26623  static struct videocodec_master * __devinit
26624 @@ -1207,6 +1228,7 @@
26625                 } else {
26626                         int i;
26627                         unsigned short ss_vendor, ss_device;
26628 +
26629                         ss_vendor = zr->pci_dev->subsystem_vendor;
26630                         ss_device = zr->pci_dev->subsystem_device;
26631                         dprintk(1,
26632 @@ -1467,6 +1489,7 @@
26633  init_dc10_cards (void)
26634  {
26635         int i;
26636 +
26637         memset(zoran, 0, sizeof(zoran));
26638         printk(KERN_INFO "Zoran MJPEG board driver version %d.%d.%d\n",
26639                MAJOR_VERSION, MINOR_VERSION, RELEASE_VERSION);
26640 @@ -1523,6 +1546,7 @@
26641         /* take care of Natoma chipset and a revision 1 zr36057 */
26642         for (i = 0; i < zoran_num; i++) {
26643                 struct zoran *zr = &zoran[i];
26644 +
26645                 if (pci_pci_problems & PCIPCI_NATOMA && zr->revision <= 1) {
26646                         zr->jpg_buffers.need_contiguous = 1;
26647                         dprintk(1,
26648 @@ -1546,6 +1570,7 @@
26649  unload_dc10_cards (void)
26650  {
26651         int i;
26652 +
26653         for (i = 0; i < zoran_num; i++)
26654                 zoran_release(&zoran[i]);
26655  }
26656 diff -Nru a/drivers/media/video/zoran_card.h b/drivers/media/video/zoran_card.h
26657 --- a/drivers/media/video/zoran_card.h  Wed Aug 20 14:29:31 2003
26658 +++ b/drivers/media/video/zoran_card.h  Sun Aug 31 16:14:03 2003
26659 @@ -40,5 +40,6 @@
26660  extern int zoran_check_jpg_settings(struct zoran *zr,
26661                                     struct zoran_jpg_settings *settings);
26662  extern void zoran_open_init_params(struct zoran *zr);
26663 +extern void zoran_vdev_release(struct video_device *vdev);
26664  
26665  #endif                         /* __ZORAN_CARD_H__ */
26666 diff -Nru a/drivers/media/video/zoran_device.c b/drivers/media/video/zoran_device.c
26667 --- a/drivers/media/video/zoran_device.c        Wed Aug 20 14:29:31 2003
26668 +++ b/drivers/media/video/zoran_device.c        Sun Aug 31 16:14:05 2003
26669 @@ -58,11 +58,11 @@
26670  extern const struct zoran_format zoran_formats[];
26671  extern const int zoran_num_formats;
26672  
26673 -extern int debug;
26674 +extern int *zr_debug;
26675  
26676  #define dprintk(num, format, args...) \
26677         do { \
26678 -               if (debug >= num) \
26679 +               if (*zr_debug >= num) \
26680                         printk(format, ##args); \
26681         } while (0)
26682  
26683 @@ -170,7 +170,7 @@
26684  static void
26685  dump_guests (struct zoran *zr)
26686  {
26687 -       if (debug > 2) {
26688 +       if (*zr_debug > 2) {
26689                 int i, guest[8];
26690  
26691                 for (i = 1; i < 8; i++) {       // Don't read jpeg codec here
26692 @@ -190,6 +190,7 @@
26693  get_time (void)
26694  {
26695         struct timeval tv;
26696 +
26697         do_gettimeofday(&tv);
26698         return (1000000 * tv.tv_sec + tv.tv_usec);
26699  }
26700 @@ -868,8 +869,8 @@
26701  void
26702  print_interrupts (struct zoran *zr)
26703  {
26704 -       int res, noerr;
26705 -       noerr = 0;
26706 +       int res, noerr = 0;
26707 +
26708         printk(KERN_INFO "%s: interrupts received:", ZR_DEVNAME(zr));
26709         if ((res = zr->field_counter) < -1 || res > 1) {
26710                 printk(" FD:%d", res);
26711 @@ -931,6 +932,7 @@
26712  count_reset_interrupt (struct zoran *zr)
26713  {
26714         u32 isr;
26715 +
26716         if ((isr = btread(ZR36057_ISR) & 0x78000000)) {
26717                 if (isr & ZR36057_ISR_GIRQ1) {
26718                         btwrite(ZR36057_ISR_GIRQ1, ZR36057_ISR);
26719 @@ -961,6 +963,7 @@
26720  jpeg_start (struct zoran *zr)
26721  {
26722         int reg;
26723 +
26724         zr->frame_num = 0;
26725  
26726         /* deassert P_reset, disable code transfer, deassert Active */
26727 @@ -1272,7 +1275,7 @@
26728                 zr->num_errors++;
26729  
26730                 /* Report error */
26731 -               if (debug > 1 && zr->num_errors <= 8) {
26732 +               if (*zr_debug > 1 && zr->num_errors <= 8) {
26733                         long frame;
26734                         frame =
26735                             zr->jpg_pend[zr->jpg_dma_tail & BUZ_MASK_FRAME];
26736 @@ -1453,38 +1456,23 @@
26737                                             0) {
26738                                                 /* it is finished, notify the user */
26739  
26740 -                                               zr->v4l_buffers.buffer[zr->
26741 -                                                                      v4l_grab_frame].
26742 -                                                   state = BUZ_STATE_DONE;
26743 -                                               zr->v4l_buffers.buffer[zr->
26744 -                                                                      v4l_grab_frame].
26745 -                                                   bs.seq =
26746 -                                                   zr->v4l_grab_seq;
26747 -                                               do_gettimeofday(&zr->
26748 -                                                               v4l_buffers.
26749 -                                                               buffer[zr->
26750 -                                                                      v4l_grab_frame].
26751 -                                                               bs.
26752 -                                                               timestamp);
26753 -                                               zr->v4l_grab_frame =
26754 -                                                   NO_GRAB_ACTIVE;
26755 +                                               zr->v4l_buffers.buffer[zr->v4l_grab_frame].state = BUZ_STATE_DONE;
26756 +                                               zr->v4l_buffers.buffer[zr->v4l_grab_frame].bs.seq = zr->v4l_grab_seq;
26757 +                                               do_gettimeofday(&zr->v4l_buffers.buffer[zr->v4l_grab_frame].bs.timestamp);
26758 +                                               zr->v4l_grab_frame = NO_GRAB_ACTIVE;
26759                                                 zr->v4l_pend_tail++;
26760                                         }
26761                                 }
26762  
26763                                 if (zr->v4l_grab_frame == NO_GRAB_ACTIVE)
26764 -                                       wake_up_interruptible(&zr->
26765 -                                                             v4l_capq);
26766 +                                       wake_up_interruptible(&zr->v4l_capq);
26767  
26768                                 /* Check if there is another grab queued */
26769  
26770                                 if (zr->v4l_grab_frame == NO_GRAB_ACTIVE &&
26771 -                                   zr->v4l_pend_tail !=
26772 -                                   zr->v4l_pend_head) {
26773 +                                   zr->v4l_pend_tail != zr->v4l_pend_head) {
26774  
26775 -                                       int frame =
26776 -                                           zr->v4l_pend[zr->
26777 -                                                        v4l_pend_tail &
26778 +                                       int frame = zr->v4l_pend[zr->v4l_pend_tail &
26779                                                          V4L_MASK_FRAME];
26780                                         u32 reg;
26781  
26782 @@ -1544,7 +1532,7 @@
26783  
26784                         if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS ||
26785                             zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) {
26786 -                               if (debug > 1 &&
26787 +                               if (*zr_debug > 1 &&
26788                                     (!zr->frame_num || zr->JPEG_error)) {
26789                                         printk(KERN_INFO
26790                                                "%s: first frame ready: state=0x%08x odd_even=%d field_per_buff=%d delay=%d\n",
26791 @@ -1559,11 +1547,8 @@
26792                                                 int i;
26793                                                 strcpy(sv, sc);
26794                                                 for (i = 0; i < 4; i++) {
26795 -                                                       if (zr->
26796 -                                                           stat_com[i] &
26797 -                                                           1)
26798 -                                                               sv[i] =
26799 -                                                                   '1';
26800 +                                                       if (zr->stat_com[i] & 1)
26801 +                                                               sv[i] = '1';
26802                                                 }
26803                                                 sv[4] = 0;
26804                                                 printk(KERN_INFO
26805 @@ -1584,7 +1569,7 @@
26806                                                     zr->JPEG_missed;
26807                                 }
26808  
26809 -                               if (debug > 2 && zr->frame_num < 6) {
26810 +                               if (*zr_debug > 2 && zr->frame_num < 6) {
26811                                         int i;
26812                                         printk("%s: seq=%ld stat_com:",
26813                                                ZR_DEVNAME(zr), zr->jpg_seq_num);
26814 @@ -1643,10 +1628,11 @@
26815  zoran_set_pci_master (struct zoran *zr,
26816                       int           set_master)
26817  {
26818 -       u16 command;
26819         if (set_master) {
26820                 pci_set_master(zr->pci_dev);
26821         } else {
26822 +               u16 command;
26823 +
26824                 pci_read_config_word(zr->pci_dev, PCI_COMMAND, &command);
26825                 command &= ~PCI_COMMAND_MASTER;
26826                 pci_write_config_word(zr->pci_dev, PCI_COMMAND, command);
26827 @@ -1657,6 +1643,7 @@
26828  zoran_init_hardware (struct zoran *zr)
26829  {
26830         int j, zero = 0;
26831 +
26832         /* Enable bus-mastering */
26833         zoran_set_pci_master(zr, 1);
26834  
26835 @@ -1718,6 +1705,7 @@
26836  zr36057_init_vfe (struct zoran *zr)
26837  {
26838         u32 reg;
26839 +
26840         reg = btread(ZR36057_VFESPFR);
26841         reg |= ZR36057_VFESPFR_LittleEndian;
26842         reg &= ~ZR36057_VFESPFR_VCLKPol;
26843 @@ -1748,6 +1736,7 @@
26844         if (zr->card.type == LML33 &&
26845             (cmd == DECODER_SET_NORM || DECODER_SET_INPUT)) {
26846                 int res;
26847 +
26848                 // Bt819 needs to reset its FIFO buffer using #FRST pin and
26849                 // LML33 card uses GPIO(7) for that.
26850                 GPIO(zr, 7, 0);
26851 diff -Nru a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
26852 --- a/drivers/media/video/zoran_driver.c        Wed Aug 20 14:29:31 2003
26853 +++ b/drivers/media/video/zoran_driver.c        Sun Aug 31 16:14:05 2003
26854 @@ -51,6 +51,7 @@
26855  #include <linux/delay.h>
26856  #include <linux/slab.h>
26857  #include <linux/pci.h>
26858 +#include <linux/vmalloc.h>
26859  
26860  #include <linux/interrupt.h>
26861  #include <linux/i2c.h>
26862 @@ -187,11 +188,11 @@
26863  #   include <linux/bigphysarea.h>
26864  #endif
26865  
26866 -extern int debug;
26867 +extern int *zr_debug;
26868  
26869  #define dprintk(num, format, args...) \
26870         do { \
26871 -               if (debug >= num) \
26872 +               if (*zr_debug >= num) \
26873                         printk(format, ##args); \
26874         } while (0)
26875  
26876 @@ -370,6 +371,7 @@
26877                         int n =
26878                             (fh->v4l_buffers.buffer_size + PAGE_SIZE -
26879                              1) / PAGE_SIZE;
26880 +
26881                         mem =
26882                             (unsigned char *) bigphysarea_alloc_pages(n, 0,
26883                                                                       GFP_KERNEL);
26884 @@ -412,6 +414,7 @@
26885                                 int size =
26886                                     fh->v4l_buffers.num_buffers *
26887                                     fh->v4l_buffers.buffer_size;
26888 +
26889                                 pmem = get_high_mem(size);
26890                                 if (pmem == 0) {
26891                                         dprintk(1,
26892 @@ -847,9 +850,10 @@
26893                 if (res)
26894                         return res;
26895         }
26896 -       if ((res =
26897 -            zoran_v4l_set_format(file, mp->width, mp->height,
26898 -                                 &zoran_formats[i])))
26899 +       if ((res = zoran_v4l_set_format(file,
26900 +                                       mp->width,
26901 +                                       mp->height,
26902 +                                       &zoran_formats[i])))
26903                 return res;
26904         zr->v4l_settings = fh->v4l_settings;
26905  
26906 @@ -1144,7 +1148,7 @@
26907                 frame = zr->jpg_pend[zr->jpg_que_tail & BUZ_MASK_FRAME];
26908  
26909         /* buffer should now be in BUZ_STATE_DONE */
26910 -       if (debug > 0)
26911 +       if (*zr_debug > 0)
26912                 if (zr->jpg_buffers.buffer[frame].state != BUZ_STATE_DONE)
26913                         dprintk(2,
26914                                 KERN_ERR
26915 @@ -1268,7 +1272,7 @@
26916  
26917         /* find the device */
26918         for (i = 0; i < zoran_num; i++) {
26919 -               if (zoran[i].video_dev.minor == minor) {
26920 +               if (zoran[i].video_dev->minor == minor) {
26921                         zr = &zoran[i];
26922                         break;
26923                 }
26924 @@ -1424,7 +1428,7 @@
26925                 /* disable interrupts */
26926                 btand(~ZR36057_ICR_IntPinEn, ZR36057_ICR);
26927  
26928 -               if (debug > 1)
26929 +               if (*zr_debug > 1)
26930                         print_interrupts(zr);
26931  
26932                 /* Overlay off */
26933 @@ -2032,6 +2036,7 @@
26934         case VIDIOCGCAP:
26935         {
26936                 struct video_capability *vcap = arg;
26937 +
26938                 dprintk(3, KERN_DEBUG "%s: VIDIOCGCAP\n", ZR_DEVNAME(zr));
26939  
26940                 memset(vcap, 0, sizeof(struct video_capability));
26941 @@ -2154,6 +2159,7 @@
26942  
26943                 for (i = 0; i < zoran_num_formats; i++) {
26944                         const struct zoran_format *fmt = &zoran_formats[i];
26945 +
26946                         if (fmt->palette != -1 &&
26947                             fmt->flags & ZORAN_FORMAT_OVERLAY &&
26948                             fmt->palette == vpict->palette &&
26949 @@ -2203,7 +2209,9 @@
26950         case VIDIOCGWIN:
26951         {
26952                 struct video_window *vwin = arg;
26953 +
26954                 dprintk(3, KERN_DEBUG "%s: VIDIOCGWIN\n", ZR_DEVNAME(zr));
26955 +
26956                 memset(vwin, 0, sizeof(struct video_window));
26957                 down(&zr->resource_lock);
26958                 vwin->x = fh->overlay_settings.x;
26959 @@ -2241,7 +2249,9 @@
26960         case VIDIOCGFBUF:
26961         {
26962                 struct video_buffer *vbuf = arg;
26963 +
26964                 dprintk(3, KERN_DEBUG "%s: VIDIOCGFBUF\n", ZR_DEVNAME(zr));
26965 +
26966                 down(&zr->resource_lock);
26967                 *vbuf = zr->buffer;
26968                 up(&zr->resource_lock);
26969 @@ -2285,8 +2295,10 @@
26970         case VIDIOCSYNC:
26971         {
26972                 int *frame = arg, res;
26973 +
26974                 dprintk(3, KERN_DEBUG "%s: VIDIOCSYNC - frame=%d\n",
26975                         ZR_DEVNAME(zr), *frame);
26976 +
26977                 down(&zr->resource_lock);
26978                 res = v4l_sync(file, *frame);
26979                 up(&zr->resource_lock);
26980 @@ -2300,11 +2312,13 @@
26981         {
26982                 struct video_mmap *vmap = arg;
26983                 int res;
26984 +
26985                 dprintk(3,
26986                         KERN_DEBUG
26987                         "%s: VIDIOCMCAPTURE - frame=%d, geom=%dx%d, fmt=%d\n",
26988                         ZR_DEVNAME(zr), vmap->frame, vmap->width, vmap->height,
26989                         vmap->format);
26990 +
26991                 down(&zr->resource_lock);
26992                 res = v4l_grab(file, vmap);
26993                 up(&zr->resource_lock);
26994 @@ -2358,7 +2372,8 @@
26995                 struct video_unit *vunit = arg;
26996  
26997                 dprintk(3, KERN_DEBUG "%s: VIDIOCGUNIT\n", ZR_DEVNAME(zr));
26998 -               vunit->video = zr->video_dev.minor;
26999 +
27000 +               vunit->video = zr->video_dev->minor;
27001                 vunit->vbi = VIDEO_NO_UNIT;
27002                 vunit->radio = VIDEO_NO_UNIT;
27003                 vunit->audio = VIDEO_NO_UNIT;
27004 @@ -2393,6 +2408,7 @@
27005         case BUZIOC_G_PARAMS:
27006         {
27007                 struct zoran_params *bparams = arg;
27008 +
27009                 dprintk(3, KERN_DEBUG "%s: BUZIOC_G_PARAMS\n", ZR_DEVNAME(zr));
27010  
27011                 memset(bparams, 0, sizeof(struct zoran_params));
27012 @@ -2686,6 +2702,7 @@
27013                 struct v4l2_fmtdesc *fmt = arg;
27014                 int index = fmt->index, num = -1, i, flag = 0, type =
27015                     fmt->type;
27016 +
27017                 dprintk(3, KERN_DEBUG "%s: VIDIOC_ENUM_FMT - index=%d\n",
27018                         ZR_DEVNAME(zr), fmt->index);
27019  
27020 @@ -3530,6 +3547,7 @@
27021         case VIDIOC_QUERYCTRL:
27022         {
27023                 struct v4l2_queryctrl *ctrl = arg;
27024 +
27025                 dprintk(3, KERN_DEBUG "%s: VIDIOC_QUERYCTRL - id=%d\n",
27026                         ZR_DEVNAME(zr), ctrl->id);
27027  
27028 @@ -3571,6 +3589,7 @@
27029         case VIDIOC_G_CTRL:
27030         {
27031                 struct v4l2_control *ctrl = arg;
27032 +
27033                 dprintk(3, KERN_DEBUG "%s: VIDIOC_G_CTRL - id=%d\n",
27034                         ZR_DEVNAME(zr), ctrl->id);
27035  
27036 @@ -3652,6 +3671,7 @@
27037         case VIDIOC_ENUMSTD:
27038         {
27039                 struct v4l2_standard *std = arg;
27040 +
27041                 dprintk(3, KERN_DEBUG "%s: VIDIOC_ENUMSTD - index=%d\n",
27042                         ZR_DEVNAME(zr), std->index);
27043  
27044 @@ -3707,6 +3727,7 @@
27045         {
27046                 v4l2_std_id *std = arg;
27047                 int norm;
27048 +
27049                 dprintk(3, KERN_DEBUG "%s: VIDIOC_G_STD\n", ZR_DEVNAME(zr));
27050  
27051                 down(&zr->resource_lock);
27052 @@ -3804,6 +3825,7 @@
27053         case VIDIOC_G_INPUT:
27054         {
27055                 int *input = arg;
27056 +
27057                 dprintk(3, KERN_DEBUG "%s: VIDIOC_G_INPUT\n", ZR_DEVNAME(zr));
27058  
27059                 down(&zr->resource_lock);
27060 @@ -3817,6 +3839,7 @@
27061         case VIDIOC_S_INPUT:
27062         {
27063                 int *input = arg, res = 0;
27064 +
27065                 dprintk(3, KERN_DEBUG "%s: VIDIOC_S_INPUT - input=%d\n",
27066                         ZR_DEVNAME(zr), *input);
27067  
27068 @@ -3835,6 +3858,7 @@
27069         case VIDIOC_ENUMOUTPUT:
27070         {
27071                 struct v4l2_output *outp = arg;
27072 +
27073                 dprintk(3, KERN_DEBUG "%s: VIDIOC_ENUMOUTPUT - index=%d\n",
27074                         ZR_DEVNAME(zr), outp->index);
27075  
27076 @@ -4005,7 +4029,9 @@
27077         case VIDIOC_G_JPEGCOMP:
27078         {
27079                 struct v4l2_jpegcompression *params = arg;
27080 -               dprintk(3, KERN_DEBUG "%s: VIDIOC_G_JPEGCOMP\n", ZR_DEVNAME(zr));
27081 +
27082 +               dprintk(3, KERN_DEBUG "%s: VIDIOC_G_JPEGCOMP\n",
27083 +                       ZR_DEVNAME(zr));
27084  
27085                 memset(params, 0, sizeof(*params));
27086  
27087 @@ -4175,6 +4201,7 @@
27088                         } else if (fmt->type ==
27089                                    V4L2_BUF_TYPE_VIDEO_CAPTURE) {
27090                                 int i;
27091 +
27092                                 for (i = 0; i < zoran_num_formats; i++)
27093                                         if (zoran_formats[i].fourcc ==
27094                                             fmt->fmt.pix.pixelformat)
27095 @@ -4321,6 +4348,7 @@
27096  zoran_vm_open (struct vm_area_struct *vma)
27097  {
27098         struct zoran_mapping *map = vma->vm_private_data;
27099 +
27100         map->count++;
27101  }
27102  
27103 @@ -4665,5 +4693,6 @@
27104  #endif
27105         .hardware = ZORAN_HARDWARE,
27106         .fops = &zoran_fops,
27107 +       .release = &zoran_vdev_release,
27108         .minor = -1
27109  };
27110 diff -Nru a/drivers/media/video/zoran_procfs.c b/drivers/media/video/zoran_procfs.c
27111 --- a/drivers/media/video/zoran_procfs.c        Wed Aug 20 15:38:07 2003
27112 +++ b/drivers/media/video/zoran_procfs.c        Sun Aug 31 16:14:05 2003
27113 @@ -49,11 +49,11 @@
27114  #include "zoran.h"
27115  #include "zoran_procfs.h"
27116  
27117 -extern int debug;
27118 +extern int *zr_debug;
27119  
27120  #define dprintk(num, format, args...) \
27121         do { \
27122 -               if (debug >= num) \
27123 +               if (*zr_debug >= num) \
27124                         printk(format, ##args); \
27125         } while (0)
27126  
27127 @@ -248,6 +248,7 @@
27128  {
27129  #ifdef CONFIG_PROC_FS
27130         char name[8];
27131 +
27132         snprintf(name, 7, "zoran%d", zr->id);
27133         if ((zr->zoran_proc = create_proc_entry(name, 0, 0))) {
27134                 zr->zoran_proc->read_proc = zoran_read_proc;
27135 @@ -272,6 +273,7 @@
27136  {
27137  #ifdef CONFIG_PROC_FS
27138         char name[8];
27139 +
27140         snprintf(name, 7, "zoran%d", zr->id);
27141         if (zr->zoran_proc) {
27142                 remove_proc_entry(name, 0);
27143 diff -Nru a/drivers/mtd/maps/ceiva.c b/drivers/mtd/maps/ceiva.c
27144 --- a/drivers/mtd/maps/ceiva.c  Wed May 28 08:01:03 2003
27145 +++ b/drivers/mtd/maps/ceiva.c  Sun Aug 31 16:14:08 2003
27146 @@ -64,23 +64,23 @@
27147  
27148  static struct mtd_partition ceiva_partitions[] = {
27149         {
27150 -               name: "Ceiva BOOT partition",
27151 -               size:   BOOT_PARTITION_SIZE_KiB*1024,
27152 -               offset: 0,
27153 +               .name = "Ceiva BOOT partition",
27154 +               .size   = BOOT_PARTITION_SIZE_KiB*1024,
27155 +               .offset = 0,
27156  
27157         },{
27158 -               name: "Ceiva parameters partition",
27159 -               size:   PARAMS_PARTITION_SIZE_KiB*1024,
27160 -               offset: (16 + 8) * 1024,
27161 +               .name = "Ceiva parameters partition",
27162 +               .size   = PARAMS_PARTITION_SIZE_KiB*1024,
27163 +               .offset = (16 + 8) * 1024,
27164         },{
27165 -               name: "Ceiva kernel partition",
27166 -               size: (KERNEL_PARTITION_SIZE_KiB)*1024,
27167 -               offset: 0x20000,
27168 +               .name = "Ceiva kernel partition",
27169 +               .size = (KERNEL_PARTITION_SIZE_KiB)*1024,
27170 +               .offset = 0x20000,
27171  
27172         },{
27173 -               name: "Ceiva root filesystem partition",
27174 -               offset: MTDPART_OFS_APPEND,
27175 -               size: (ROOT_PARTITION_SIZE_KiB)*1024,
27176 +               .name = "Ceiva root filesystem partition",
27177 +               .offset = MTDPART_OFS_APPEND,
27178 +               .size = (ROOT_PARTITION_SIZE_KiB)*1024,
27179         }
27180  };
27181  #endif
27182 diff -Nru a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
27183 --- a/drivers/mtd/maps/pcmciamtd.c      Wed Jun 25 03:30:03 2003
27184 +++ b/drivers/mtd/maps/pcmciamtd.c      Sat Aug 23 08:27:27 2003
27185 @@ -344,9 +344,8 @@
27186   * still open, this will be postponed until it is closed.
27187   */
27188  
27189 -static void pcmciamtd_release(u_long arg)
27190 +static void pcmciamtd_release(dev_link_t *link)
27191  {
27192 -       dev_link_t *link = (dev_link_t *)arg;
27193         struct pcmciamtd_dev *dev = link->priv;
27194  
27195         DEBUG(3, "link = 0x%p", link);
27196 @@ -564,7 +563,7 @@
27197  
27198         if(!dev->win_size) {
27199                 err("Cant allocate memory window");
27200 -               pcmciamtd_release((u_long)link);
27201 +               pcmciamtd_release(link);
27202                 return;
27203         }
27204         DEBUG(1, "Allocated a window of %dKiB", dev->win_size >> 10);
27205 @@ -576,7 +575,7 @@
27206         dev->win_base = ioremap(req.Base, req.Size);
27207         if(!dev->win_base) {
27208                 err("ioremap(%lu, %u) failed", req.Base, req.Size);
27209 -               pcmciamtd_release((u_long)link);
27210 +               pcmciamtd_release(link);
27211                 return;
27212         }
27213         DEBUG(1, "mapped window dev = %p req.base = 0x%lx base = %p size = 0x%x",
27214 @@ -631,7 +630,7 @@
27215         
27216         if(!mtd) {
27217                 DEBUG(1, "Cant find an MTD");
27218 -               pcmciamtd_release((u_long)link);
27219 +               pcmciamtd_release(link);
27220                 return;
27221         }
27222  
27223 @@ -671,7 +670,7 @@
27224                 map_destroy(mtd);
27225                 dev->mtd_info = NULL;
27226                 err("Couldnt register MTD device");
27227 -               pcmciamtd_release((u_long)link);
27228 +               pcmciamtd_release(link);
27229                 return;
27230         }
27231         snprintf(dev->node.dev_name, sizeof(dev->node.dev_name), "mtd%d", mtd->index);
27232 @@ -683,7 +682,7 @@
27233   cs_failed:
27234         cs_error(link->handle, last_fn, last_ret);
27235         err("CS Error, exiting");
27236 -       pcmciamtd_release((u_long)link);
27237 +       pcmciamtd_release(link);
27238         return;
27239  }
27240  
27241 @@ -710,7 +709,7 @@
27242                                 del_mtd_device(dev->mtd_info);
27243                                 info("mtd%d: Removed", dev->mtd_info->index);
27244                         }
27245 -                       mod_timer(&link->release, jiffies + HZ/20);
27246 +                       pcmciamtd_release(link);
27247                 }
27248                 break;
27249         case CS_EVENT_CARD_INSERTION:
27250 @@ -751,10 +750,8 @@
27251  {
27252         DEBUG(3, "link=0x%p", link);
27253  
27254 -       del_timer(&link->release);
27255 -
27256         if(link->state & DEV_CONFIG) {
27257 -               pcmciamtd_release((u_long)link);
27258 +               pcmciamtd_release(link);
27259         }
27260  
27261         if (link->handle) {
27262 @@ -789,10 +786,6 @@
27263         memset(dev, 0, sizeof(*dev));
27264         link = &dev->link;
27265         link->priv = dev;
27266 -
27267 -       init_timer(&link->release);
27268 -       link->release.function = &pcmciamtd_release;
27269 -       link->release.data = (u_long)link;
27270  
27271         link->conf.Attributes = 0;
27272         link->conf.IntType = INT_MEMORY;
27273 diff -Nru a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
27274 --- a/drivers/mtd/mtdchar.c     Wed May 28 08:01:05 2003
27275 +++ b/drivers/mtd/mtdchar.c     Tue Aug 26 09:25:41 2003
27276 @@ -59,7 +59,7 @@
27277  
27278  static int mtd_open(struct inode *inode, struct file *file)
27279  {
27280 -       int minor = minor(inode->i_rdev);
27281 +       int minor = iminor(inode);
27282         int devnum = minor >> 1;
27283         struct mtd_info *mtd;
27284  
27285 diff -Nru a/drivers/mtd/nand/autcpu12.c b/drivers/mtd/nand/autcpu12.c
27286 --- a/drivers/mtd/nand/autcpu12.c       Mon Jun 23 05:34:08 2003
27287 +++ b/drivers/mtd/nand/autcpu12.c       Sun Aug 31 16:14:08 2003
27288 @@ -73,39 +73,39 @@
27289  extern struct nand_oobinfo jffs2_oobinfo;
27290  
27291  static struct mtd_partition partition_info16k[] = {
27292 -       { name: "AUTCPU12 flash partition 1",
27293 -         offset:  0,
27294 -         size:    8 * SZ_1M },
27295 -       { name: "AUTCPU12 flash partition 2",
27296 -         offset:  8 * SZ_1M,
27297 -         size:    8 * SZ_1M },
27298 +       { .name = "AUTCPU12 flash partition 1",
27299 +         .offset  = 0,
27300 +         .size =    8 * SZ_1M },
27301 +       { .name = "AUTCPU12 flash partition 2",
27302 +         .offset =  8 * SZ_1M,
27303 +         .size =    8 * SZ_1M },
27304  };
27305  
27306  static struct mtd_partition partition_info32k[] = {
27307 -       { name: "AUTCPU12 flash partition 1",
27308 -         offset:  0,
27309 -         size:    8 * SZ_1M },
27310 -       { name: "AUTCPU12 flash partition 2",
27311 -         offset:  8 * SZ_1M,
27312 -         size:   24 * SZ_1M },
27313 +       { .name = "AUTCPU12 flash partition 1",
27314 +         .offset  = 0,
27315 +         .size =    8 * SZ_1M },
27316 +       { .name = "AUTCPU12 flash partition 2",
27317 +         .offset =  8 * SZ_1M,
27318 +         .size =   24 * SZ_1M },
27319  };
27320  
27321  static struct mtd_partition partition_info64k[] = {
27322 -       { name: "AUTCPU12 flash partition 1",
27323 -         offset:  0,
27324 -         size:   16 * SZ_1M },
27325 -       { name: "AUTCPU12 flash partition 2",
27326 -         offset: 16 * SZ_1M,
27327 -         size:   48 * SZ_1M },
27328 +       { .name = "AUTCPU12 flash partition 1",
27329 +         .offset  = 0,
27330 +         .size =   16 * SZ_1M },
27331 +       { .name = "AUTCPU12 flash partition 2",
27332 +         .offset = 16 * SZ_1M,
27333 +         .size =   48 * SZ_1M },
27334  };
27335  
27336  static struct mtd_partition partition_info128k[] = {
27337 -       { name: "AUTCPU12 flash partition 1",
27338 -         offset:  0,
27339 -         size:   16 * SZ_1M },
27340 -       { name: "AUTCPU12 flash partition 2",
27341 -         offset: 16 * SZ_1M,
27342 -         size:   112 * SZ_1M },
27343 +       { .name = "AUTCPU12 flash partition 1",
27344 +         .offset  = 0,
27345 +         .size =   16 * SZ_1M },
27346 +       { .name = "AUTCPU12 flash partition 2",
27347 +         .offset = 16 * SZ_1M,
27348 +         .size =   112 * SZ_1M },
27349  };
27350  
27351  #define NUM_PARTITIONS16K 2
27352 diff -Nru a/drivers/mtd/nand/edb7312.c b/drivers/mtd/nand/edb7312.c
27353 --- a/drivers/mtd/nand/edb7312.c        Wed May 28 08:01:25 2003
27354 +++ b/drivers/mtd/nand/edb7312.c        Sun Aug 31 16:14:08 2003
27355 @@ -71,9 +71,9 @@
27356   * Define static partitions for flash device
27357   */
27358  static struct mtd_partition partition_info[] = {
27359 -       { name: "EP7312 Nand Flash",
27360 -                 offset: 0,
27361 -                 size: 8*1024*1024 }
27362 +       { .name = "EP7312 Nand Flash",
27363 +                 .offset = 0,
27364 +                 .size = 8*1024*1024 }
27365  };
27366  #define NUM_PARTITIONS 1
27367  
27368 diff -Nru a/drivers/net/3c501.c b/drivers/net/3c501.c
27369 --- a/drivers/net/3c501.c       Sun Apr 20 22:41:08 2003
27370 +++ b/drivers/net/3c501.c       Tue Aug 26 13:21:28 2003
27371 @@ -307,7 +307,7 @@
27372         dev->stop = &el1_close;
27373         dev->get_stats = &el1_get_stats;
27374         dev->set_multicast_list = &set_multicast_list;
27375 -       dev->do_ioctl = netdev_ioctl;
27376 +       dev->ethtool_ops = &netdev_ethtool_ops;
27377  
27378         /*
27379          *      Setup the generic properties
27380 @@ -857,86 +857,31 @@
27381         }
27382  }
27383  
27384 -/**
27385 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
27386 - * @dev: network interface on which out-of-band action is to be performed
27387 - * @useraddr: userspace address to which data is to be read and returned
27388 - *
27389 - * Process the various commands of the SIOCETHTOOL interface.
27390 - */
27391  
27392 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
27393 +static void netdev_get_drvinfo(struct net_device *dev,
27394 +                              struct ethtool_drvinfo *info)
27395  {
27396 -       u32 ethcmd;
27397 -
27398 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
27399 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
27400 -
27401 -       if (get_user(ethcmd, (u32 *)useraddr))
27402 -               return -EFAULT;
27403 -
27404 -       switch (ethcmd) {
27405 -
27406 -       case ETHTOOL_GDRVINFO: {
27407 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
27408 -               strcpy (info.driver, DRV_NAME);
27409 -               strcpy (info.version, DRV_VERSION);
27410 -               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
27411 -               if (copy_to_user (useraddr, &info, sizeof (info)))
27412 -                       return -EFAULT;
27413 -               return 0;
27414 -       }
27415 -
27416 -       /* get message-level */
27417 -       case ETHTOOL_GMSGLVL: {
27418 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
27419 -               edata.data = debug;
27420 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
27421 -                       return -EFAULT;
27422 -               return 0;
27423 -       }
27424 -       /* set message-level */
27425 -       case ETHTOOL_SMSGLVL: {
27426 -               struct ethtool_value edata;
27427 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
27428 -                       return -EFAULT;
27429 -               debug = edata.data;
27430 -               return 0;
27431 -       }
27432 -
27433 -       default:
27434 -               break;
27435 -       }
27436 -
27437 -       return -EOPNOTSUPP;
27438 +       strcpy(info->driver, DRV_NAME);
27439 +       strcpy(info->version, DRV_VERSION);
27440 +       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
27441  }
27442  
27443 -/**
27444 - * netdev_ioctl: Handle network interface ioctls
27445 - * @dev: network interface on which out-of-band action is to be performed
27446 - * @rq: user request data
27447 - * @cmd: command issued by user
27448 - *
27449 - * Process the various out-of-band ioctls passed to this driver.
27450 - */
27451 +static u32 netdev_get_msglevel(struct net_device *dev)
27452 +{
27453 +       return debug;
27454 +}
27455  
27456 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
27457 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
27458  {
27459 -       int rc = 0;
27460 +       debug = level;
27461 +}
27462  
27463 -       switch (cmd) {
27464 -       case SIOCETHTOOL:
27465 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
27466 -               break;
27467 -
27468 -       default:
27469 -               rc = -EOPNOTSUPP;
27470 -               break;
27471 -       }
27472 +static struct ethtool_ops netdev_ethtool_ops = {
27473 +       .get_drvinfo            = netdev_get_drvinfo,
27474 +       .get_msglevel           = netdev_get_msglevel,
27475 +       .set_msglevel           = netdev_set_msglevel,
27476 +};
27477  
27478 -       return rc;
27479 -}
27480
27481  #ifdef MODULE
27482  
27483  static struct net_device dev_3c501 = {
27484 diff -Nru a/drivers/net/3c501.h b/drivers/net/3c501.h
27485 --- a/drivers/net/3c501.h       Sun Apr 20 22:41:08 2003
27486 +++ b/drivers/net/3c501.h       Tue Aug 26 13:21:28 2003
27487 @@ -14,7 +14,7 @@
27488  static int  el1_close(struct net_device *dev);
27489  static struct net_device_stats *el1_get_stats(struct net_device *dev);
27490  static void set_multicast_list(struct net_device *dev);
27491 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
27492 +static struct ethtool_ops netdev_ethtool_ops;
27493  
27494  #define EL1_IO_EXTENT  16
27495  
27496 diff -Nru a/drivers/net/3c503.c b/drivers/net/3c503.c
27497 --- a/drivers/net/3c503.c       Mon Feb 24 10:34:15 2003
27498 +++ b/drivers/net/3c503.c       Tue Aug 26 13:29:32 2003
27499 @@ -80,7 +80,7 @@
27500                            int ring_offset);
27501  static void el2_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
27502                          int ring_page);
27503 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
27504 +static struct ethtool_ops netdev_ethtool_ops;
27505  
27506  \f
27507  /* This routine probes for a memory-mapped 3c503 board by looking for
27508 @@ -308,7 +308,7 @@
27509  
27510      dev->open = &el2_open;
27511      dev->stop = &el2_close;
27512 -    dev->do_ioctl = &netdev_ioctl;
27513 +    dev->ethtool_ops = &netdev_ethtool_ops;
27514  
27515      if (dev->mem_start)
27516         printk("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n",
27517 @@ -617,69 +617,18 @@
27518      return;
27519  }
27520  
27521 -/**
27522 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
27523 - * @dev: network interface on which out-of-band action is to be performed
27524 - * @useraddr: userspace address to which data is to be read and returned
27525 - *
27526 - * Process the various commands of the SIOCETHTOOL interface.
27527 - */
27528  
27529 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
27530 +static void netdev_get_drvinfo(struct net_device *dev,
27531 +                              struct ethtool_drvinfo *info)
27532  {
27533 -       u32 ethcmd;
27534 -
27535 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
27536 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
27537 -
27538 -       if (get_user(ethcmd, (u32 *)useraddr))
27539 -               return -EFAULT;
27540 -
27541 -       switch (ethcmd) {
27542 -
27543 -       case ETHTOOL_GDRVINFO: {
27544 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
27545 -               strcpy (info.driver, DRV_NAME);
27546 -               strcpy (info.version, DRV_VERSION);
27547 -               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
27548 -               if (copy_to_user (useraddr, &info, sizeof (info)))
27549 -                       return -EFAULT;
27550 -               return 0;
27551 -       }
27552 -
27553 -       default:
27554 -               break;
27555 -       }
27556 -
27557 -       return -EOPNOTSUPP;
27558 +       strcpy(info->driver, DRV_NAME);
27559 +       strcpy(info->version, DRV_VERSION);
27560 +       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
27561  }
27562  
27563 -/**
27564 - * netdev_ioctl: Handle network interface ioctls
27565 - * @dev: network interface on which out-of-band action is to be performed
27566 - * @rq: user request data
27567 - * @cmd: command issued by user
27568 - *
27569 - * Process the various out-of-band ioctls passed to this driver.
27570 - */
27571 -
27572 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
27573 -{
27574 -       int rc = 0;
27575 -
27576 -       switch (cmd) {
27577 -       case SIOCETHTOOL:
27578 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
27579 -               break;
27580 -
27581 -       default:
27582 -               rc = -EOPNOTSUPP;
27583 -               break;
27584 -       }
27585 -
27586 -       return rc;
27587 -}
27588
27589 +static struct ethtool_ops netdev_ethtool_ops = {
27590 +       .get_drvinfo            = netdev_get_drvinfo,
27591 +};
27592  
27593  #ifdef MODULE
27594  #define MAX_EL2_CARDS  4       /* Max number of EL2 cards per module */
27595 diff -Nru a/drivers/net/3c505.c b/drivers/net/3c505.c
27596 --- a/drivers/net/3c505.c       Wed Jun  4 06:07:40 2003
27597 +++ b/drivers/net/3c505.c       Tue Aug 26 13:29:32 2003
27598 @@ -1163,86 +1163,30 @@
27599         return &adapter->stats;
27600  }
27601  
27602 -/**
27603 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
27604 - * @dev: network interface on which out-of-band action is to be performed
27605 - * @useraddr: userspace address to which data is to be read and returned
27606 - *
27607 - * Process the various commands of the SIOCETHTOOL interface.
27608 - */
27609 -
27610 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
27611 -{
27612 -       u32 ethcmd;
27613 -
27614 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
27615 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
27616 -
27617 -       if (get_user(ethcmd, (u32 *)useraddr))
27618 -               return -EFAULT;
27619 -
27620 -       switch (ethcmd) {
27621 -
27622 -       case ETHTOOL_GDRVINFO: {
27623 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
27624 -               strcpy (info.driver, DRV_NAME);
27625 -               strcpy (info.version, DRV_VERSION);
27626 -               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
27627 -               if (copy_to_user (useraddr, &info, sizeof (info)))
27628 -                       return -EFAULT;
27629 -               return 0;
27630 -       }
27631 -
27632 -       /* get message-level */
27633 -       case ETHTOOL_GMSGLVL: {
27634 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
27635 -               edata.data = debug;
27636 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
27637 -                       return -EFAULT;
27638 -               return 0;
27639 -       }
27640 -       /* set message-level */
27641 -       case ETHTOOL_SMSGLVL: {
27642 -               struct ethtool_value edata;
27643 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
27644 -                       return -EFAULT;
27645 -               debug = edata.data;
27646 -               return 0;
27647 -       }
27648 -
27649 -       default:
27650 -               break;
27651 -       }
27652  
27653 -       return -EOPNOTSUPP;
27654 +static void netdev_get_drvinfo(struct net_device *dev,
27655 +                              struct ethtool_drvinfo *info)
27656 +{
27657 +       strcpy(info->driver, DRV_NAME);
27658 +       strcpy(info->version, DRV_VERSION);
27659 +       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
27660  }
27661  
27662 -/**
27663 - * netdev_ioctl: Handle network interface ioctls
27664 - * @dev: network interface on which out-of-band action is to be performed
27665 - * @rq: user request data
27666 - * @cmd: command issued by user
27667 - *
27668 - * Process the various out-of-band ioctls passed to this driver.
27669 - */
27670 -
27671 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
27672 -{
27673 -       int rc = 0;
27674 -
27675 -       switch (cmd) {
27676 -       case SIOCETHTOOL:
27677 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
27678 -               break;
27679 -
27680 -       default:
27681 -               rc = -EOPNOTSUPP;
27682 -               break;
27683 -       }
27684 +static u32 netdev_get_msglevel(struct net_device *dev)
27685 +{
27686 +       return debug;
27687 +}
27688  
27689 -       return rc;
27690 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
27691 +{
27692 +       debug = level;
27693  }
27694
27695 +
27696 +static struct ethtool_ops netdev_ethtool_ops = {
27697 +       .get_drvinfo            = netdev_get_drvinfo,
27698 +       .get_msglevel           = netdev_get_msglevel,
27699 +       .set_msglevel           = netdev_set_msglevel,
27700 +};
27701  
27702  /******************************************************
27703   *
27704 @@ -1373,7 +1317,7 @@
27705         dev->tx_timeout = elp_timeout;                  /* local */
27706         dev->watchdog_timeo = 10*HZ;
27707         dev->set_multicast_list = elp_set_mc_list;      /* local */
27708 -       dev->do_ioctl = netdev_ioctl;                   /* local */
27709 +       dev->ethtool_ops = &netdev_ethtool_ops;         /* local */
27710  
27711         /* Setup the generic properties */
27712         ether_setup(dev);
27713 diff -Nru a/drivers/net/3c507.c b/drivers/net/3c507.c
27714 --- a/drivers/net/3c507.c       Sun Apr 20 22:41:08 2003
27715 +++ b/drivers/net/3c507.c       Tue Aug 26 13:29:32 2003
27716 @@ -299,7 +299,7 @@
27717  
27718  static void hardware_send_packet(struct net_device *dev, void *buf, short length, short pad);
27719  static void init_82586_mem(struct net_device *dev);
27720 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
27721 +static struct ethtool_ops netdev_ethtool_ops;
27722  
27723  \f
27724  /* Check for a network adaptor of this type, and return '0' iff one exists.
27725 @@ -431,7 +431,7 @@
27726         dev->get_stats  = el16_get_stats;
27727         dev->tx_timeout = el16_tx_timeout;
27728         dev->watchdog_timeo = TX_TIMEOUT;
27729 -       dev->do_ioctl = netdev_ioctl;
27730 +       dev->ethtool_ops = &netdev_ethtool_ops;
27731  
27732         ether_setup(dev);       /* Generic ethernet behaviour */
27733  
27734 @@ -874,86 +874,29 @@
27735         lp->rx_tail = rx_tail;
27736  }
27737  
27738 -/**
27739 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
27740 - * @dev: network interface on which out-of-band action is to be performed
27741 - * @useraddr: userspace address to which data is to be read and returned
27742 - *
27743 - * Process the various commands of the SIOCETHTOOL interface.
27744 - */
27745 -
27746 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
27747 -{
27748 -       u32 ethcmd;
27749 -
27750 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
27751 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
27752 -
27753 -       if (get_user(ethcmd, (u32 *)useraddr))
27754 -               return -EFAULT;
27755 -
27756 -       switch (ethcmd) {
27757 -
27758 -       case ETHTOOL_GDRVINFO: {
27759 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
27760 -               strcpy (info.driver, DRV_NAME);
27761 -               strcpy (info.version, DRV_VERSION);
27762 -               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
27763 -               if (copy_to_user (useraddr, &info, sizeof (info)))
27764 -                       return -EFAULT;
27765 -               return 0;
27766 -       }
27767 -
27768 -       /* get message-level */
27769 -       case ETHTOOL_GMSGLVL: {
27770 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
27771 -               edata.data = debug;
27772 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
27773 -                       return -EFAULT;
27774 -               return 0;
27775 -       }
27776 -       /* set message-level */
27777 -       case ETHTOOL_SMSGLVL: {
27778 -               struct ethtool_value edata;
27779 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
27780 -                       return -EFAULT;
27781 -               debug = edata.data;
27782 -               return 0;
27783 -       }
27784 -
27785 -       default:
27786 -               break;
27787 -       }
27788 -
27789 -       return -EOPNOTSUPP;
27790 +static void netdev_get_drvinfo(struct net_device *dev,
27791 +                              struct ethtool_drvinfo *info)
27792 +{
27793 +       strcpy(info->driver, DRV_NAME);
27794 +       strcpy(info->version, DRV_VERSION);
27795 +       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
27796  }
27797  
27798 -/**
27799 - * netdev_ioctl: Handle network interface ioctls
27800 - * @dev: network interface on which out-of-band action is to be performed
27801 - * @rq: user request data
27802 - * @cmd: command issued by user
27803 - *
27804 - * Process the various out-of-band ioctls passed to this driver.
27805 - */
27806 -
27807 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
27808 +static u32 netdev_get_msglevel(struct net_device *dev)
27809  {
27810 -       int rc = 0;
27811 -
27812 -       switch (cmd) {
27813 -       case SIOCETHTOOL:
27814 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
27815 -               break;
27816 -
27817 -       default:
27818 -               rc = -EOPNOTSUPP;
27819 -               break;
27820 -       }
27821 +       return debug;
27822 +}
27823  
27824 -       return rc;
27825 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
27826 +{
27827 +       debug = level;
27828  }
27829
27830 +
27831 +static struct ethtool_ops netdev_ethtool_ops = {
27832 +       .get_drvinfo            = netdev_get_drvinfo,
27833 +       .get_msglevel           = netdev_get_msglevel,
27834 +       .set_msglevel           = netdev_set_msglevel,
27835 +};
27836  
27837  #ifdef MODULE
27838  static struct net_device dev_3c507;
27839 diff -Nru a/drivers/net/3c509.c b/drivers/net/3c509.c
27840 --- a/drivers/net/3c509.c       Tue Aug 19 20:53:14 2003
27841 +++ b/drivers/net/3c509.c       Sun Aug 31 22:52:48 2003
27842 @@ -300,10 +300,11 @@
27843   *
27844   * Both call el3_common_init/el3_common_remove. */
27845  
27846 -static void __init el3_common_init(struct net_device *dev)
27847 +static int __init el3_common_init(struct net_device *dev)
27848  {
27849         struct el3_private *lp = dev->priv;
27850         short i;
27851 +       int err;
27852  
27853         spin_lock_init(&lp->lock);
27854  
27855 @@ -314,10 +315,29 @@
27856                 dev->if_port |= (dev->mem_start & 0x08);
27857         }
27858  
27859 +       /* The EL3-specific entries in the device structure. */
27860 +       dev->open = &el3_open;
27861 +       dev->hard_start_xmit = &el3_start_xmit;
27862 +       dev->stop = &el3_close;
27863 +       dev->get_stats = &el3_get_stats;
27864 +       dev->set_multicast_list = &set_multicast_list;
27865 +       dev->tx_timeout = el3_tx_timeout;
27866 +       dev->watchdog_timeo = TX_TIMEOUT;
27867 +       dev->do_ioctl = netdev_ioctl;
27868 +
27869 +       err = register_netdev(dev);
27870 +       if (err) {
27871 +               printk(KERN_ERR "Failed to register 3c5x9 at %#3.3lx, IRQ %d.\n",
27872 +                       dev->base_addr, dev->irq);
27873 +               release_region(dev->base_addr, EL3_IO_EXTENT);
27874 +               return err;
27875 +       }
27876 +
27877         {
27878                 const char *if_names[] = {"10baseT", "AUI", "undefined", "BNC"};
27879 -               printk("%s: 3c5x9 at %#3.3lx, %s port, address ",
27880 -                       dev->name, dev->base_addr, if_names[(dev->if_port & 0x03)]);
27881 +               printk("%s: 3c5x9 found at %#3.3lx, %s port, address ",
27882 +                       dev->name, dev->base_addr, 
27883 +                       if_names[(dev->if_port & 0x03)]);
27884         }
27885  
27886         /* Read in the station address. */
27887 @@ -327,16 +347,8 @@
27888  
27889         if (el3_debug > 0)
27890                 printk(KERN_INFO "%s" KERN_INFO "%s", versionA, versionB);
27891 +       return 0;
27892  
27893 -       /* The EL3-specific entries in the device structure. */
27894 -       dev->open = &el3_open;
27895 -       dev->hard_start_xmit = &el3_start_xmit;
27896 -       dev->stop = &el3_close;
27897 -       dev->get_stats = &el3_get_stats;
27898 -       dev->set_multicast_list = &set_multicast_list;
27899 -       dev->tx_timeout = el3_tx_timeout;
27900 -       dev->watchdog_timeo = TX_TIMEOUT;
27901 -       dev->do_ioctl = netdev_ioctl;
27902  }
27903  
27904  static void el3_common_remove (struct net_device *dev)
27905 @@ -564,9 +576,8 @@
27906  #if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800)
27907         lp->dev = &idev->dev;
27908  #endif
27909 -       el3_common_init(dev);
27910 +       err = el3_common_init(dev);
27911  
27912 -       err = register_netdev(dev);
27913         if (err)
27914                 goto out1;
27915  
27916 @@ -588,7 +599,6 @@
27917         return 0;
27918  
27919  out1:
27920 -       release_region(ioaddr, EL3_IO_EXTENT);
27921  #if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800)
27922         if (idev)
27923                 pnp_device_detach(idev);
27924 @@ -629,8 +639,8 @@
27925                            el3_mca_adapter_names[mdev->index], slot + 1);
27926  
27927                 /* claim the slot */
27928 -               strncpy(device->name, el3_mca_adapter_names[mdev->index],
27929 -                               sizeof(device->name));
27930 +               strncpy(mdev->name, el3_mca_adapter_names[mdev->index],
27931 +                               sizeof(mdev->name));
27932                 mca_device_set_claim(mdev, 1);
27933  
27934                 if_port = pos4 & 0x03;
27935 @@ -662,11 +672,9 @@
27936                 lp->dev = device;
27937                 lp->type = EL3_MCA;
27938                 device->driver_data = dev;
27939 -               el3_common_init(dev);
27940 +               err = el3_common_init(dev);
27941  
27942 -               err = register_netdev(dev);
27943                 if (err) {
27944 -                       release_region(ioaddr, EL3_IO_EXTENT);
27945                         return -ENOMEM;
27946                 }
27947  
27948 @@ -723,11 +731,9 @@
27949         lp->dev = device;
27950         lp->type = EL3_EISA;
27951         eisa_set_drvdata (edev, dev);
27952 -       el3_common_init(dev);
27953 +       err = el3_common_init(dev);
27954  
27955 -       err = register_netdev(dev);
27956         if (err) {
27957 -               release_region(ioaddr, EL3_IO_EXTENT);
27958                 return err;
27959         }
27960  
27961 diff -Nru a/drivers/net/3c515.c b/drivers/net/3c515.c
27962 --- a/drivers/net/3c515.c       Tue Aug 19 20:53:14 2003
27963 +++ b/drivers/net/3c515.c       Tue Aug 26 13:42:22 2003
27964 @@ -392,7 +392,7 @@
27965  static void update_stats(int addr, struct net_device *dev);
27966  static struct net_device_stats *corkscrew_get_stats(struct net_device *dev);
27967  static void set_rx_mode(struct net_device *dev);
27968 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
27969 +static struct ethtool_ops netdev_ethtool_ops;
27970  \f
27971  
27972  /* 
27973 @@ -718,7 +718,7 @@
27974         dev->stop = &corkscrew_close;
27975         dev->get_stats = &corkscrew_get_stats;
27976         dev->set_multicast_list = &set_rx_mode;
27977 -       dev->do_ioctl = netdev_ioctl;
27978 +       dev->ethtool_ops = &netdev_ethtool_ops;
27979  
27980         return 0;
27981  }
27982 @@ -1580,86 +1580,30 @@
27983         outw(new_mode, ioaddr + EL3_CMD);
27984  }
27985  
27986 -/**
27987 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
27988 - * @dev: network interface on which out-of-band action is to be performed
27989 - * @useraddr: userspace address to which data is to be read and returned
27990 - *
27991 - * Process the various commands of the SIOCETHTOOL interface.
27992 - */
27993 -
27994 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
27995 +static void netdev_get_drvinfo(struct net_device *dev,
27996 +                              struct ethtool_drvinfo *info)
27997  {
27998 -       u32 ethcmd;
27999 -
28000 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
28001 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
28002 -
28003 -       if (get_user(ethcmd, (u32 *)useraddr))
28004 -               return -EFAULT;
28005 -
28006 -       switch (ethcmd) {
28007 -
28008 -       case ETHTOOL_GDRVINFO: {
28009 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
28010 -               strcpy (info.driver, DRV_NAME);
28011 -               strcpy (info.version, DRV_VERSION);
28012 -               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
28013 -               if (copy_to_user (useraddr, &info, sizeof (info)))
28014 -                       return -EFAULT;
28015 -               return 0;
28016 -       }
28017 -
28018 -       /* get message-level */
28019 -       case ETHTOOL_GMSGLVL: {
28020 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
28021 -               edata.data = corkscrew_debug;
28022 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
28023 -                       return -EFAULT;
28024 -               return 0;
28025 -       }
28026 -       /* set message-level */
28027 -       case ETHTOOL_SMSGLVL: {
28028 -               struct ethtool_value edata;
28029 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
28030 -                       return -EFAULT;
28031 -               corkscrew_debug = edata.data;
28032 -               return 0;
28033 -       }
28034 -
28035 -       default:
28036 -               break;
28037 -       }
28038 -
28039 -       return -EOPNOTSUPP;
28040 +       strcpy(info->driver, DRV_NAME);
28041 +       strcpy(info->version, DRV_VERSION);
28042 +       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
28043  }
28044  
28045 -/**
28046 - * netdev_ioctl: Handle network interface ioctls
28047 - * @dev: network interface on which out-of-band action is to be performed
28048 - * @rq: user request data
28049 - * @cmd: command issued by user
28050 - *
28051 - * Process the various out-of-band ioctls passed to this driver.
28052 - */
28053 -
28054 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
28055 +static u32 netdev_get_msglevel(struct net_device *dev)
28056  {
28057 -       int rc = 0;
28058 +       return debug;
28059 +}
28060  
28061 -       switch (cmd) {
28062 -       case SIOCETHTOOL:
28063 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
28064 -               break;
28065 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
28066 +{
28067 +       debug = level;
28068 +}
28069  
28070 -       default:
28071 -               rc = -EOPNOTSUPP;
28072 -               break;
28073 -       }
28074 +static struct ethtool_ops netdev_ethtool_ops = {
28075 +       .get_drvinfo            = netdev_get_drvinfo,
28076 +       .get_msglevel           = netdev_get_msglevel,
28077 +       .set_msglevel           = netdev_set_msglevel,
28078 +};
28079  
28080 -       return rc;
28081 -}
28082
28083  \f
28084  #ifdef MODULE
28085  void cleanup_module(void)
28086 diff -Nru a/drivers/net/3c523.c b/drivers/net/3c523.c
28087 --- a/drivers/net/3c523.c       Sun Apr 27 20:36:18 2003
28088 +++ b/drivers/net/3c523.c       Tue Aug 26 13:42:22 2003
28089 @@ -188,7 +188,7 @@
28090  #ifdef ELMC_MULTICAST
28091  static void set_multicast_list(struct net_device *dev);
28092  #endif
28093 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
28094 +static struct ethtool_ops netdev_ethtool_ops;
28095  
28096  /* helper-functions */
28097  static int init586(struct net_device *dev);
28098 @@ -571,7 +571,7 @@
28099  #else
28100         dev->set_multicast_list = NULL;
28101  #endif
28102 -       dev->do_ioctl = netdev_ioctl;
28103 +       dev->ethtool_ops = &netdev_ethtool_ops;
28104         
28105         ether_setup(dev);
28106  
28107 @@ -1228,70 +1228,17 @@
28108  }
28109  #endif
28110  
28111 -/**
28112 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
28113 - * @dev: network interface on which out-of-band action is to be performed
28114 - * @useraddr: userspace address to which data is to be read and returned
28115 - *
28116 - * Process the various commands of the SIOCETHTOOL interface.
28117 - */
28118 -
28119 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
28120 +static void netdev_get_drvinfo(struct net_device *dev,
28121 +                              struct ethtool_drvinfo *info)
28122  {
28123 -       u32 ethcmd;
28124 -
28125 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
28126 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
28127 -
28128 -       if (get_user(ethcmd, (u32 *)useraddr))
28129 -               return -EFAULT;
28130 -
28131 -       switch (ethcmd) {
28132 -
28133 -       case ETHTOOL_GDRVINFO: {
28134 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
28135 -               strcpy (info.driver, DRV_NAME);
28136 -               strcpy (info.version, DRV_VERSION);
28137 -               sprintf(info.bus_info, "MCA 0x%lx", dev->base_addr);
28138 -               if (copy_to_user (useraddr, &info, sizeof (info)))
28139 -                       return -EFAULT;
28140 -               return 0;
28141 -       }
28142 -
28143 -       default:
28144 -               break;
28145 -       }
28146 -
28147 -       return -EOPNOTSUPP;
28148 +       strcpy(info->driver, DRV_NAME);
28149 +       strcpy(info->version, DRV_VERSION);
28150 +       sprintf(info->bus_info, "MCA 0x%lx", dev->base_addr);
28151  }
28152  
28153 -/**
28154 - * netdev_ioctl: Handle network interface ioctls
28155 - * @dev: network interface on which out-of-band action is to be performed
28156 - * @rq: user request data
28157 - * @cmd: command issued by user
28158 - *
28159 - * Process the various out-of-band ioctls passed to this driver.
28160 - */
28161 -
28162 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
28163 -{
28164 -       int rc = 0;
28165 -
28166 -       switch (cmd) {
28167 -       case SIOCETHTOOL:
28168 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
28169 -               break;
28170 -
28171 -       default:
28172 -               rc = -EOPNOTSUPP;
28173 -               break;
28174 -       }
28175 -
28176 -       return rc;
28177 -}
28178
28179 -/*************************************************************************/
28180 +static struct ethtool_ops netdev_ethtool_ops = {
28181 +       .get_drvinfo            = netdev_get_drvinfo,
28182 +};
28183  
28184  #ifdef MODULE
28185  
28186 diff -Nru a/drivers/net/3c527.c b/drivers/net/3c527.c
28187 --- a/drivers/net/3c527.c       Sun Apr 27 20:36:18 2003
28188 +++ b/drivers/net/3c527.c       Sun Aug 31 06:34:16 2003
28189 @@ -218,7 +218,7 @@
28190  static struct  net_device_stats *mc32_get_stats(struct net_device *dev);
28191  static void    mc32_set_multicast_list(struct net_device *dev);
28192  static void    mc32_reset_multicast_list(struct net_device *dev);
28193 -static int     netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
28194 +static struct ethtool_ops netdev_ethtool_ops;
28195  
28196  /**
28197   * mc32_probe  -       Search for supported boards
28198 @@ -508,7 +508,7 @@
28199         dev->set_multicast_list = mc32_set_multicast_list;
28200         dev->tx_timeout         = mc32_timeout;
28201         dev->watchdog_timeo     = HZ*5; /* Board does all the work */
28202 -       dev->do_ioctl           = netdev_ioctl;
28203 +       dev->ethtool_ops        = &netdev_ethtool_ops;
28204         
28205         lp->xceiver_state = HALTED; 
28206         
28207 @@ -1081,14 +1081,15 @@
28208         /* NP is the buffer we will be loading */
28209         np=lp->tx_ring[lp->tx_ring_head].p; 
28210  
28211 -       /* We will need this to flush the buffer out */
28212 -       lp->tx_ring[lp->tx_ring_head].skb=skb;
28213 -          
28214         if (skb->len < ETH_ZLEN) {
28215                 skb = skb_padto(skb, ETH_ZLEN);
28216                 if (skb == NULL)
28217                         goto out;
28218         }
28219 +
28220 +       /* We will need this to flush the buffer out */
28221 +       lp->tx_ring[lp->tx_ring_head].skb = skb;
28222 +          
28223         np->length = (skb->len < ETH_ZLEN) ? ETH_ZLEN : skb->len; 
28224                         
28225         np->data        = isa_virt_to_bus(skb->data);
28226 @@ -1655,86 +1656,30 @@
28227         do_mc32_set_multicast_list(dev,1);
28228  }
28229  
28230 -/**
28231 - * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
28232 - * @dev: network interface on which out-of-band action is to be performed
28233 - * @useraddr: userspace address to which data is to be read and returned
28234 - *
28235 - * Process the various commands of the SIOCETHTOOL interface.
28236 - */
28237 -
28238 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
28239 +static void netdev_get_drvinfo(struct net_device *dev,
28240 +                              struct ethtool_drvinfo *info)
28241  {
28242 -       u32 ethcmd;
28243 -
28244 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
28245 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
28246 -
28247 -       if (get_user(ethcmd, (u32 *)useraddr))
28248 -               return -EFAULT;
28249 -
28250 -       switch (ethcmd) {
28251 -
28252 -       case ETHTOOL_GDRVINFO: {
28253 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
28254 -               strcpy (info.driver, DRV_NAME);
28255 -               strcpy (info.version, DRV_VERSION);
28256 -               sprintf(info.bus_info, "MCA 0x%lx", dev->base_addr);
28257 -               if (copy_to_user (useraddr, &info, sizeof (info)))
28258 -                       return -EFAULT;
28259 -               return 0;
28260 -       }
28261 -
28262 -       /* get message-level */
28263 -       case ETHTOOL_GMSGLVL: {
28264 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
28265 -               edata.data = mc32_debug;
28266 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
28267 -                       return -EFAULT;
28268 -               return 0;
28269 -       }
28270 -       /* set message-level */
28271 -       case ETHTOOL_SMSGLVL: {
28272 -               struct ethtool_value edata;
28273 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
28274 -                       return -EFAULT;
28275 -               mc32_debug = edata.data;
28276 -               return 0;
28277 -       }
28278 -
28279 -       default:
28280 -               break;
28281 -       }
28282 -
28283 -       return -EOPNOTSUPP;
28284 +       strcpy(info->driver, DRV_NAME);
28285 +       strcpy(info->version, DRV_VERSION);
28286 +       sprintf(info->bus_info, "MCA 0x%lx", dev->base_addr);
28287  }
28288  
28289 -/**
28290 - * netdev_ioctl: Handle network interface ioctls
28291 - * @dev: network interface on which out-of-band action is to be performed
28292 - * @rq: user request data
28293 - * @cmd: command issued by user
28294 - *
28295 - * Process the various out-of-band ioctls passed to this driver.
28296 - */
28297 +static u32 netdev_get_msglevel(struct net_device *dev)
28298 +{
28299 +       return mc32_debug;
28300 +}
28301  
28302 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
28303 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
28304  {
28305 -       int rc = 0;
28306 +       mc32_debug = level;
28307 +}
28308  
28309 -       switch (cmd) {
28310 -       case SIOCETHTOOL:
28311 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
28312 -               break;
28313 +static struct ethtool_ops netdev_ethtool_ops = {
28314 +       .get_drvinfo            = netdev_get_drvinfo,
28315 +       .get_msglevel           = netdev_get_msglevel,
28316 +       .set_msglevel           = netdev_set_msglevel,
28317 +};
28318  
28319 -       default:
28320 -               rc = -EOPNOTSUPP;
28321 -               break;
28322 -       }
28323 -
28324 -       return rc;
28325 -}
28326
28327  #ifdef MODULE
28328  
28329  static struct net_device this_device;
28330 diff -Nru a/drivers/net/3c59x.c b/drivers/net/3c59x.c
28331 --- a/drivers/net/3c59x.c       Tue Aug 19 20:53:15 2003
28332 +++ b/drivers/net/3c59x.c       Tue Aug 26 11:23:22 2003
28333 @@ -900,6 +900,7 @@
28334  static int vortex_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
28335  static void vortex_tx_timeout(struct net_device *dev);
28336  static void acpi_set_WOL(struct net_device *dev);
28337 +static struct ethtool_ops vortex_ethtool_ops;
28338  \f
28339  /* This driver uses 'options' to pass the media type, full-duplex flag, etc. */
28340  /* Option count limit only -- unlimited interfaces are supported. */
28341 @@ -1445,6 +1446,7 @@
28342         dev->stop = vortex_close;
28343         dev->get_stats = vortex_get_stats;
28344         dev->do_ioctl = vortex_ioctl;
28345 +       dev->ethtool_ops = &vortex_ethtool_ops;
28346         dev->set_multicast_list = set_rx_mode;
28347         dev->tx_timeout = vortex_tx_timeout;
28348         dev->watchdog_timeo = (watchdog * HZ) / 1000;
28349 @@ -2816,38 +2818,28 @@
28350  }
28351  
28352  
28353 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
28354 +static void vortex_get_drvinfo(struct net_device *dev,
28355 +                                       struct ethtool_drvinfo *info)
28356  {
28357         struct vortex_private *vp = dev->priv;
28358 -       u32 ethcmd;
28359 -               
28360 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
28361 -               return -EFAULT;
28362  
28363 -        switch (ethcmd) {
28364 -        case ETHTOOL_GDRVINFO: {
28365 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
28366 -               strcpy(info.driver, DRV_NAME);
28367 -               strcpy(info.version, DRV_VERSION);
28368 -               if (VORTEX_PCI(vp))
28369 -                       strcpy(info.bus_info, pci_name(VORTEX_PCI(vp)));
28370 -               else {
28371 -                       if (VORTEX_EISA(vp))
28372 -                               sprintf (info.bus_info, vp->gendev->bus_id);
28373 -                       else
28374 -                               sprintf(info.bus_info, "EISA 0x%lx %d",
28375 -                                               dev->base_addr, dev->irq);
28376 -               }
28377 -               if (copy_to_user(useraddr, &info, sizeof(info)))
28378 -                       return -EFAULT;
28379 -               return 0;
28380 +       strcpy(info->driver, DRV_NAME);
28381 +       strcpy(info->version, DRV_VERSION);
28382 +       if (VORTEX_PCI(vp)) {
28383 +               strcpy(info->bus_info, pci_name(VORTEX_PCI(vp)));
28384 +       } else {
28385 +               if (VORTEX_EISA(vp))
28386 +                       sprintf(info->bus_info, vp->gendev->bus_id);
28387 +               else
28388 +                       sprintf(info->bus_info, "EISA 0x%lx %d",
28389 +                                       dev->base_addr, dev->irq);
28390         }
28391 -
28392 -        }
28393 -       
28394 -       return -EOPNOTSUPP;
28395  }
28396  
28397 +static struct ethtool_ops vortex_ethtool_ops = {
28398 +       .get_drvinfo =          vortex_get_drvinfo,
28399 +};
28400 +
28401  static int vortex_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
28402  {
28403         struct vortex_private *vp = (struct vortex_private *)dev->priv;
28404 @@ -2857,9 +2849,6 @@
28405         int retval;
28406  
28407         switch(cmd) {
28408 -       case SIOCETHTOOL:
28409 -               return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
28410 -
28411         case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
28412                 data->phy_id = phy;
28413  
28414 diff -Nru a/drivers/net/8139cp.c b/drivers/net/8139cp.c
28415 --- a/drivers/net/8139cp.c      Tue Aug 19 20:13:55 2003
28416 +++ b/drivers/net/8139cp.c      Mon Sep  1 17:25:54 2003
28417 @@ -24,15 +24,13 @@
28418                 PCI suspend/resume  - Felipe Damasio <felipewd@terra.com.br>
28419                 LinkChg interrupt   - Felipe Damasio <felipewd@terra.com.br>
28420                         
28421 -       TODO, in rough priority order:
28422 +       TODO:
28423         * Test Tx checksumming thoroughly
28424 -       * dev->tx_timeout
28425 -       * Constants (module parms?) for Rx work limit
28426 +       * Implement dev->tx_timeout
28427 +
28428 +       Low priority TODO:
28429         * Complete reset on PciErr
28430         * Consider Rx interrupt mitigation using TimerIntr
28431 -       * Implement 8139C+ statistics dump; maybe not...
28432 -         h/w stats can be reset only by software reset
28433 -       * Handle netif_rx return value
28434         * Investigate using skb->priority with h/w VLAN priority
28435         * Investigate using High Priority Tx Queue with skb->priority
28436         * Adjust Rx FIFO threshold and Max Rx DMA burst on Rx FIFO error
28437 @@ -41,14 +39,17 @@
28438           Tx descriptor bit
28439         * The real minimum of CP_MIN_MTU is 4 bytes.  However,
28440           for this to be supported, one must(?) turn on packet padding.
28441 -       * Support 8169 GMII
28442 -       * Support external MII transceivers
28443 +       * Support external MII transceivers (patch available)
28444 +
28445 +       NOTES:
28446 +       * TX checksumming is considered experimental.  It is off by
28447 +         default, use ethtool to turn it on.
28448  
28449   */
28450  
28451  #define DRV_NAME               "8139cp"
28452 -#define DRV_VERSION            "0.3.0"
28453 -#define DRV_RELDATE            "Sep 29, 2002"
28454 +#define DRV_VERSION            "1.1"
28455 +#define DRV_RELDATE            "Aug 30, 2003"
28456  
28457  
28458  #include <linux/config.h>
28459 @@ -71,9 +72,6 @@
28460  #include <asm/io.h>
28461  #include <asm/uaccess.h>
28462  
28463 -/* experimental TX checksumming feature enable/disable */
28464 -#undef CP_TX_CHECKSUM
28465 -
28466  /* VLAN tagging feature enable/disable */
28467  #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
28468  #define CP_VLAN_TAG_USED 1
28469 @@ -86,7 +84,7 @@
28470  #endif
28471  
28472  /* These identify the driver base version and may not be removed. */
28473 -static char version[] __devinitdata =
28474 +static char version[] =
28475  KERN_INFO DRV_NAME ": 10/100 PCI Ethernet driver v" DRV_VERSION " (" DRV_RELDATE ")\n";
28476  
28477  MODULE_AUTHOR("Jeff Garzik <jgarzik@pobox.com>");
28478 @@ -160,6 +158,7 @@
28479         TxConfig        = 0x40, /* Tx configuration */
28480         ChipVersion     = 0x43, /* 8-bit chip version, inside TxConfig */
28481         RxConfig        = 0x44, /* Rx configuration */
28482 +       RxMissed        = 0x4C, /* 24 bits valid, write clears */
28483         Cfg9346         = 0x50, /* EEPROM select/control; Cfg reg [un]lock */
28484         Config1         = 0x52, /* Config1 */
28485         Config3         = 0x59, /* Config3 */
28486 @@ -292,12 +291,11 @@
28487         UWF             = (1 << 4),  /* Accept Unicast wakeup frame */
28488         LANWake         = (1 << 1),  /* Enable LANWake signal */
28489         PMEStatus       = (1 << 0),  /* PME status can be reset by PCI RST# */
28490 -};
28491  
28492 -static const unsigned int cp_intr_mask =
28493 -       PciErr | LinkChg |
28494 -       RxOK | RxErr | RxEmpty | RxFIFOOvr |
28495 -       TxOK | TxErr | TxEmpty;
28496 +       cp_norx_intr_mask = PciErr | LinkChg | TxOK | TxErr | TxEmpty,
28497 +       cp_rx_intr_mask = RxOK | RxErr | RxEmpty | RxFIFOOvr,
28498 +       cp_intr_mask = cp_rx_intr_mask | cp_norx_intr_mask,
28499 +};
28500  
28501  static const unsigned int cp_rx_config =
28502           (RX_FIFO_THRESH << RxCfgFIFOShift) |
28503 @@ -364,11 +362,7 @@
28504  
28505         struct pci_dev          *pdev;
28506         u32                     rx_config;
28507 -
28508 -       struct sk_buff          *frag_skb;
28509 -       unsigned                dropping_frag : 1;
28510 -       unsigned                pci_using_dac : 1;
28511 -       unsigned int            board_type;
28512 +       u16                     cpcmd;
28513  
28514         unsigned int            wol_enabled : 1; /* Is Wake-on-LAN enabled? */
28515         u32                     power_state[16];
28516 @@ -400,28 +394,9 @@
28517  static void cp_tx (struct cp_private *cp);
28518  static void cp_clean_rings (struct cp_private *cp);
28519  
28520 -enum board_type {
28521 -       RTL8139Cp,
28522 -       RTL8169,
28523 -};
28524 -
28525 -static struct cp_board_info {
28526 -       const char *name;
28527 -} cp_board_tbl[] __devinitdata = {
28528 -       /* RTL8139Cp */
28529 -       { "RTL-8139C+" },
28530 -
28531 -       /* RTL8169 */
28532 -       { "RTL-8169" },
28533 -};
28534 -
28535  static struct pci_device_id cp_pci_tbl[] = {
28536         { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139,
28537 -         PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139Cp },
28538 -#if 0
28539 -       { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8169,
28540 -         PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8169 },
28541 -#endif
28542 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
28543         { },
28544  };
28545  MODULE_DEVICE_TABLE(pci, cp_pci_tbl);
28546 @@ -446,6 +421,31 @@
28547  };
28548  
28549  
28550 +#if CP_VLAN_TAG_USED
28551 +static void cp_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
28552 +{
28553 +       struct cp_private *cp = dev->priv;
28554 +
28555 +       spin_lock_irq(&cp->lock);
28556 +       cp->vlgrp = grp;
28557 +       cp->cpcmd |= RxVlanOn;
28558 +       cpw16(CpCmd, cp->cpcmd);
28559 +       spin_unlock_irq(&cp->lock);
28560 +}
28561 +
28562 +static void cp_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
28563 +{
28564 +       struct cp_private *cp = dev->priv;
28565 +
28566 +       spin_lock_irq(&cp->lock);
28567 +       cp->cpcmd &= ~RxVlanOn;
28568 +       cpw16(CpCmd, cp->cpcmd);
28569 +       if (cp->vlgrp)
28570 +               cp->vlgrp->vlan_devices[vid] = NULL;
28571 +       spin_unlock_irq(&cp->lock);
28572 +}
28573 +#endif /* CP_VLAN_TAG_USED */
28574 +
28575  static inline void cp_set_rxbufsize (struct cp_private *cp)
28576  {
28577         unsigned int mtu = cp->dev->mtu;
28578 @@ -468,10 +468,11 @@
28579  
28580  #if CP_VLAN_TAG_USED
28581         if (cp->vlgrp && (desc->opts2 & RxVlanTagged)) {
28582 -               vlan_hwaccel_rx(skb, cp->vlgrp, be16_to_cpu(desc->opts2 & 0xffff));
28583 +               vlan_hwaccel_receive_skb(skb, cp->vlgrp,
28584 +                                        be16_to_cpu(desc->opts2 & 0xffff));
28585         } else
28586  #endif
28587 -               netif_rx(skb);
28588 +               netif_receive_skb(skb);
28589  }
28590  
28591  static void cp_rx_err_acct (struct cp_private *cp, unsigned rx_tail,
28592 @@ -486,81 +487,14 @@
28593                 cp->net_stats.rx_frame_errors++;
28594         if (status & RxErrCRC)
28595                 cp->net_stats.rx_crc_errors++;
28596 -       if (status & RxErrRunt)
28597 +       if ((status & RxErrRunt) || (status & RxErrLong))
28598                 cp->net_stats.rx_length_errors++;
28599 -       if (status & RxErrLong)
28600 +       if ((status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag))
28601                 cp->net_stats.rx_length_errors++;
28602         if (status & RxErrFIFO)
28603                 cp->net_stats.rx_fifo_errors++;
28604  }
28605  
28606 -static void cp_rx_frag (struct cp_private *cp, unsigned rx_tail,
28607 -                       struct sk_buff *skb, u32 status, u32 len)
28608 -{
28609 -       struct sk_buff *copy_skb, *frag_skb = cp->frag_skb;
28610 -       unsigned orig_len = frag_skb ? frag_skb->len : 0;
28611 -       unsigned target_len = orig_len + len;
28612 -       unsigned first_frag = status & FirstFrag;
28613 -       unsigned last_frag = status & LastFrag;
28614 -
28615 -       if (netif_msg_rx_status (cp))
28616 -               printk (KERN_DEBUG "%s: rx %s%sfrag, slot %d status 0x%x len %d\n",
28617 -                       cp->dev->name,
28618 -                       cp->dropping_frag ? "dropping " : "",
28619 -                       first_frag ? "first " :
28620 -                       last_frag ? "last " : "",
28621 -                       rx_tail, status, len);
28622 -
28623 -       cp->cp_stats.rx_frags++;
28624 -
28625 -       if (!frag_skb && !first_frag)
28626 -               cp->dropping_frag = 1;
28627 -       if (cp->dropping_frag)
28628 -               goto drop_frag;
28629 -
28630 -       copy_skb = dev_alloc_skb (target_len + RX_OFFSET);
28631 -       if (!copy_skb) {
28632 -               printk(KERN_WARNING "%s: rx slot %d alloc failed\n",
28633 -                      cp->dev->name, rx_tail);
28634 -
28635 -               cp->dropping_frag = 1;
28636 -drop_frag:
28637 -               if (frag_skb) {
28638 -                       dev_kfree_skb_irq(frag_skb);
28639 -                       cp->frag_skb = NULL;
28640 -               }
28641 -               if (last_frag) {
28642 -                       cp->net_stats.rx_dropped++;
28643 -                       cp->dropping_frag = 0;
28644 -               }
28645 -               return;
28646 -       }
28647 -
28648 -       copy_skb->dev = cp->dev;
28649 -       skb_reserve(copy_skb, RX_OFFSET);
28650 -       skb_put(copy_skb, target_len);
28651 -       if (frag_skb) {
28652 -               memcpy(copy_skb->data, frag_skb->data, orig_len);
28653 -               dev_kfree_skb_irq(frag_skb);
28654 -       }
28655 -       pci_dma_sync_single(cp->pdev, cp->rx_skb[rx_tail].mapping,
28656 -                           len, PCI_DMA_FROMDEVICE);
28657 -       memcpy(copy_skb->data + orig_len, skb->data, len);
28658 -
28659 -       copy_skb->ip_summed = CHECKSUM_NONE;
28660 -
28661 -       if (last_frag) {
28662 -               if (status & (RxError | RxErrFIFO)) {
28663 -                       cp_rx_err_acct(cp, rx_tail, status, len);
28664 -                       dev_kfree_skb_irq(copy_skb);
28665 -               } else
28666 -                       cp_rx_skb(cp, copy_skb, &cp->rx_ring[rx_tail]);
28667 -               cp->frag_skb = NULL;
28668 -       } else {
28669 -               cp->frag_skb = copy_skb;
28670 -       }
28671 -}
28672 -
28673  static inline unsigned int cp_rx_csum_ok (u32 status)
28674  {
28675         unsigned int protocol = (status >> 16) & 0x3;
28676 @@ -574,12 +508,18 @@
28677         return 0;
28678  }
28679  
28680 -static void cp_rx (struct cp_private *cp)
28681 +static int cp_rx_poll (struct net_device *dev, int *budget)
28682  {
28683 +       struct cp_private *cp = dev->priv;
28684         unsigned rx_tail = cp->rx_tail;
28685 -       unsigned rx_work = 100;
28686 +       unsigned rx_work = dev->quota;
28687 +       unsigned rx;
28688 +
28689 +rx_status_loop:
28690 +       rx = 0;
28691 +       cpw16(IntrStatus, cp_rx_intr_mask);
28692  
28693 -       while (rx_work--) {
28694 +       while (1) {
28695                 u32 status, len;
28696                 dma_addr_t mapping;
28697                 struct sk_buff *skb, *new_skb;
28698 @@ -599,7 +539,14 @@
28699                 mapping = cp->rx_skb[rx_tail].mapping;
28700  
28701                 if ((status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag)) {
28702 -                       cp_rx_frag(cp, rx_tail, skb, status, len);
28703 +                       /* we don't support incoming fragmented frames.
28704 +                        * instead, we attempt to ensure that the
28705 +                        * pre-allocated RX skbs are properly sized such
28706 +                        * that RX fragments are never encountered
28707 +                        */
28708 +                       cp_rx_err_acct(cp, rx_tail, status, len);
28709 +                       cp->net_stats.rx_dropped++;
28710 +                       cp->cp_stats.rx_frags++;
28711                         goto rx_next;
28712                 }
28713  
28714 @@ -640,6 +587,7 @@
28715                 cp->rx_skb[rx_tail].skb = new_skb;
28716  
28717                 cp_rx_skb(cp, skb, desc);
28718 +               rx++;
28719  
28720  rx_next:
28721                 cp->rx_ring[rx_tail].opts2 = 0;
28722 @@ -650,12 +598,30 @@
28723                 else
28724                         desc->opts1 = cpu_to_le32(DescOwn | cp->rx_buf_sz);
28725                 rx_tail = NEXT_RX(rx_tail);
28726 -       }
28727  
28728 -       if (!rx_work)
28729 -               printk(KERN_WARNING "%s: rx work limit reached\n", cp->dev->name);
28730 +               if (!rx_work--)
28731 +                       break;
28732 +       }
28733  
28734         cp->rx_tail = rx_tail;
28735 +
28736 +       dev->quota -= rx;
28737 +       *budget -= rx;
28738 +
28739 +       /* if we did not reach work limit, then we're done with
28740 +        * this round of polling
28741 +        */
28742 +       if (rx_work) {
28743 +               if (cpr16(IntrStatus) & cp_rx_intr_mask)
28744 +                       goto rx_status_loop;
28745 +
28746 +               cpw16_f(IntrMask, cp_intr_mask);
28747 +               netif_rx_complete(dev);
28748 +
28749 +               return 0;       /* done */
28750 +       }
28751 +
28752 +       return 1;               /* not done */
28753  }
28754  
28755  static irqreturn_t
28756 @@ -673,12 +639,16 @@
28757                 printk(KERN_DEBUG "%s: intr, status %04x cmd %02x cpcmd %04x\n",
28758                         dev->name, status, cpr8(Cmd), cpr16(CpCmd));
28759  
28760 -       cpw16_f(IntrStatus, status);
28761 +       cpw16(IntrStatus, status & ~cp_rx_intr_mask);
28762  
28763         spin_lock(&cp->lock);
28764  
28765 -       if (status & (RxOK | RxErr | RxEmpty | RxFIFOOvr))
28766 -               cp_rx(cp);
28767 +       if (status & (RxOK | RxErr | RxEmpty | RxFIFOOvr)) {
28768 +               if (netif_rx_schedule_prep(dev)) {
28769 +                       cpw16_f(IntrMask, cp_norx_intr_mask);
28770 +                       __netif_rx_schedule(dev);
28771 +               }
28772 +       }
28773         if (status & (TxOK | TxErr | TxEmpty | SWInt))
28774                 cp_tx(cp);
28775         if (status & LinkChg)
28776 @@ -691,6 +661,8 @@
28777                 pci_write_config_word(cp->pdev, PCI_STATUS, pci_status);
28778                 printk(KERN_ERR "%s: PCI bus error, status=%04x, PCI status=%04x\n",
28779                        dev->name, status, pci_status);
28780 +
28781 +               /* TODO: reset hardware */
28782         }
28783  
28784         spin_unlock(&cp->lock);
28785 @@ -750,7 +722,7 @@
28786  
28787         cp->tx_tail = tx_tail;
28788  
28789 -       if (netif_queue_stopped(cp->dev) && (TX_BUFFS_AVAIL(cp) > (MAX_SKB_FRAGS + 1)))
28790 +       if (TX_BUFFS_AVAIL(cp) > (MAX_SKB_FRAGS + 1))
28791                 netif_wake_queue(cp->dev);
28792  }
28793  
28794 @@ -792,7 +764,6 @@
28795                 txd->addr = cpu_to_le64(mapping);
28796                 wmb();
28797  
28798 -#ifdef CP_TX_CHECKSUM
28799                 if (skb->ip_summed == CHECKSUM_HW) {
28800                         const struct iphdr *ip = skb->nh.iph;
28801                         if (ip->protocol == IPPROTO_TCP)
28802 @@ -806,7 +777,6 @@
28803                         else
28804                                 BUG();
28805                 } else
28806 -#endif
28807                         txd->opts1 = cpu_to_le32(eor | len | DescOwn |
28808                                                  FirstFrag | LastFrag);
28809                 wmb();
28810 @@ -820,9 +790,7 @@
28811                 u32 first_len, first_eor;
28812                 dma_addr_t first_mapping;
28813                 int frag, first_entry = entry;
28814 -#ifdef CP_TX_CHECKSUM
28815                 const struct iphdr *ip = skb->nh.iph;
28816 -#endif
28817  
28818                 /* We must give this initial chunk to the device last.
28819                  * Otherwise we could race with the device.
28820 @@ -848,7 +816,7 @@
28821                                                   this_frag->page_offset),
28822                                                  len, PCI_DMA_TODEVICE);
28823                         eor = (entry == (CP_TX_RING_SIZE - 1)) ? RingEnd : 0;
28824 -#ifdef CP_TX_CHECKSUM
28825 +
28826                         if (skb->ip_summed == CHECKSUM_HW) {
28827                                 ctrl = eor | len | DescOwn | IPCS;
28828                                 if (ip->protocol == IPPROTO_TCP)
28829 @@ -858,7 +826,6 @@
28830                                 else
28831                                         BUG();
28832                         } else
28833 -#endif
28834                                 ctrl = eor | len | DescOwn;
28835  
28836                         if (frag == skb_shinfo(skb)->nr_frags - 1)
28837 @@ -883,7 +850,6 @@
28838                 txd->addr = cpu_to_le64(first_mapping);
28839                 wmb();
28840  
28841 -#ifdef CP_TX_CHECKSUM
28842                 if (skb->ip_summed == CHECKSUM_HW) {
28843                         if (ip->protocol == IPPROTO_TCP)
28844                                 txd->opts1 = cpu_to_le32(first_eor | first_len |
28845 @@ -896,7 +862,6 @@
28846                         else
28847                                 BUG();
28848                 } else
28849 -#endif
28850                         txd->opts1 = cpu_to_le32(first_eor | first_len |
28851                                                  FirstFrag | DescOwn);
28852                 wmb();
28853 @@ -975,7 +940,9 @@
28854  
28855  static void __cp_get_stats(struct cp_private *cp)
28856  {
28857 -       /* XXX implement */
28858 +       /* only lower 24 bits valid; write any value to clear */
28859 +       cp->net_stats.rx_missed_errors += (cpr32 (RxMissed) & 0xffffff);
28860 +       cpw32 (RxMissed, 0);
28861  }
28862  
28863  static struct net_device_stats *cp_get_stats(struct net_device *dev)
28864 @@ -995,11 +962,10 @@
28865  {
28866         struct net_device *dev = cp->dev;
28867  
28868 -       cpw16(IntrMask, 0);
28869 -       cpr16(IntrMask);
28870 +       cpw16(IntrStatus, ~(cpr16(IntrStatus)));
28871 +       cpw16_f(IntrMask, 0);
28872         cpw8(Cmd, 0);
28873 -       cpw16(CpCmd, 0);
28874 -       cpr16(CpCmd);
28875 +       cpw16_f(CpCmd, 0);
28876         cpw16(IntrStatus, ~(cpr16(IntrStatus)));
28877         synchronize_irq(dev->irq);
28878         udelay(10);
28879 @@ -1031,11 +997,7 @@
28880  
28881  static inline void cp_start_hw (struct cp_private *cp)
28882  {
28883 -       u16 pci_dac = cp->pci_using_dac ? PCIDAC : 0;
28884 -       if (cp->board_type == RTL8169)
28885 -               cpw16(CpCmd, pci_dac | PCIMulRW | RxChkSum);
28886 -       else
28887 -               cpw16(CpCmd, pci_dac | PCIMulRW | RxChkSum | CpRxOn | CpTxOn);
28888 +       cpw16(CpCmd, cp->cpcmd);
28889         cpw8(Cmd, RxOn | TxOn);
28890  }
28891  
28892 @@ -1059,13 +1021,10 @@
28893  
28894         cpw8(Config1, cpr8(Config1) | DriverLoaded | PMEnable);
28895         /* Disable Wake-on-LAN. Can be turned on with ETHTOOL_SWOL */
28896 -       if (cp->board_type == RTL8139Cp) {
28897 -               cpw8(Config3, PARMEnable);
28898 -               cp->wol_enabled = 0;
28899 -       }
28900 +       cpw8(Config3, PARMEnable);
28901 +       cp->wol_enabled = 0;
28902 +
28903         cpw8(Config5, cpr8(Config5) & PMEStatus); 
28904 -       if (cp->board_type == RTL8169)
28905 -               cpw16(RxMaxSize, cp->rx_buf_sz);
28906  
28907         cpw32_f(HiTxRingAddr, 0);
28908         cpw32_f(HiTxRingAddr + 4, 0);
28909 @@ -1258,8 +1217,6 @@
28910  
28911         dev->mtu = new_mtu;
28912         cp_set_rxbufsize(cp);           /* set new rx buf size */
28913 -       if (cp->board_type == RTL8169)
28914 -               cpw16(RxMaxSize, cp->rx_buf_sz);
28915  
28916         rc = cp_init_rings(cp);         /* realloc and restart h/w */
28917         cp_start_hw(cp);
28918 @@ -1304,8 +1261,8 @@
28919  }
28920  
28921  /* Set the ethtool Wake-on-LAN settings */
28922 -static void netdev_set_wol (struct cp_private *cp,
28923 -                     const struct ethtool_wolinfo *wol)
28924 +static int netdev_set_wol (struct cp_private *cp,
28925 +                          const struct ethtool_wolinfo *wol)
28926  {
28927         u8 options;
28928  
28929 @@ -1332,6 +1289,8 @@
28930         cpw8 (Config5, options);
28931  
28932         cp->wol_enabled = (wol->wolopts) ? 1 : 0;
28933 +
28934 +       return 0;
28935  }
28936  
28937  /* Get the ethtool Wake-on-LAN settings */
28938 @@ -1357,308 +1316,205 @@
28939         if (options & MWF)           wol->wolopts |= WAKE_MCAST;
28940  }
28941  
28942 -static int cp_ethtool_ioctl (struct cp_private *cp, void *useraddr)
28943 +static void cp_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
28944  {
28945 -       u32 ethcmd;
28946 +       struct cp_private *cp = dev->priv;
28947  
28948 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
28949 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
28950 +       strcpy (info->driver, DRV_NAME);
28951 +       strcpy (info->version, DRV_VERSION);
28952 +       strcpy (info->bus_info, pci_name(cp->pdev));
28953 +}
28954  
28955 -       if (get_user(ethcmd, (u32 *)useraddr))
28956 -               return -EFAULT;
28957 -
28958 -       switch (ethcmd) {
28959 -
28960 -       case ETHTOOL_GDRVINFO: {
28961 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
28962 -               strcpy (info.driver, DRV_NAME);
28963 -               strcpy (info.version, DRV_VERSION);
28964 -               strcpy (info.bus_info, pci_name(cp->pdev));
28965 -               info.regdump_len = CP_REGS_SIZE;
28966 -               info.n_stats = CP_NUM_STATS;
28967 -               if (copy_to_user (useraddr, &info, sizeof (info)))
28968 -                       return -EFAULT;
28969 -               return 0;
28970 -       }
28971 +static int cp_get_regs_len(struct net_device *dev)
28972 +{
28973 +       return CP_REGS_SIZE;
28974 +}
28975  
28976 -       /* get settings */
28977 -       case ETHTOOL_GSET: {
28978 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
28979 -               spin_lock_irq(&cp->lock);
28980 -               mii_ethtool_gset(&cp->mii_if, &ecmd);
28981 -               spin_unlock_irq(&cp->lock);
28982 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
28983 -                       return -EFAULT;
28984 -               return 0;
28985 -       }
28986 -       /* set settings */
28987 -       case ETHTOOL_SSET: {
28988 -               int r;
28989 -               struct ethtool_cmd ecmd;
28990 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
28991 -                       return -EFAULT;
28992 -               spin_lock_irq(&cp->lock);
28993 -               r = mii_ethtool_sset(&cp->mii_if, &ecmd);
28994 -               spin_unlock_irq(&cp->lock);
28995 -               return r;
28996 -       }
28997 -       /* restart autonegotiation */
28998 -       case ETHTOOL_NWAY_RST: {
28999 -               return mii_nway_restart(&cp->mii_if);
29000 -       }
29001 -       /* get link status */
29002 -       case ETHTOOL_GLINK: {
29003 -               struct ethtool_value edata = {ETHTOOL_GLINK};
29004 -               edata.data = mii_link_ok(&cp->mii_if);
29005 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
29006 -                       return -EFAULT;
29007 -               return 0;
29008 -       }
29009 +static int cp_get_stats_count (struct net_device *dev)
29010 +{
29011 +       return CP_NUM_STATS;
29012 +}
29013  
29014 -       /* get message-level */
29015 -       case ETHTOOL_GMSGLVL: {
29016 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
29017 -               edata.data = cp->msg_enable;
29018 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
29019 -                       return -EFAULT;
29020 -               return 0;
29021 -       }
29022 -       /* set message-level */
29023 -       case ETHTOOL_SMSGLVL: {
29024 -               struct ethtool_value edata;
29025 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
29026 -                       return -EFAULT;
29027 -               cp->msg_enable = edata.data;
29028 -               return 0;
29029 -       }
29030 +static int cp_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
29031 +{
29032 +       struct cp_private *cp = dev->priv;
29033 +       int rc;
29034  
29035 -       /* NIC register dump */
29036 -       case ETHTOOL_GREGS: {
29037 -                struct ethtool_regs regs;
29038 -                u8 *regbuf = kmalloc(CP_REGS_SIZE, GFP_KERNEL);
29039 -                int rc;
29040 -
29041 -               if (!regbuf)
29042 -                       return -ENOMEM;
29043 -               memset(regbuf, 0, CP_REGS_SIZE);
29044 +       spin_lock_irq(&cp->lock);
29045 +       rc = mii_ethtool_gset(&cp->mii_if, cmd);
29046 +       spin_unlock_irq(&cp->lock);
29047  
29048 -                rc = copy_from_user(&regs, useraddr, sizeof(regs));
29049 -               if (rc) {
29050 -                       rc = -EFAULT;
29051 -                       goto err_out_gregs;
29052 -               }
29053 -                
29054 -                if (regs.len > CP_REGS_SIZE)
29055 -                        regs.len = CP_REGS_SIZE;
29056 -                if (regs.len < CP_REGS_SIZE) {
29057 -                       rc = -EINVAL;
29058 -                       goto err_out_gregs;
29059 -               }
29060 +       return rc;
29061 +}
29062  
29063 -                regs.version = CP_REGS_VER;
29064 -                rc = copy_to_user(useraddr, &regs, sizeof(regs));
29065 -               if (rc) {
29066 -                       rc = -EFAULT;
29067 -                       goto err_out_gregs;
29068 -               }
29069 +static int cp_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
29070 +{
29071 +       struct cp_private *cp = dev->priv;
29072 +       int rc;
29073  
29074 -                useraddr += offsetof(struct ethtool_regs, data);
29075 +       spin_lock_irq(&cp->lock);
29076 +       rc = mii_ethtool_sset(&cp->mii_if, cmd);
29077 +       spin_unlock_irq(&cp->lock);
29078  
29079 -                spin_lock_irq(&cp->lock);
29080 -                memcpy_fromio(regbuf, cp->regs, CP_REGS_SIZE);
29081 -                spin_unlock_irq(&cp->lock);
29082 +       return rc;
29083 +}
29084  
29085 -                if (copy_to_user(useraddr, regbuf, regs.len))
29086 -                        rc = -EFAULT;
29087 +static int cp_nway_reset(struct net_device *dev)
29088 +{
29089 +       struct cp_private *cp = dev->priv;
29090 +       return mii_nway_restart(&cp->mii_if);
29091 +}
29092  
29093 -err_out_gregs:
29094 -               kfree(regbuf);
29095 -               return rc;
29096 -       }
29097 +static u32 cp_get_msglevel(struct net_device *dev)
29098 +{
29099 +       struct cp_private *cp = dev->priv;
29100 +       return cp->msg_enable;
29101 +}
29102  
29103 -       /* get/set RX checksumming */
29104 -       case ETHTOOL_GRXCSUM: {
29105 -               struct ethtool_value edata = { ETHTOOL_GRXCSUM };
29106 -               u16 cmd = cpr16(CpCmd) & RxChkSum;
29107 -
29108 -               edata.data = cmd ? 1 : 0;
29109 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
29110 -                       return -EFAULT;
29111 -               return 0;
29112 -       }
29113 -       case ETHTOOL_SRXCSUM: {
29114 -               struct ethtool_value edata;
29115 -               u16 cmd = cpr16(CpCmd), newcmd;
29116 +static void cp_set_msglevel(struct net_device *dev, u32 value)
29117 +{
29118 +       struct cp_private *cp = dev->priv;
29119 +       cp->msg_enable = value;
29120 +}
29121  
29122 -               newcmd = cmd;
29123 +static u32 cp_get_rx_csum(struct net_device *dev)
29124 +{
29125 +       struct cp_private *cp = dev->priv;
29126 +       return (cpr16(CpCmd) & RxChkSum) ? 1 : 0;
29127 +}
29128  
29129 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
29130 -                       return -EFAULT;
29131 +static int cp_set_rx_csum(struct net_device *dev, u32 data)
29132 +{
29133 +       struct cp_private *cp = dev->priv;
29134 +       u16 cmd = cp->cpcmd, newcmd;
29135  
29136 -               if (edata.data)
29137 -                       newcmd |= RxChkSum;
29138 -               else
29139 -                       newcmd &= ~RxChkSum;
29140 +       newcmd = cmd;
29141  
29142 -               if (newcmd == cmd)
29143 -                       return 0;
29144 +       if (data)
29145 +               newcmd |= RxChkSum;
29146 +       else
29147 +               newcmd &= ~RxChkSum;
29148  
29149 +       if (newcmd != cmd) {
29150                 spin_lock_irq(&cp->lock);
29151 +               cp->cpcmd = newcmd;
29152                 cpw16_f(CpCmd, newcmd);
29153                 spin_unlock_irq(&cp->lock);
29154         }
29155  
29156 -       /* get/set TX checksumming */
29157 -       case ETHTOOL_GTXCSUM: {
29158 -               struct ethtool_value edata = { ETHTOOL_GTXCSUM };
29159 -
29160 -               edata.data = (cp->dev->features & NETIF_F_IP_CSUM) != 0;
29161 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
29162 -                       return -EFAULT;
29163 -               return 0;
29164 -       }
29165 -       case ETHTOOL_STXCSUM: {
29166 -               struct ethtool_value edata;
29167 -
29168 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
29169 -                       return -EFAULT;
29170 -
29171 -               if (edata.data)
29172 -                       cp->dev->features |= NETIF_F_IP_CSUM;
29173 -               else
29174 -                       cp->dev->features &= ~NETIF_F_IP_CSUM;
29175 -
29176 -               return 0;
29177 -       }
29178 +       return 0;
29179 +}
29180  
29181 -       /* get/set scatter-gather */
29182 -       case ETHTOOL_GSG: {
29183 -               struct ethtool_value edata = { ETHTOOL_GSG };
29184 -
29185 -               edata.data = (cp->dev->features & NETIF_F_SG) != 0;
29186 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
29187 -                       return -EFAULT;
29188 -               return 0;
29189 -       }
29190 -       case ETHTOOL_SSG: {
29191 -               struct ethtool_value edata;
29192 +static void cp_get_regs(struct net_device *dev, struct ethtool_regs *regs,
29193 +                       void *p)
29194 +{
29195 +       struct cp_private *cp = dev->priv;
29196  
29197 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
29198 -                       return -EFAULT;
29199 +       if (regs->len < CP_REGS_SIZE)
29200 +               return /* -EINVAL */;
29201  
29202 -               if (edata.data)
29203 -                       cp->dev->features |= NETIF_F_SG;
29204 -               else
29205 -                       cp->dev->features &= ~NETIF_F_SG;
29206 +       regs->version = CP_REGS_VER;
29207  
29208 -               return 0;
29209 -       }
29210 +       spin_lock_irq(&cp->lock);
29211 +       memcpy_fromio(p, cp->regs, CP_REGS_SIZE);
29212 +       spin_unlock_irq(&cp->lock);
29213 +}
29214  
29215 -       /* get string list(s) */
29216 -       case ETHTOOL_GSTRINGS: {
29217 -               struct ethtool_gstrings estr = { ETHTOOL_GSTRINGS };
29218 -
29219 -               if (copy_from_user(&estr, useraddr, sizeof(estr)))
29220 -                       return -EFAULT;
29221 -               if (estr.string_set != ETH_SS_STATS)
29222 -                       return -EINVAL;
29223 -
29224 -               estr.len = CP_NUM_STATS;
29225 -               if (copy_to_user(useraddr, &estr, sizeof(estr)))
29226 -                       return -EFAULT;
29227 -               if (copy_to_user(useraddr + sizeof(estr),
29228 -                                &ethtool_stats_keys,
29229 -                                sizeof(ethtool_stats_keys)))
29230 -                       return -EFAULT;
29231 -               return 0;
29232 -       }
29233 +static void cp_get_wol (struct net_device *dev, struct ethtool_wolinfo *wol)
29234 +{
29235 +       struct cp_private *cp = dev->priv;
29236  
29237 -       /* get NIC-specific statistics */
29238 -       case ETHTOOL_GSTATS: {
29239 -               struct ethtool_stats estats = { ETHTOOL_GSTATS };
29240 -               u64 *tmp_stats;
29241 -               unsigned int work = 100;
29242 -               const unsigned int sz = sizeof(u64) * CP_NUM_STATS;
29243 -               int i;
29244 -
29245 -               /* begin NIC statistics dump */
29246 -               cpw32(StatsAddr + 4, 0); /* FIXME: 64-bit PCI */
29247 -               cpw32(StatsAddr, cp->nic_stats_dma | DumpStats);
29248 -               cpr32(StatsAddr);
29249 -
29250 -               estats.n_stats = CP_NUM_STATS;
29251 -               if (copy_to_user(useraddr, &estats, sizeof(estats)))
29252 -                       return -EFAULT;
29253 -
29254 -               while (work-- > 0) {
29255 -                       if ((cpr32(StatsAddr) & DumpStats) == 0)
29256 -                               break;
29257 -                       cpu_relax();
29258 -               }
29259 +       spin_lock_irq (&cp->lock);
29260 +       netdev_get_wol (cp, wol);
29261 +       spin_unlock_irq (&cp->lock);
29262 +}
29263  
29264 -               if (cpr32(StatsAddr) & DumpStats)
29265 -                       return -EIO;
29266 +static int cp_set_wol (struct net_device *dev, struct ethtool_wolinfo *wol)
29267 +{
29268 +       struct cp_private *cp = dev->priv;
29269 +       int rc;
29270  
29271 -               tmp_stats = kmalloc(sz, GFP_KERNEL);
29272 -               if (!tmp_stats)
29273 -                       return -ENOMEM;
29274 -               memset(tmp_stats, 0, sz);
29275 -
29276 -               i = 0;
29277 -               tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_ok);
29278 -               tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok);
29279 -               tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_err);
29280 -               tmp_stats[i++] = le32_to_cpu(cp->nic_stats->rx_err);
29281 -               tmp_stats[i++] = le16_to_cpu(cp->nic_stats->rx_fifo);
29282 -               tmp_stats[i++] = le16_to_cpu(cp->nic_stats->frame_align);
29283 -               tmp_stats[i++] = le32_to_cpu(cp->nic_stats->tx_ok_1col);
29284 -               tmp_stats[i++] = le32_to_cpu(cp->nic_stats->tx_ok_mcol);
29285 -               tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok_phys);
29286 -               tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok_bcast);
29287 -               tmp_stats[i++] = le32_to_cpu(cp->nic_stats->rx_ok_mcast);
29288 -               tmp_stats[i++] = le16_to_cpu(cp->nic_stats->tx_abort);
29289 -               tmp_stats[i++] = le16_to_cpu(cp->nic_stats->tx_underrun);
29290 -               tmp_stats[i++] = cp->cp_stats.rx_frags;
29291 -               if (i != CP_NUM_STATS)
29292 -                       BUG();
29293 +       spin_lock_irq (&cp->lock);
29294 +       rc = netdev_set_wol (cp, wol);
29295 +       spin_unlock_irq (&cp->lock);
29296  
29297 -               i = copy_to_user(useraddr + sizeof(estats),
29298 -                                tmp_stats, sz);
29299 -               kfree(tmp_stats);
29300 +       return rc;
29301 +}
29302  
29303 -               if (i)
29304 -                       return -EFAULT;
29305 -               return 0;
29306 +static void cp_get_strings (struct net_device *dev, u32 stringset, u8 *buf)
29307 +{
29308 +       switch (stringset) {
29309 +       case ETH_SS_STATS:
29310 +               memcpy(buf, &ethtool_stats_keys, sizeof(ethtool_stats_keys));
29311 +               break;
29312 +       default:
29313 +               BUG();
29314 +               break;
29315         }
29316 +}
29317  
29318 -       /* get/set Wake-on-LAN settings */
29319 -       case ETHTOOL_GWOL: {
29320 -               struct ethtool_wolinfo wol = { ETHTOOL_GWOL };
29321 -               
29322 -               spin_lock_irq (&cp->lock);
29323 -               netdev_get_wol (cp, &wol);
29324 -               spin_unlock_irq (&cp->lock);
29325 -               return ((copy_to_user (useraddr, &wol, sizeof (wol)))? -EFAULT : 0);
29326 -       }
29327 -       
29328 -       case ETHTOOL_SWOL: {
29329 -               struct ethtool_wolinfo wol;
29330 +static void cp_get_ethtool_stats (struct net_device *dev,
29331 +                                 struct ethtool_stats *estats, u64 *tmp_stats)
29332 +{
29333 +       struct cp_private *cp = dev->priv;
29334 +       unsigned int work = 100;
29335 +       int i;
29336  
29337 -               if (copy_from_user (&wol, useraddr, sizeof (wol)))
29338 -                       return -EFAULT;
29339 -               spin_lock_irq (&cp->lock);
29340 -               netdev_set_wol (cp, &wol);
29341 -               spin_unlock_irq (&cp->lock);
29342 -               return 0;
29343 -       }
29344 +       /* begin NIC statistics dump */
29345 +       cpw32(StatsAddr + 4, 0); /* FIXME: 64-bit PCI */
29346 +       cpw32(StatsAddr, cp->nic_stats_dma | DumpStats);
29347 +       cpr32(StatsAddr);
29348  
29349 -       default:
29350 -               break;
29351 +       while (work-- > 0) {
29352 +               if ((cpr32(StatsAddr) & DumpStats) == 0)
29353 +                       break;
29354 +               cpu_relax();
29355         }
29356  
29357 -       return -EOPNOTSUPP;
29358 +       if (cpr32(StatsAddr) & DumpStats)
29359 +               return /* -EIO */;
29360 +
29361 +       i = 0;
29362 +       tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_ok);
29363 +       tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok);
29364 +       tmp_stats[i++] = le64_to_cpu(cp->nic_stats->tx_err);
29365 +       tmp_stats[i++] = le32_to_cpu(cp->nic_stats->rx_err);
29366 +       tmp_stats[i++] = le16_to_cpu(cp->nic_stats->rx_fifo);
29367 +       tmp_stats[i++] = le16_to_cpu(cp->nic_stats->frame_align);
29368 +       tmp_stats[i++] = le32_to_cpu(cp->nic_stats->tx_ok_1col);
29369 +       tmp_stats[i++] = le32_to_cpu(cp->nic_stats->tx_ok_mcol);
29370 +       tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok_phys);
29371 +       tmp_stats[i++] = le64_to_cpu(cp->nic_stats->rx_ok_bcast);
29372 +       tmp_stats[i++] = le32_to_cpu(cp->nic_stats->rx_ok_mcast);
29373 +       tmp_stats[i++] = le16_to_cpu(cp->nic_stats->tx_abort);
29374 +       tmp_stats[i++] = le16_to_cpu(cp->nic_stats->tx_underrun);
29375 +       tmp_stats[i++] = cp->cp_stats.rx_frags;
29376 +       if (i != CP_NUM_STATS)
29377 +               BUG();
29378  }
29379  
29380 +static struct ethtool_ops cp_ethtool_ops = {
29381 +       .get_drvinfo            = cp_get_drvinfo,
29382 +       .get_regs_len           = cp_get_regs_len,
29383 +       .get_stats_count        = cp_get_stats_count,
29384 +       .get_settings           = cp_get_settings,
29385 +       .set_settings           = cp_set_settings,
29386 +       .nway_reset             = cp_nway_reset,
29387 +       .get_link               = ethtool_op_get_link,
29388 +       .get_msglevel           = cp_get_msglevel,
29389 +       .set_msglevel           = cp_set_msglevel,
29390 +       .get_rx_csum            = cp_get_rx_csum,
29391 +       .set_rx_csum            = cp_set_rx_csum,
29392 +       .get_tx_csum            = ethtool_op_get_tx_csum,
29393 +       .set_tx_csum            = ethtool_op_set_tx_csum, /* local! */
29394 +       .get_sg                 = ethtool_op_get_sg,
29395 +       .set_sg                 = ethtool_op_set_sg,
29396 +       .get_regs               = cp_get_regs,
29397 +       .get_wol                = cp_get_wol,
29398 +       .set_wol                = cp_set_wol,
29399 +       .get_strings            = cp_get_strings,
29400 +       .get_ethtool_stats      = cp_get_ethtool_stats,
29401 +};
29402  
29403  static int cp_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
29404  {
29405 @@ -1669,38 +1525,12 @@
29406         if (!netif_running(dev))
29407                 return -EINVAL;
29408  
29409 -       if (cmd == SIOCETHTOOL)
29410 -               return cp_ethtool_ioctl(cp, (void *) rq->ifr_data);
29411 -
29412         spin_lock_irq(&cp->lock);
29413         rc = generic_mii_ioctl(&cp->mii_if, mii, cmd, NULL);
29414         spin_unlock_irq(&cp->lock);
29415         return rc;
29416  }
29417  
29418 -#if CP_VLAN_TAG_USED
29419 -static void cp_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
29420 -{
29421 -       struct cp_private *cp = dev->priv;
29422 -
29423 -       spin_lock_irq(&cp->lock);
29424 -       cp->vlgrp = grp;
29425 -       cpw16(CpCmd, cpr16(CpCmd) | RxVlanOn);
29426 -       spin_unlock_irq(&cp->lock);
29427 -}
29428 -
29429 -static void cp_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
29430 -{
29431 -       struct cp_private *cp = dev->priv;
29432 -
29433 -       spin_lock_irq(&cp->lock);
29434 -       cpw16(CpCmd, cpr16(CpCmd) & ~RxVlanOn);
29435 -       if (cp->vlgrp)
29436 -               cp->vlgrp->vlan_devices[vid] = NULL;
29437 -       spin_unlock_irq(&cp->lock);
29438 -}
29439 -#endif
29440 -
29441  /* Serial EEPROM section. */
29442  
29443  /*  EEPROM_Ctrl bits. */
29444 @@ -1723,7 +1553,7 @@
29445  #define EE_READ_CMD            (6)
29446  #define EE_ERASE_CMD   (7)
29447  
29448 -static int __devinit read_eeprom (void *ioaddr, int location, int addr_len)
29449 +static int read_eeprom (void *ioaddr, int location, int addr_len)
29450  {
29451         int i;
29452         unsigned retval = 0;
29453 @@ -1769,17 +1599,15 @@
29454         pci_set_power_state (cp->pdev, 3);
29455  }
29456  
29457 -static int __devinit cp_init_one (struct pci_dev *pdev,
29458 -                                 const struct pci_device_id *ent)
29459 +static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
29460  {
29461         struct net_device *dev;
29462         struct cp_private *cp;
29463         int rc;
29464         void *regs;
29465         long pciaddr;
29466 -       unsigned int addr_len, i;
29467 -       u8 pci_rev, cache_size;
29468 -       unsigned int board_type = (unsigned int) ent->driver_data;
29469 +       unsigned int addr_len, i, pci_using_dac;
29470 +       u8 pci_rev;
29471  
29472  #ifndef MODULE
29473         static int version_printed;
29474 @@ -1805,7 +1633,6 @@
29475  
29476         cp = dev->priv;
29477         cp->pdev = pdev;
29478 -       cp->board_type = board_type;
29479         cp->dev = dev;
29480         cp->msg_enable = (debug < 0 ? CP_DEF_MSG_ENABLE : debug);
29481         spin_lock_init (&cp->lock);
29482 @@ -1821,10 +1648,14 @@
29483         if (rc)
29484                 goto err_out_free;
29485  
29486 -       rc = pci_request_regions(pdev, DRV_NAME);
29487 +       rc = pci_set_mwi(pdev);
29488         if (rc)
29489                 goto err_out_disable;
29490  
29491 +       rc = pci_request_regions(pdev, DRV_NAME);
29492 +       if (rc)
29493 +               goto err_out_mwi;
29494 +
29495         if (pdev->irq < 2) {
29496                 rc = -EIO;
29497                 printk(KERN_ERR PFX "invalid irq (%d) for pci dev %s\n",
29498 @@ -1846,18 +1677,22 @@
29499         }
29500  
29501         /* Configure DMA attributes. */
29502 -       if (!pci_set_dma_mask(pdev, (u64) 0xffffffffffffffffULL)) {
29503 -               cp->pci_using_dac = 1;
29504 +       if ((sizeof(dma_addr_t) > 32) &&
29505 +           !pci_set_dma_mask(pdev, 0xffffffffffffffffULL)) {
29506 +               pci_using_dac = 1;
29507         } else {
29508 -               rc = pci_set_dma_mask(pdev, (u64) 0xffffffff);
29509 +               rc = pci_set_dma_mask(pdev, 0xffffffffULL);
29510                 if (rc) {
29511                         printk(KERN_ERR PFX "No usable DMA configuration, "
29512                                "aborting.\n");
29513                         goto err_out_res;
29514                 }
29515 -               cp->pci_using_dac = 0;
29516 +               pci_using_dac = 0;
29517         }
29518  
29519 +       cp->cpcmd = (pci_using_dac ? PCIDAC : 0) |
29520 +                   PCIMulRW | RxChkSum | CpRxOn | CpTxOn;
29521 +
29522         regs = ioremap_nocache(pciaddr, CP_REGS_SIZE);
29523         if (!regs) {
29524                 rc = -EIO;
29525 @@ -1882,16 +1717,17 @@
29526         dev->hard_start_xmit = cp_start_xmit;
29527         dev->get_stats = cp_get_stats;
29528         dev->do_ioctl = cp_ioctl;
29529 +       dev->poll = cp_rx_poll;
29530 +       dev->weight = 16;       /* arbitrary? from NAPI_HOWTO.txt. */
29531  #ifdef BROKEN
29532         dev->change_mtu = cp_change_mtu;
29533  #endif
29534 +       dev->ethtool_ops = &cp_ethtool_ops;
29535  #if 0
29536         dev->tx_timeout = cp_tx_timeout;
29537         dev->watchdog_timeo = TX_TIMEOUT;
29538  #endif
29539 -#ifdef CP_TX_CHECKSUM
29540 -       dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
29541 -#endif
29542 +
29543  #if CP_VLAN_TAG_USED
29544         dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
29545         dev->vlan_rx_register = cp_vlan_rx_register;
29546 @@ -1904,11 +1740,10 @@
29547         if (rc)
29548                 goto err_out_iomap;
29549  
29550 -       printk (KERN_INFO "%s: %s at 0x%lx, "
29551 +       printk (KERN_INFO "%s: RTL-8139C+ at 0x%lx, "
29552                 "%02x:%02x:%02x:%02x:%02x:%02x, "
29553                 "IRQ %d\n",
29554                 dev->name,
29555 -               cp_board_tbl[board_type].name,
29556                 dev->base_addr,
29557                 dev->dev_addr[0], dev->dev_addr[1],
29558                 dev->dev_addr[2], dev->dev_addr[3],
29559 @@ -1917,29 +1752,8 @@
29560  
29561         pci_set_drvdata(pdev, dev);
29562  
29563 -       /*
29564 -        * Looks like this is necessary to deal with on all architectures,
29565 -        * even this %$#%$# N440BX Intel based thing doesn't get it right.
29566 -        * Ie. having two NICs in the machine, one will have the cache
29567 -        * line set at boot time, the other will not.
29568 -        */
29569 -       pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &cache_size);
29570 -       cache_size <<= 2;
29571 -       if (cache_size != SMP_CACHE_BYTES) {
29572 -               printk(KERN_INFO "%s: PCI cache line size set incorrectly "
29573 -                      "(%i bytes) by BIOS/FW, ", dev->name, cache_size);
29574 -               if (cache_size > SMP_CACHE_BYTES)
29575 -                       printk("expecting %i\n", SMP_CACHE_BYTES);
29576 -               else {
29577 -                       printk("correcting to %i\n", SMP_CACHE_BYTES);
29578 -                       pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE,
29579 -                                             SMP_CACHE_BYTES >> 2);
29580 -               }
29581 -       }
29582 -
29583         /* enable busmastering and memory-write-invalidate */
29584         pci_set_master(pdev);
29585 -       pci_set_mwi(pdev);
29586  
29587         if (cp->wol_enabled) cp_set_d3_state (cp);
29588  
29589 @@ -1949,6 +1763,8 @@
29590         iounmap(regs);
29591  err_out_res:
29592         pci_release_regions(pdev);
29593 +err_out_mwi:
29594 +       pci_clear_mwi(pdev);
29595  err_out_disable:
29596         pci_disable_device(pdev);
29597  err_out_free:
29598 @@ -1956,7 +1772,7 @@
29599         return rc;
29600  }
29601  
29602 -static void __devexit cp_remove_one (struct pci_dev *pdev)
29603 +static void cp_remove_one (struct pci_dev *pdev)
29604  {
29605         struct net_device *dev = pci_get_drvdata(pdev);
29606         struct cp_private *cp = dev->priv;
29607 @@ -1967,6 +1783,7 @@
29608         iounmap(cp->regs);
29609         if (cp->wol_enabled) pci_set_power_state (pdev, 0);
29610         pci_release_regions(pdev);
29611 +       pci_clear_mwi(pdev);
29612         pci_disable_device(pdev);
29613         pci_set_drvdata(pdev, NULL);
29614         free_netdev(dev);
29615 @@ -2029,7 +1846,7 @@
29616         .name         = DRV_NAME,
29617         .id_table     = cp_pci_tbl,
29618         .probe        = cp_init_one,
29619 -       .remove       = __devexit_p(cp_remove_one),
29620 +       .remove       = cp_remove_one,
29621  #ifdef CONFIG_PM
29622         .resume       = cp_resume,
29623         .suspend      = cp_suspend,
29624 diff -Nru a/drivers/net/8139too.c b/drivers/net/8139too.c
29625 --- a/drivers/net/8139too.c     Tue Aug 19 20:13:55 2003
29626 +++ b/drivers/net/8139too.c     Sun Aug 31 12:38:16 2003
29627 @@ -123,6 +123,11 @@
29628  #define USE_IO_OPS 1
29629  #endif
29630  
29631 +/* use a 16K rx ring buffer instead of the default 32K */
29632 +#ifdef CONFIG_SH_DREAMCAST
29633 +#define USE_BUF16K 1
29634 +#endif
29635 +
29636  /* define to 1 to enable copious debugging info */
29637  #undef RTL8139_DEBUG
29638  
29639 @@ -165,7 +170,11 @@
29640  static int debug = -1;
29641  
29642  /* Size of the in-memory receive ring. */
29643 +#ifdef USE_BUF16K
29644 +#define RX_BUF_LEN_IDX 1       /* 0==8K, 1==16K, 2==32K, 3==64K */
29645 +#else
29646  #define RX_BUF_LEN_IDX 2       /* 0==8K, 1==16K, 2==32K, 3==64K */
29647 +#endif
29648  #define RX_BUF_LEN     (8192 << RX_BUF_LEN_IDX)
29649  #define RX_BUF_PAD     16
29650  #define RX_BUF_WRAP_PAD 2048 /* spare padding to handle lack of packet wrap */
29651 @@ -212,18 +221,7 @@
29652  
29653  typedef enum {
29654         RTL8139 = 0,
29655 -       RTL8139_CB,
29656 -       SMC1211TX,
29657 -       /*MPX5030,*/
29658 -       DELTA8139,
29659 -       ADDTRON8139,
29660 -       DFE538TX,
29661 -       DFE690TXD,
29662 -       FE2000VX,
29663 -       ALLIED8139,
29664         RTL8129,
29665 -       FNW3603TX,
29666 -       FNW3800TX,
29667  } board_t;
29668  
29669  
29670 @@ -232,36 +230,29 @@
29671         const char *name;
29672         u32 hw_flags;
29673  } board_info[] __devinitdata = {
29674 -       { "RealTek RTL8139 Fast Ethernet", RTL8139_CAPS },
29675 -       { "RealTek RTL8139B PCI/CardBus", RTL8139_CAPS },
29676 -       { "SMC1211TX EZCard 10/100 (RealTek RTL8139)", RTL8139_CAPS },
29677 -/*     { MPX5030, "Accton MPX5030 (RealTek RTL8139)", RTL8139_CAPS },*/
29678 -       { "Delta Electronics 8139 10/100BaseTX", RTL8139_CAPS },
29679 -       { "Addtron Technolgy 8139 10/100BaseTX", RTL8139_CAPS },
29680 -       { "D-Link DFE-538TX (RealTek RTL8139)", RTL8139_CAPS },
29681 -       { "D-Link DFE-690TXD (RealTek RTL8139)", RTL8139_CAPS },
29682 -       { "AboCom FE2000VX (RealTek RTL8139)", RTL8139_CAPS },
29683 -       { "Allied Telesyn 8139 CardBus", RTL8139_CAPS },
29684 +       { "RealTek RTL8139", RTL8139_CAPS },
29685         { "RealTek RTL8129", RTL8129_CAPS },
29686 -       { "Planex FNW-3603-TX 10/100 CardBus", RTL8139_CAPS },
29687 -       { "Planex FNW-3800-TX 10/100 CardBus", RTL8139_CAPS },
29688  };
29689  
29690  
29691  static struct pci_device_id rtl8139_pci_tbl[] = {
29692         {0x10ec, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
29693 -       {0x10ec, 0x8138, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139_CB },
29694 -       {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SMC1211TX },
29695 -/*     {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MPX5030 },*/
29696 -       {0x1500, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DELTA8139 },
29697 -       {0x4033, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ADDTRON8139 },
29698 -       {0x1186, 0x1300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DFE538TX },
29699 -       {0x1186, 0x1340, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DFE690TXD },
29700 -       {0x13d1, 0xab06, PCI_ANY_ID, PCI_ANY_ID, 0, 0, FE2000VX },
29701 -       {0x1259, 0xa117, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ALLIED8139 },
29702 -       {0x14ea, 0xab06, PCI_ANY_ID, PCI_ANY_ID, 0, 0, FNW3603TX },
29703 -       {0x14ea, 0xab07, PCI_ANY_ID, PCI_ANY_ID, 0, 0, FNW3800TX },
29704 -
29705 +       {0x10ec, 0x8138, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
29706 +       {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
29707 +       {0x1500, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
29708 +       {0x4033, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
29709 +       {0x1186, 0x1300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
29710 +       {0x1186, 0x1340, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
29711 +       {0x13d1, 0xab06, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
29712 +       {0x1259, 0xa117, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
29713 +       {0x14ea, 0xab06, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
29714 +       {0x14ea, 0xab07, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
29715 +       {0x11db, 0x1234, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
29716 +
29717 +#ifdef CONFIG_SH_SECUREEDGE5410
29718 +       /* Bogus 8139 silicon reports 8129 without external PROM :-( */
29719 +       {0x10ec, 0x8129, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
29720 +#endif
29721  #ifdef CONFIG_8139TOO_8129
29722         {0x10ec, 0x8129, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8129 },
29723  #endif
29724 @@ -271,8 +262,8 @@
29725          * so we simply don't match on the main vendor id.
29726          */
29727         {PCI_ANY_ID, 0x8139, 0x10ec, 0x8139, 0, 0, RTL8139 },
29728 -       {PCI_ANY_ID, 0x8139, 0x1186, 0x1300, 0, 0, DFE538TX },
29729 -       {PCI_ANY_ID, 0x8139, 0x13d1, 0xab06, 0, 0, FE2000VX },
29730 +       {PCI_ANY_ID, 0x8139, 0x1186, 0x1300, 0, 0, RTL8139 },
29731 +       {PCI_ANY_ID, 0x8139, 0x13d1, 0xab06, 0, 0, RTL8139 },
29732  
29733         {0,}
29734  };
29735 @@ -302,7 +293,6 @@
29736         IntrMask = 0x3C,
29737         IntrStatus = 0x3E,
29738         TxConfig = 0x40,
29739 -       ChipVersion = 0x43,
29740         RxConfig = 0x44,
29741         Timer = 0x48,           /* A general-purpose counter. */
29742         RxMissed = 0x4C,        /* 24 bits valid, write clears. */
29743 @@ -461,7 +451,6 @@
29744         RxNoWrap = (1 << 7),
29745  };
29746  
29747 -
29748  /* Twister tuning parameters from RealTek.
29749     Completely undocumented, but required to tune bad links on some boards. */
29750  enum CSCRBits {
29751 @@ -472,36 +461,22 @@
29752         CSCR_LinkDownCmd = 0x0f3c0,
29753  };
29754  
29755 -
29756  enum Cfg9346Bits {
29757         Cfg9346_Lock = 0x00,
29758         Cfg9346_Unlock = 0xC0,
29759  };
29760  
29761 -#ifdef CONFIG_8139TOO_TUNE_TWISTER
29762 -
29763 -enum TwisterParamVals {
29764 -       PARA78_default  = 0x78fa8388,
29765 -       PARA7c_default  = 0xcb38de43,   /* param[0][3] */
29766 -       PARA7c_xxx      = 0xcb38de43,
29767 -};
29768 -
29769 -static const unsigned long param[4][4] = {
29770 -       {0xcb39de43, 0xcb39ce43, 0xfb38de03, 0xcb38de43},
29771 -       {0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83},
29772 -       {0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83},
29773 -       {0xbb39de43, 0xbb39ce43, 0xbb39ce83, 0xbb39ce83}
29774 -};
29775 -
29776 -#endif /* CONFIG_8139TOO_TUNE_TWISTER */
29777 -
29778  typedef enum {
29779         CH_8139 = 0,
29780         CH_8139_K,
29781         CH_8139A,
29782 +       CH_8139A_G,
29783         CH_8139B,
29784         CH_8130,
29785         CH_8139C,
29786 +       CH_8100,
29787 +       CH_8100B_8139D,
29788 +       CH_8101,
29789  } chip_t;
29790  
29791  enum chip_flags {
29792 @@ -509,50 +484,65 @@
29793         HasLWake = (1 << 1),
29794  };
29795  
29796 +#define HW_REVID(b30, b29, b28, b27, b26, b23, b22) \
29797 +       (b30<<30 | b29<<29 | b28<<28 | b27<<27 | b26<<26 | b23<<23 | b22<<22)
29798 +#define HW_REVID_MASK  HW_REVID(1, 1, 1, 1, 1, 1, 1)
29799  
29800  /* directly indexed by chip_t, above */
29801  const static struct {
29802         const char *name;
29803 -       u8 version; /* from RTL8139C docs */
29804 -       u32 RxConfigMask; /* should clear the bits supported by this chip */
29805 +       u32 version; /* from RTL8139C/RTL8139D docs */
29806         u32 flags;
29807  } rtl_chip_info[] = {
29808         { "RTL-8139",
29809 -         0x40,
29810 -         0xf0fe0040, /* XXX copied from RTL8139A, verify */
29811 +         HW_REVID(1, 0, 0, 0, 0, 0, 0),
29812           HasHltClk,
29813         },
29814  
29815         { "RTL-8139 rev K",
29816 -         0x60,
29817 -         0xf0fe0040,
29818 +         HW_REVID(1, 1, 0, 0, 0, 0, 0),
29819           HasHltClk,
29820         },
29821  
29822         { "RTL-8139A",
29823 -         0x70,
29824 -         0xf0fe0040,
29825 +         HW_REVID(1, 1, 1, 0, 0, 0, 0),
29826 +         HasHltClk, /* XXX undocumented? */
29827 +       },
29828 +
29829 +       { "RTL-8139A rev G",
29830 +         HW_REVID(1, 1, 1, 0, 0, 1, 0),
29831           HasHltClk, /* XXX undocumented? */
29832         },
29833  
29834         { "RTL-8139B",
29835 -         0x78,
29836 -         0xf0fc0040,
29837 +         HW_REVID(1, 1, 1, 1, 0, 0, 0),
29838           HasLWake,
29839         },
29840  
29841         { "RTL-8130",
29842 -         0x7C,
29843 -         0xf0fe0040, /* XXX copied from RTL8139A, verify */
29844 +         HW_REVID(1, 1, 1, 1, 1, 0, 0),
29845           HasLWake,
29846         },
29847  
29848         { "RTL-8139C",
29849 -         0x74,
29850 -         0xf0fc0040, /* XXX copied from RTL8139B, verify */
29851 +         HW_REVID(1, 1, 1, 0, 1, 0, 0),
29852           HasLWake,
29853         },
29854  
29855 +       { "RTL-8100",
29856 +         HW_REVID(1, 1, 1, 1, 0, 1, 0),
29857 +         HasLWake,
29858 +       },
29859 +
29860 +       { "RTL-8100B/8139D",
29861 +         HW_REVID(1, 1, 1, 0, 1, 0, 1),
29862 +         HasLWake,
29863 +       },
29864 +
29865 +       { "RTL-8101",
29866 +         HW_REVID(1, 1, 1, 0, 1, 1, 1),
29867 +         HasLWake,
29868 +       },
29869  };
29870  
29871  struct rtl_extra_stats {
29872 @@ -612,7 +602,7 @@
29873  static int mdio_read (struct net_device *dev, int phy_id, int location);
29874  static void mdio_write (struct net_device *dev, int phy_id, int location,
29875                         int val);
29876 -static int rtl8139_thread (void *data);
29877 +static inline void rtl8139_start_thread(struct net_device *dev);
29878  static void rtl8139_tx_timeout (struct net_device *dev);
29879  static void rtl8139_init_ring (struct net_device *dev);
29880  static int rtl8139_start_xmit (struct sk_buff *skb,
29881 @@ -625,6 +615,7 @@
29882  static void rtl8139_set_rx_mode (struct net_device *dev);
29883  static void __set_rx_mode (struct net_device *dev);
29884  static void rtl8139_hw_start (struct net_device *dev);
29885 +static struct ethtool_ops rtl8139_ethtool_ops;
29886  
29887  #ifdef USE_IO_OPS
29888  
29889 @@ -688,10 +679,17 @@
29890         PCIErr | PCSTimeout | RxUnderrun | RxOverflow | RxFIFOOver |
29891         TxErr | TxOK | RxErr | RxOK;
29892  
29893 +#ifdef USE_BUF16K 
29894 +static const unsigned int rtl8139_rx_config =
29895 +       RxCfgRcv16K | RxNoWrap |
29896 +       (RX_FIFO_THRESH << RxCfgFIFOShift) |
29897 +       (RX_DMA_BURST << RxCfgDMAShift);
29898 +#else
29899  static const unsigned int rtl8139_rx_config =
29900         RxCfgRcv32K | RxNoWrap |
29901         (RX_FIFO_THRESH << RxCfgFIFOShift) |
29902         (RX_DMA_BURST << RxCfgDMAShift);
29903 +#endif
29904  
29905  static const unsigned int rtl8139_tx_config =
29906         (TX_DMA_BURST << TxDMAShift) | (TX_RETRY << TxRetryShift);
29907 @@ -716,13 +714,6 @@
29908         /* it's ok to call this even if we have no regions to free */
29909         pci_release_regions (pdev);
29910  
29911 -#ifndef RTL8139_NDEBUG
29912 -       /* poison memory before freeing */
29913 -       memset (dev, 0xBC,
29914 -               sizeof (struct net_device) +
29915 -               sizeof (struct rtl8139_private));
29916 -#endif /* RTL8139_NDEBUG */
29917 -
29918         free_netdev(dev);
29919  
29920         pci_set_drvdata (pdev, NULL);
29921 @@ -757,7 +748,7 @@
29922         unsigned int i;
29923         u32 pio_start, pio_end, pio_flags, pio_len;
29924         unsigned long mmio_start, mmio_end, mmio_flags, mmio_len;
29925 -       u32 tmp;
29926 +       u32 version;
29927  
29928         assert (pdev != NULL);
29929  
29930 @@ -859,9 +850,9 @@
29931         }
29932  
29933         /* identify chip attached to board */
29934 -       tmp = RTL_R8 (ChipVersion);
29935 +       version = RTL_R32 (TxConfig) & HW_REVID_MASK;
29936         for (i = 0; i < ARRAY_SIZE (rtl_chip_info); i++)
29937 -               if (tmp == rtl_chip_info[i].version) {
29938 +               if (version == rtl_chip_info[i].version) {
29939                         tp->chipset = i;
29940                         goto match;
29941                 }
29942 @@ -892,8 +883,11 @@
29943                 }
29944                 if (rtl_chip_info[tp->chipset].flags & HasLWake) {
29945                         tmp8 = RTL_R8 (Config4);
29946 -                       if (tmp8 & LWPTN)
29947 +                       if (tmp8 & LWPTN) {
29948 +                               RTL_W8 (Cfg9346, Cfg9346_Unlock);
29949                                 RTL_W8 (Config4, tmp8 & ~LWPTN);
29950 +                               RTL_W8 (Cfg9346, Cfg9346_Lock);
29951 +                       }
29952                 }
29953         } else {
29954                 DPRINTK("Old chip wakeup\n");
29955 @@ -971,6 +965,7 @@
29956         dev->get_stats = rtl8139_get_stats;
29957         dev->set_multicast_list = rtl8139_set_rx_mode;
29958         dev->do_ioctl = netdev_ioctl;
29959 +       dev->ethtool_ops = &rtl8139_ethtool_ops;
29960         dev->tx_timeout = rtl8139_tx_timeout;
29961         dev->watchdog_timeo = TX_TIMEOUT;
29962  
29963 @@ -1318,8 +1313,6 @@
29964  
29965         tp->mii.full_duplex = tp->mii.force_media;
29966         tp->tx_flag = (TX_FIFO_THRESH << 11) & 0x003f0000;
29967 -       tp->twistie = (tp->chipset == CH_8139_K) ? 1 : 0;
29968 -       tp->time_to_die = 0;
29969  
29970         rtl8139_init_ring (dev);
29971         rtl8139_hw_start (dev);
29972 @@ -1330,32 +1323,18 @@
29973                         dev->irq, RTL_R8 (MediaStatus),
29974                         tp->mii.full_duplex ? "full" : "half");
29975  
29976 -       tp->thr_pid = kernel_thread (rtl8139_thread, dev, CLONE_FS | CLONE_FILES);
29977 -       if (tp->thr_pid < 0)
29978 -               printk (KERN_WARNING "%s: unable to start kernel thread\n",
29979 -                       dev->name);
29980 +       rtl8139_start_thread(dev);
29981  
29982         return 0;
29983  }
29984  
29985  
29986 -static void rtl_check_media (struct net_device *dev)
29987 +static void rtl_check_media (struct net_device *dev, unsigned int init_media)
29988  {
29989         struct rtl8139_private *tp = dev->priv;
29990  
29991         if (tp->phys[0] >= 0) {
29992 -               u16 mii_lpa = mdio_read(dev, tp->phys[0], MII_LPA);
29993 -               if (mii_lpa == 0xffff)
29994 -                       ;                                       /* Not there */
29995 -               else if ((mii_lpa & LPA_100FULL) == LPA_100FULL
29996 -                                || (mii_lpa & 0x00C0) == LPA_10FULL)
29997 -                       tp->mii.full_duplex = 1;
29998 -
29999 -               printk (KERN_INFO"%s: Setting %s%s-duplex based on"
30000 -                               " auto-negotiated partner ability %4.4x.\n",
30001 -                       dev->name, mii_lpa == 0 ? "" :
30002 -                               (mii_lpa & 0x0180) ? "100mbps " : "10mbps ",
30003 -                       tp->mii.full_duplex ? "full" : "half", mii_lpa);
30004 +               mii_check_media(&tp->mii, 1, init_media);
30005         }
30006  }
30007  
30008 @@ -1390,7 +1369,7 @@
30009  
30010         tp->cur_rx = 0;
30011  
30012 -       rtl_check_media (dev);
30013 +       rtl_check_media (dev, 1);
30014  
30015         if (tp->chipset >= CH_8139B) {
30016                 /* Disable magic packet scanning, which is enabled
30017 @@ -1452,6 +1431,19 @@
30018  static inline void rtl8139_tune_twister (struct net_device *dev,
30019                                   struct rtl8139_private *tp) {}
30020  #else
30021 +enum TwisterParamVals {
30022 +       PARA78_default  = 0x78fa8388,
30023 +       PARA7c_default  = 0xcb38de43,   /* param[0][3] */
30024 +       PARA7c_xxx      = 0xcb38de43,
30025 +};
30026 +
30027 +static const unsigned long param[4][4] = {
30028 +       {0xcb39de43, 0xcb39ce43, 0xfb38de03, 0xcb38de43},
30029 +       {0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83},
30030 +       {0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83},
30031 +       {0xbb39de43, 0xbb39ce43, 0xbb39ce83, 0xbb39ce83}
30032 +};
30033 +
30034  static void rtl8139_tune_twister (struct net_device *dev,
30035                                   struct rtl8139_private *tp)
30036  {
30037 @@ -1538,7 +1530,6 @@
30038  }
30039  #endif /* CONFIG_8139TOO_TUNE_TWISTER */
30040  
30041 -
30042  static inline void rtl8139_thread_iter (struct net_device *dev,
30043                                  struct rtl8139_private *tp,
30044                                  void *ioaddr)
30045 @@ -1585,7 +1576,6 @@
30046                  RTL_R8 (Config1));
30047  }
30048  
30049 -
30050  static int rtl8139_thread (void *data)
30051  {
30052         struct net_device *dev = data;
30053 @@ -1619,6 +1609,24 @@
30054         complete_and_exit (&tp->thr_exited, 0);
30055  }
30056  
30057 +static inline void rtl8139_start_thread(struct net_device *dev)
30058 +{
30059 +       struct rtl8139_private *tp = dev->priv;
30060 +
30061 +       tp->thr_pid = -1;
30062 +       tp->twistie = 0;
30063 +       tp->time_to_die = 0;
30064 +       if (tp->chipset == CH_8139_K)
30065 +               tp->twistie = 1;
30066 +       else if (tp->drv_flags & HAS_LNK_CHNG)
30067 +               return;
30068 +
30069 +       tp->thr_pid = kernel_thread(rtl8139_thread, dev, CLONE_FS|CLONE_FILES);
30070 +       if (tp->thr_pid < 0) {
30071 +               printk (KERN_WARNING "%s: unable to start kernel thread\n",
30072 +                       dev->name);
30073 +       }
30074 +}
30075  
30076  static void rtl8139_tx_clear (struct rtl8139_private *tp)
30077  {
30078 @@ -1999,18 +2007,7 @@
30079  
30080         if ((status & RxUnderrun) && link_changed &&
30081             (tp->drv_flags & HAS_LNK_CHNG)) {
30082 -               /* Really link-change on new chips. */
30083 -               int lpar = RTL_R16 (NWayLPAR);
30084 -               int duplex = (lpar & LPA_100FULL) || (lpar & 0x01C0) == 0x0040
30085 -                               || tp->mii.force_media;
30086 -               if (tp->mii.full_duplex != duplex) {
30087 -                       tp->mii.full_duplex = duplex;
30088 -#if 0
30089 -                       RTL_W8 (Cfg9346, Cfg9346_Unlock);
30090 -                       RTL_W8 (Config1, tp->mii.full_duplex ? 0x60 : 0x20);
30091 -                       RTL_W8 (Cfg9346, Cfg9346_Lock);
30092 -#endif
30093 -               }
30094 +               rtl_check_media(dev, 0);
30095                 status &= ~RxUnderrun;
30096         }
30097  
30098 @@ -2173,11 +2170,12 @@
30099  /* Get the ethtool Wake-on-LAN settings.  Assumes that wol points to
30100     kernel memory, *wol has been initialized as {ETHTOOL_GWOL}, and
30101     other threads or interrupts aren't messing with the 8139.  */
30102 -static void netdev_get_wol (struct net_device *dev, struct ethtool_wolinfo *wol)
30103 +static void rtl8139_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
30104  {
30105         struct rtl8139_private *np = dev->priv;
30106         void *ioaddr = np->mmio_addr;
30107  
30108 +       spin_lock_irq(&np->lock);
30109         if (rtl_chip_info[np->chipset].flags & HasLWake) {
30110                 u8 cfg3 = RTL_R8 (Config3);
30111                 u8 cfg5 = RTL_R8 (Config5);
30112 @@ -2199,14 +2197,14 @@
30113                 if (cfg5 & Cfg5_BWF)
30114                         wol->wolopts |= WAKE_BCAST;
30115         }
30116 +       spin_unlock_irq(&np->lock);
30117  }
30118  
30119  
30120  /* Set the ethtool Wake-on-LAN settings.  Return 0 or -errno.  Assumes
30121     that wol points to kernel memory and other threads or interrupts
30122     aren't messing with the 8139.  */
30123 -static int netdev_set_wol (struct net_device *dev,
30124 -                          const struct ethtool_wolinfo *wol)
30125 +static int rtl8139_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
30126  {
30127         struct rtl8139_private *np = dev->priv;
30128         void *ioaddr = np->mmio_addr;
30129 @@ -2220,6 +2218,7 @@
30130         if (wol->wolopts & ~support)
30131                 return -EINVAL;
30132  
30133 +       spin_lock_irq(&np->lock);
30134         cfg3 = RTL_R8 (Config3) & ~(Cfg3_LinkUp | Cfg3_Magic);
30135         if (wol->wolopts & WAKE_PHY)
30136                 cfg3 |= Cfg3_LinkUp;
30137 @@ -2240,213 +2239,120 @@
30138         if (wol->wolopts & WAKE_BCAST)
30139                 cfg5 |= Cfg5_BWF;
30140         RTL_W8 (Config5, cfg5); /* need not unlock via Cfg9346 */
30141 +       spin_unlock_irq(&np->lock);
30142  
30143         return 0;
30144  }
30145  
30146 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
30147 +static void rtl8139_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
30148  {
30149         struct rtl8139_private *np = dev->priv;
30150 -       u32 ethcmd;
30151 -
30152 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
30153 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
30154 +       strcpy(info->driver, DRV_NAME);
30155 +       strcpy(info->version, DRV_VERSION);
30156 +       strcpy(info->bus_info, pci_name(np->pci_dev));
30157 +       info->regdump_len = np->regs_len;
30158 +}
30159  
30160 -       if (get_user(ethcmd, (u32 *)useraddr))
30161 -               return -EFAULT;
30162 +static int rtl8139_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
30163 +{
30164 +       struct rtl8139_private *np = dev->priv;
30165 +       spin_lock_irq(&np->lock);
30166 +       mii_ethtool_gset(&np->mii, cmd);
30167 +       spin_unlock_irq(&np->lock);
30168 +       return 0;
30169 +}
30170  
30171 -       switch (ethcmd) {
30172 -
30173 -       case ETHTOOL_GDRVINFO: {
30174 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
30175 -               strcpy (info.driver, DRV_NAME);
30176 -               strcpy (info.version, DRV_VERSION);
30177 -               strcpy (info.bus_info, pci_name(np->pci_dev));
30178 -               info.regdump_len = np->regs_len;
30179 -               if (copy_to_user (useraddr, &info, sizeof (info)))
30180 -                       return -EFAULT;
30181 -               return 0;
30182 -       }
30183 +static int rtl8139_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
30184 +{
30185 +       struct rtl8139_private *np = dev->priv;
30186 +       int rc;
30187 +       spin_lock_irq(&np->lock);
30188 +       rc = mii_ethtool_sset(&np->mii, cmd);
30189 +       spin_unlock_irq(&np->lock);
30190 +       return rc;
30191 +}
30192  
30193 -       /* get settings */
30194 -       case ETHTOOL_GSET: {
30195 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
30196 -               spin_lock_irq(&np->lock);
30197 -               mii_ethtool_gset(&np->mii, &ecmd);
30198 -               spin_unlock_irq(&np->lock);
30199 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
30200 -                       return -EFAULT;
30201 -               return 0;
30202 -       }
30203 -       /* set settings */
30204 -       case ETHTOOL_SSET: {
30205 -               int r;
30206 -               struct ethtool_cmd ecmd;
30207 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
30208 -                       return -EFAULT;
30209 -               spin_lock_irq(&np->lock);
30210 -               r = mii_ethtool_sset(&np->mii, &ecmd);
30211 -               spin_unlock_irq(&np->lock);
30212 -               return r;
30213 -       }
30214 -       /* restart autonegotiation */
30215 -       case ETHTOOL_NWAY_RST: {
30216 -               return mii_nway_restart(&np->mii);
30217 -       }
30218 -       /* get link status */
30219 -       case ETHTOOL_GLINK: {
30220 -               struct ethtool_value edata = {ETHTOOL_GLINK};
30221 -               edata.data = mii_link_ok(&np->mii);
30222 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
30223 -                       return -EFAULT;
30224 -               return 0;
30225 -       }
30226 +static int rtl8139_nway_reset(struct net_device *dev)
30227 +{
30228 +       struct rtl8139_private *np = dev->priv;
30229 +       return mii_nway_restart(&np->mii);
30230 +}
30231  
30232 -       /* get message-level */
30233 -       case ETHTOOL_GMSGLVL: {
30234 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
30235 -               edata.data = debug;
30236 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
30237 -                       return -EFAULT;
30238 -               return 0;
30239 -       }
30240 -       /* set message-level */
30241 -       case ETHTOOL_SMSGLVL: {
30242 -               struct ethtool_value edata;
30243 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
30244 -                       return -EFAULT;
30245 -               debug = edata.data;
30246 -               return 0;
30247 -       }
30248 +static u32 rtl8139_get_link(struct net_device *dev)
30249 +{
30250 +       struct rtl8139_private *np = dev->priv;
30251 +       return mii_link_ok(&np->mii);
30252 +}
30253  
30254 -       case ETHTOOL_GWOL:
30255 -               {
30256 -                       struct ethtool_wolinfo wol = { ETHTOOL_GWOL };
30257 -                       spin_lock_irq (&np->lock);
30258 -                       netdev_get_wol (dev, &wol);
30259 -                       spin_unlock_irq (&np->lock);
30260 -                       if (copy_to_user (useraddr, &wol, sizeof (wol)))
30261 -                               return -EFAULT;
30262 -                       return 0;
30263 -               }
30264 +static u32 rtl8139_get_msglevel(struct net_device *dev)
30265 +{
30266 +       return debug;
30267 +}
30268  
30269 -       case ETHTOOL_SWOL:
30270 -               {
30271 -                       struct ethtool_wolinfo wol;
30272 -                       int rc;
30273 -                       if (copy_from_user (&wol, useraddr, sizeof (wol)))
30274 -                               return -EFAULT;
30275 -                       spin_lock_irq (&np->lock);
30276 -                       rc = netdev_set_wol (dev, &wol);
30277 -                       spin_unlock_irq (&np->lock);
30278 -                       return rc;
30279 -               }
30280 +static void rtl8139_set_msglevel(struct net_device *dev, u32 datum)
30281 +{
30282 +       debug = datum;
30283 +}
30284  
30285  /* TODO: we are too slack to do reg dumping for pio, for now */
30286 -#ifndef CONFIG_8139TOO_PIO
30287 -       /* NIC register dump */
30288 -       case ETHTOOL_GREGS: {
30289 -                struct ethtool_regs regs;
30290 -               unsigned int regs_len = np->regs_len;
30291 -                u8 *regbuf = kmalloc(regs_len, GFP_KERNEL);
30292 -                int rc;
30293 -
30294 -               if (!regbuf)
30295 -                       return -ENOMEM;
30296 -               memset(regbuf, 0, regs_len);
30297 -
30298 -                rc = copy_from_user(&regs, useraddr, sizeof(regs));
30299 -               if (rc) {
30300 -                       rc = -EFAULT;
30301 -                       goto err_out_gregs;
30302 -               }
30303 -                
30304 -                if (regs.len > regs_len)
30305 -                        regs.len = regs_len;
30306 -                if (regs.len < regs_len) {
30307 -                       rc = -EINVAL;
30308 -                       goto err_out_gregs;
30309 -               }
30310 -
30311 -                regs.version = RTL_REGS_VER;
30312 -                rc = copy_to_user(useraddr, &regs, sizeof(regs));
30313 -               if (rc) {
30314 -                       rc = -EFAULT;
30315 -                       goto err_out_gregs;
30316 -               }
30317 -
30318 -                useraddr += offsetof(struct ethtool_regs, data);
30319 -
30320 -                spin_lock_irq(&np->lock);
30321 -                memcpy_fromio(regbuf, np->mmio_addr, regs_len);
30322 -                spin_unlock_irq(&np->lock);
30323 -
30324 -                if (copy_to_user(useraddr, regbuf, regs_len))
30325 -                        rc = -EFAULT;
30326 -
30327 -err_out_gregs:
30328 -               kfree(regbuf);
30329 -               return rc;
30330 -       }
30331 -#endif /* CONFIG_8139TOO_PIO */
30332 -
30333 -       /* get string list(s) */
30334 -       case ETHTOOL_GSTRINGS: {
30335 -               struct ethtool_gstrings estr = { ETHTOOL_GSTRINGS };
30336 -
30337 -               if (copy_from_user(&estr, useraddr, sizeof(estr)))
30338 -                       return -EFAULT;
30339 -               if (estr.string_set != ETH_SS_STATS)
30340 -                       return -EINVAL;
30341 -
30342 -               estr.len = RTL_NUM_STATS;
30343 -               if (copy_to_user(useraddr, &estr, sizeof(estr)))
30344 -                       return -EFAULT;
30345 -               if (copy_to_user(useraddr + sizeof(estr),
30346 -                                &ethtool_stats_keys,
30347 -                                sizeof(ethtool_stats_keys)))
30348 -                       return -EFAULT;
30349 -               return 0;
30350 -       }
30351 +#ifdef CONFIG_8139TOO_PIO
30352 +#define rtl8139_get_regs_len   NULL
30353 +#define rtl8139_get_regs       NULL
30354 +#else
30355 +static int rtl8139_get_regs_len(struct net_device *dev)
30356 +{
30357 +       struct rtl8139_private *np = dev->priv;
30358 +       return np->regs_len;
30359 +}
30360  
30361 -       /* get NIC-specific statistics */
30362 -       case ETHTOOL_GSTATS: {
30363 -               struct ethtool_stats estats = { ETHTOOL_GSTATS };
30364 -               u64 *tmp_stats;
30365 -               const unsigned int sz = sizeof(u64) * RTL_NUM_STATS;
30366 -               int i;
30367 -
30368 -               estats.n_stats = RTL_NUM_STATS;
30369 -               if (copy_to_user(useraddr, &estats, sizeof(estats)))
30370 -                       return -EFAULT;
30371 -
30372 -               tmp_stats = kmalloc(sz, GFP_KERNEL);
30373 -               if (!tmp_stats)
30374 -                       return -ENOMEM;
30375 -               memset(tmp_stats, 0, sz);
30376 -
30377 -               i = 0;
30378 -               tmp_stats[i++] = np->xstats.early_rx;
30379 -               tmp_stats[i++] = np->xstats.tx_buf_mapped;
30380 -               tmp_stats[i++] = np->xstats.tx_timeouts;
30381 -               tmp_stats[i++] = np->xstats.rx_lost_in_ring;
30382 -               if (i != RTL_NUM_STATS)
30383 -                       BUG();
30384 +static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf)
30385 +{
30386 +       struct rtl8139_private *np = dev->priv;
30387  
30388 -               i = copy_to_user(useraddr + sizeof(estats), tmp_stats, sz);
30389 -               kfree(tmp_stats);
30390 +       regs->version = RTL_REGS_VER;
30391  
30392 -               if (i)
30393 -                       return -EFAULT;
30394 -               return 0;
30395 -       }
30396 -       default:
30397 -               break;
30398 -       }
30399 +       spin_lock_irq(&np->lock);
30400 +       memcpy_fromio(regbuf, np->mmio_addr, regs->len);
30401 +       spin_unlock_irq(&np->lock);
30402 +}
30403 +#endif /* CONFIG_8139TOO_MMIO */
30404  
30405 -       return -EOPNOTSUPP;
30406 +static int rtl8139_get_stats_count(struct net_device *dev)
30407 +{
30408 +       return RTL_NUM_STATS;
30409  }
30410  
30411 +static void rtl8139_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, u64 *data)
30412 +{
30413 +       struct rtl8139_private *np = dev->priv;
30414 +
30415 +       data[0] = np->xstats.early_rx;
30416 +       data[1] = np->xstats.tx_buf_mapped;
30417 +       data[2] = np->xstats.tx_timeouts;
30418 +       data[3] = np->xstats.rx_lost_in_ring;
30419 +}
30420 +
30421 +static void rtl8139_get_strings(struct net_device *dev, u32 stringset, u8 *data)
30422 +{
30423 +       memcpy(data, ethtool_stats_keys, sizeof(ethtool_stats_keys));
30424 +}
30425 +
30426 +static struct ethtool_ops rtl8139_ethtool_ops = {
30427 +       .get_drvinfo            = rtl8139_get_drvinfo,
30428 +       .get_settings           = rtl8139_get_settings,
30429 +       .set_settings           = rtl8139_set_settings,
30430 +       .get_regs_len           = rtl8139_get_regs_len,
30431 +       .get_regs               = rtl8139_get_regs,
30432 +       .nway_reset             = rtl8139_nway_reset,
30433 +       .get_link               = rtl8139_get_link,
30434 +       .get_msglevel           = rtl8139_get_msglevel,
30435 +       .set_msglevel           = rtl8139_set_msglevel,
30436 +       .get_wol                = rtl8139_get_wol,
30437 +       .set_wol                = rtl8139_set_wol,
30438 +       .get_strings            = rtl8139_get_strings,
30439 +       .get_stats_count        = rtl8139_get_stats_count,
30440 +       .get_ethtool_stats      = rtl8139_get_ethtool_stats,
30441 +};
30442  
30443  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
30444  {
30445 @@ -2457,14 +2363,9 @@
30446         if (!netif_running(dev))
30447                 return -EINVAL;
30448  
30449 -       if (cmd == SIOCETHTOOL)
30450 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
30451 -
30452 -       else {
30453 -               spin_lock_irq(&np->lock);
30454 -               rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
30455 -               spin_unlock_irq(&np->lock);
30456 -       }
30457 +       spin_lock_irq(&np->lock);
30458 +       rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
30459 +       spin_unlock_irq(&np->lock);
30460  
30461         return rc;
30462  }
30463 diff -Nru a/drivers/net/8390.c b/drivers/net/8390.c
30464 --- a/drivers/net/8390.c        Sun Apr 20 21:26:41 2003
30465 +++ b/drivers/net/8390.c        Mon Sep  1 09:50:20 2003
30466 @@ -997,6 +997,11 @@
30467         spin_unlock_irqrestore(&ei_local->page_lock, flags);
30468  }      
30469  
30470 +static inline void ei_device_init(struct ei_device *ei_local)
30471 +{
30472 +       spin_lock_init(&ei_local->page_lock);
30473 +}
30474 +
30475  /**
30476   * ethdev_init - init rest of 8390 device struct
30477   * @dev: network device structure to init
30478 @@ -1012,14 +1017,11 @@
30479      
30480         if (dev->priv == NULL) 
30481         {
30482 -               struct ei_device *ei_local;
30483 -               
30484                 dev->priv = kmalloc(sizeof(struct ei_device), GFP_KERNEL);
30485                 if (dev->priv == NULL)
30486                         return -ENOMEM;
30487                 memset(dev->priv, 0, sizeof(struct ei_device));
30488 -               ei_local = (struct ei_device *)dev->priv;
30489 -               spin_lock_init(&ei_local->page_lock);
30490 +               ei_device_init(dev->priv);
30491         }
30492      
30493         dev->hard_start_xmit = &ei_start_xmit;
30494 @@ -1030,6 +1032,29 @@
30495          
30496         return 0;
30497  }
30498 +
30499 +/* wrapper to make alloc_netdev happy; probably should just cast... */
30500 +static void __ethdev_init(struct net_device *dev)
30501 +{
30502 +       ethdev_init(dev);
30503 +}
30504 +
30505 +/**
30506 + * alloc_ei_netdev - alloc_etherdev counterpart for 8390
30507 + *
30508 + * Allocate 8390-specific net_device.
30509 + */
30510 +struct net_device *alloc_ei_netdev(void)
30511 +{
30512 +       struct net_device *dev;
30513 +       
30514 +       dev = alloc_netdev(sizeof(struct ei_device), "eth%d", __ethdev_init);
30515 +       if (dev)
30516 +               ei_device_init(dev->priv);
30517 +
30518 +       return dev;
30519 +}
30520 +
30521  \f
30522  
30523  
30524 @@ -1133,6 +1158,7 @@
30525  EXPORT_SYMBOL(ei_tx_timeout);
30526  EXPORT_SYMBOL(ethdev_init);
30527  EXPORT_SYMBOL(NS8390_init);
30528 +EXPORT_SYMBOL(alloc_ei_netdev);
30529  
30530  #if defined(MODULE)
30531  
30532 diff -Nru a/drivers/net/8390.h b/drivers/net/8390.h
30533 --- a/drivers/net/8390.h        Sat Jun 28 10:57:01 2003
30534 +++ b/drivers/net/8390.h        Mon Sep  1 09:50:20 2003
30535 @@ -44,6 +44,7 @@
30536  extern int ei_open(struct net_device *dev);
30537  extern int ei_close(struct net_device *dev);
30538  extern irqreturn_t ei_interrupt(int irq, void *dev_id, struct pt_regs *regs);
30539 +extern struct net_device *alloc_ei_netdev(void);
30540  
30541  /* You have one of these per-board */
30542  struct ei_device {
30543 diff -Nru a/drivers/net/Kconfig b/drivers/net/Kconfig
30544 --- a/drivers/net/Kconfig       Mon Aug 18 20:59:59 2003
30545 +++ b/drivers/net/Kconfig       Mon Sep  1 02:42:02 2003
30546 @@ -502,7 +502,7 @@
30547  
30548  config SGI_IOC3_ETH
30549         bool "SGI IOC3 Ethernet"
30550 -       depends on NET_ETHERNET && (IA64_SGI_SN1 || SGI_IP27)
30551 +       depends on NET_ETHERNET && SGI_IP27
30552         help
30553           If you have a network (Ethernet) card of this type, say Y and read
30554           the Ethernet-HOWTO, available from
30555 diff -Nru a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
30556 --- a/drivers/net/arcnet/arcnet.c       Mon Jul 21 05:31:03 2003
30557 +++ b/drivers/net/arcnet/arcnet.c       Sun Aug 31 16:14:40 2003
30558 @@ -135,7 +135,7 @@
30559                 arc_proto_map[count] = arc_proto_default;
30560  
30561         BUGLVL(D_DURING)
30562 -           printk("arcnet: struct sizes: %d %d %d %d %d\n",
30563 +           printk("arcnet: struct sizes: %Zd %Zd %Zd %Zd %Zd\n",
30564                  sizeof(struct arc_hardware), sizeof(struct arc_rfc1201),
30565                 sizeof(struct arc_rfc1051), sizeof(struct arc_eth_encap),
30566                    sizeof(struct archdr));
30567 diff -Nru a/drivers/net/arm/ether00.c b/drivers/net/arm/ether00.c
30568 --- a/drivers/net/arm/ether00.c Tue Aug 19 20:53:15 2003
30569 +++ b/drivers/net/arm/ether00.c Sun Aug 31 16:14:08 2003
30570 @@ -991,9 +991,9 @@
30571  }
30572  
30573  static struct pld_hotswap_ops ether00_pldhs_ops={
30574 -       name: ETHER00_NAME,
30575 -       add_device: ether00_add_device,
30576 -       remove_devices: ether00_remove_devices,
30577 +       .name = ETHER00_NAME,
30578 +       .add_device = ether00_add_device,
30579 +       .remove_devices = ether00_remove_devices,
30580  };
30581  
30582  
30583 diff -Nru a/drivers/net/dummy.c b/drivers/net/dummy.c
30584 --- a/drivers/net/dummy.c       Tue Aug 19 20:53:15 2003
30585 +++ b/drivers/net/dummy.c       Sun Aug 24 04:54:46 2003
30586 @@ -28,8 +28,6 @@
30587                         Alan Cox, 30th May 1994
30588  */
30589  
30590 -/* To have statistics (just packets sent) define this */
30591 -
30592  #include <linux/config.h>
30593  #include <linux/module.h>
30594  #include <linux/kernel.h>
30595 diff -Nru a/drivers/net/epic100.c b/drivers/net/epic100.c
30596 --- a/drivers/net/epic100.c     Tue Aug 19 20:53:15 2003
30597 +++ b/drivers/net/epic100.c     Mon Sep  1 14:05:11 2003
30598 @@ -362,6 +362,7 @@
30599  static int epic_rx(struct net_device *dev);
30600  static irqreturn_t epic_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
30601  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
30602 +static struct ethtool_ops netdev_ethtool_ops;
30603  static int epic_close(struct net_device *dev);
30604  static struct net_device_stats *epic_get_stats(struct net_device *dev);
30605  static void set_rx_mode(struct net_device *dev);
30606 @@ -539,6 +540,7 @@
30607         dev->get_stats = &epic_get_stats;
30608         dev->set_multicast_list = &set_rx_mode;
30609         dev->do_ioctl = &netdev_ioctl;
30610 +       dev->ethtool_ops = &netdev_ethtool_ops;
30611         dev->watchdog_timeo = TX_TIMEOUT;
30612         dev->tx_timeout = &epic_tx_timeout;
30613  
30614 @@ -1361,82 +1363,73 @@
30615         return;
30616  }
30617  
30618 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
30619 +static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
30620  {
30621         struct epic_private *np = dev->priv;
30622 -       u32 ethcmd;
30623  
30624 -       if (copy_from_user (&ethcmd, useraddr, sizeof (ethcmd)))
30625 -               return -EFAULT;
30626 +       strcpy (info->driver, DRV_NAME);
30627 +       strcpy (info->version, DRV_VERSION);
30628 +       strcpy (info->bus_info, pci_name(np->pci_dev));
30629 +}
30630  
30631 -       switch (ethcmd) {
30632 -       case ETHTOOL_GDRVINFO: {
30633 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
30634 -               strcpy (info.driver, DRV_NAME);
30635 -               strcpy (info.version, DRV_VERSION);
30636 -               strcpy (info.bus_info, pci_name(np->pci_dev));
30637 -               if (copy_to_user (useraddr, &info, sizeof (info)))
30638 -                       return -EFAULT;
30639 -               return 0;
30640 -       }
30641 -
30642 -       /* get settings */
30643 -       case ETHTOOL_GSET: {
30644 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
30645 -               spin_lock_irq(&np->lock);
30646 -               mii_ethtool_gset(&np->mii, &ecmd);
30647 -               spin_unlock_irq(&np->lock);
30648 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
30649 -                       return -EFAULT;
30650 -               return 0;
30651 -       }
30652 -       /* set settings */
30653 -       case ETHTOOL_SSET: {
30654 -               int r;
30655 -               struct ethtool_cmd ecmd;
30656 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
30657 -                       return -EFAULT;
30658 -               spin_lock_irq(&np->lock);
30659 -               r = mii_ethtool_sset(&np->mii, &ecmd);
30660 -               spin_unlock_irq(&np->lock);
30661 -               return r;
30662 -       }
30663 -       /* restart autonegotiation */
30664 -       case ETHTOOL_NWAY_RST: {
30665 -               return mii_nway_restart(&np->mii);
30666 -       }
30667 -       /* get link status */
30668 -       case ETHTOOL_GLINK: {
30669 -               struct ethtool_value edata = {ETHTOOL_GLINK};
30670 -               edata.data = mii_link_ok(&np->mii);
30671 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
30672 -                       return -EFAULT;
30673 -               return 0;
30674 -       }
30675 -
30676 -       /* get message-level */
30677 -       case ETHTOOL_GMSGLVL: {
30678 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
30679 -               edata.data = debug;
30680 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
30681 -                       return -EFAULT;
30682 -               return 0;
30683 -       }
30684 -       /* set message-level */
30685 -       case ETHTOOL_SMSGLVL: {
30686 -               struct ethtool_value edata;
30687 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
30688 -                       return -EFAULT;
30689 -               debug = edata.data;
30690 -               return 0;
30691 -       }
30692 -       default:
30693 -               break;
30694 -       }
30695 +static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
30696 +{
30697 +       struct epic_private *np = dev->priv;
30698 +       int rc;
30699 +
30700 +       spin_lock_irq(&np->lock);
30701 +       rc = mii_ethtool_gset(&np->mii, cmd);
30702 +       spin_unlock_irq(&np->lock);
30703 +
30704 +       return rc;
30705 +}
30706 +
30707 +static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
30708 +{
30709 +       struct epic_private *np = dev->priv;
30710 +       int rc;
30711 +
30712 +       spin_lock_irq(&np->lock);
30713 +       rc = mii_ethtool_sset(&np->mii, cmd);
30714 +       spin_unlock_irq(&np->lock);
30715 +
30716 +       return rc;
30717 +}
30718 +
30719 +static int netdev_nway_reset(struct net_device *dev)
30720 +{
30721 +       struct epic_private *np = dev->priv;
30722 +       return mii_nway_restart(&np->mii);
30723 +}
30724  
30725 -       return -EOPNOTSUPP;
30726 +static u32 netdev_get_link(struct net_device *dev)
30727 +{
30728 +       struct epic_private *np = dev->priv;
30729 +       return mii_link_ok(&np->mii);
30730  }
30731  
30732 +static u32 netdev_get_msglevel(struct net_device *dev)
30733 +{
30734 +       return debug;
30735 +}
30736 +
30737 +static void netdev_set_msglevel(struct net_device *dev, u32 value)
30738 +{
30739 +       debug = value;
30740 +}
30741 +
30742 +static struct ethtool_ops netdev_ethtool_ops = {
30743 +       .get_drvinfo            = netdev_get_drvinfo,
30744 +       .get_settings           = netdev_get_settings,
30745 +       .set_settings           = netdev_set_settings,
30746 +       .nway_reset             = netdev_nway_reset,
30747 +       .get_link               = netdev_get_link,
30748 +       .get_msglevel           = netdev_get_msglevel,
30749 +       .set_msglevel           = netdev_set_msglevel,
30750 +       .get_sg                 = ethtool_op_get_sg,
30751 +       .get_tx_csum            = ethtool_op_get_tx_csum,
30752 +};
30753 +
30754  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
30755  {
30756         struct epic_private *np = dev->priv;
30757 @@ -1450,16 +1443,10 @@
30758                 outl((inl(ioaddr + NVCTL) & ~0x003C) | 0x4800, ioaddr + NVCTL);
30759         }
30760  
30761 -       /* ethtool commands */
30762 -       if (cmd == SIOCETHTOOL)
30763 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
30764 -
30765 -       /* all other ioctls (the SIOC[GS]MIIxxx ioctls) */
30766 -       else {
30767 -               spin_lock_irq(&np->lock);
30768 -               rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
30769 -               spin_unlock_irq(&np->lock);
30770 -       }
30771 +       /* all non-ethtool ioctls (the SIOC[GS]MIIxxx ioctls) */
30772 +       spin_lock_irq(&np->lock);
30773 +       rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
30774 +       spin_unlock_irq(&np->lock);
30775  
30776         /* power-down, if interface is down */
30777         if (! netif_running(dev)) {
30778 diff -Nru a/drivers/net/eth16i.c b/drivers/net/eth16i.c
30779 --- a/drivers/net/eth16i.c      Sun Apr 27 20:36:19 2003
30780 +++ b/drivers/net/eth16i.c      Sun Aug 31 06:34:16 2003
30781 @@ -1053,7 +1053,7 @@
30782         int ioaddr = dev->base_addr;
30783         int status = 0;
30784         ushort length = skb->len;
30785 -       unsigned char *buf = skb->data;
30786 +       unsigned char *buf;
30787         unsigned long flags;
30788  
30789         if (length < ETH_ZLEN) {
30790 @@ -1062,6 +1062,7 @@
30791                         return 0;
30792                 length = ETH_ZLEN;
30793         }
30794 +       buf = skb->data;
30795  
30796         netif_stop_queue(dev);
30797                 
30798 diff -Nru a/drivers/net/fealnx.c b/drivers/net/fealnx.c
30799 --- a/drivers/net/fealnx.c      Tue Aug 19 20:53:16 2003
30800 +++ b/drivers/net/fealnx.c      Mon Sep  1 14:18:01 2003
30801 @@ -443,6 +443,7 @@
30802  static void set_rx_mode(struct net_device *dev);
30803  static struct net_device_stats *get_stats(struct net_device *dev);
30804  static int mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
30805 +static struct ethtool_ops netdev_ethtool_ops;
30806  static int netdev_close(struct net_device *dev);
30807  static void reset_rx_descriptors(struct net_device *dev);
30808  
30809 @@ -667,6 +668,7 @@
30810         dev->get_stats = &get_stats;
30811         dev->set_multicast_list = &set_rx_mode;
30812         dev->do_ioctl = &mii_ioctl;
30813 +       dev->ethtool_ops = &netdev_ethtool_ops;
30814         dev->tx_timeout = tx_timeout;
30815         dev->watchdog_timeo = TX_TIMEOUT;
30816         
30817 @@ -938,7 +940,7 @@
30818  // 89/9/1 modify,
30819  //   np->bcrvalue=0x38;
30820         np->bcrvalue = 0x10;
30821 -       np->cralue = 0xe00;     /* rx 128 burst length */
30822 +       np->crvalue = 0xe00;    /* rx 128 burst length */
30823  #warning Processor architecture undefined!
30824  #endif
30825  // 89/12/29 add,
30826 @@ -1760,82 +1762,72 @@
30827         writel(np->crvalue, ioaddr + TCRRCR);
30828  }
30829  
30830 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
30831 +static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
30832  {
30833         struct netdev_private *np = dev->priv;
30834 -       u32 ethcmd;
30835  
30836 -       if (copy_from_user (&ethcmd, useraddr, sizeof (ethcmd)))
30837 -               return -EFAULT;
30838 +       strcpy (info->driver, DRV_NAME);
30839 +       strcpy (info->version, DRV_VERSION);
30840 +       strcpy (info->bus_info, pci_name(np->pci_dev));
30841 +}
30842  
30843 -       switch (ethcmd) {
30844 -       case ETHTOOL_GDRVINFO: {
30845 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
30846 -               strcpy (info.driver, DRV_NAME);
30847 -               strcpy (info.version, DRV_VERSION);
30848 -               strcpy (info.bus_info, pci_name(np->pci_dev));
30849 -               if (copy_to_user (useraddr, &info, sizeof (info)))
30850 -                       return -EFAULT;
30851 -               return 0;
30852 -       }
30853 -
30854 -       /* get settings */
30855 -       case ETHTOOL_GSET: {
30856 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
30857 -               spin_lock_irq(&np->lock);
30858 -               mii_ethtool_gset(&np->mii, &ecmd);
30859 -               spin_unlock_irq(&np->lock);
30860 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
30861 -                       return -EFAULT;
30862 -               return 0;
30863 -       }
30864 -       /* set settings */
30865 -       case ETHTOOL_SSET: {
30866 -               int r;
30867 -               struct ethtool_cmd ecmd;
30868 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
30869 -                       return -EFAULT;
30870 -               spin_lock_irq(&np->lock);
30871 -               r = mii_ethtool_sset(&np->mii, &ecmd);
30872 -               spin_unlock_irq(&np->lock);
30873 -               return r;
30874 -       }
30875 -       /* restart autonegotiation */
30876 -       case ETHTOOL_NWAY_RST: {
30877 -               return mii_nway_restart(&np->mii);
30878 -       }
30879 -       /* get link status */
30880 -       case ETHTOOL_GLINK: {
30881 -               struct ethtool_value edata = {ETHTOOL_GLINK};
30882 -               edata.data = mii_link_ok(&np->mii);
30883 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
30884 -                       return -EFAULT;
30885 -               return 0;
30886 -       }
30887 -
30888 -       /* get message-level */
30889 -       case ETHTOOL_GMSGLVL: {
30890 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
30891 -               edata.data = debug;
30892 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
30893 -                       return -EFAULT;
30894 -               return 0;
30895 -       }
30896 -       /* set message-level */
30897 -       case ETHTOOL_SMSGLVL: {
30898 -               struct ethtool_value edata;
30899 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
30900 -                       return -EFAULT;
30901 -               debug = edata.data;
30902 -               return 0;
30903 -       }
30904 -       default:
30905 -               break;
30906 -       }
30907 +static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
30908 +{
30909 +       struct netdev_private *np = dev->priv;
30910 +       int rc;
30911 +
30912 +       spin_lock_irq(&np->lock);
30913 +       rc = mii_ethtool_gset(&np->mii, cmd);
30914 +       spin_unlock_irq(&np->lock);
30915 +
30916 +       return rc;
30917 +}
30918 +
30919 +static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
30920 +{
30921 +       struct netdev_private *np = dev->priv;
30922 +       int rc;
30923 +
30924 +       spin_lock_irq(&np->lock);
30925 +       rc = mii_ethtool_sset(&np->mii, cmd);
30926 +       spin_unlock_irq(&np->lock);
30927 +
30928 +       return rc;
30929 +}
30930 +
30931 +static int netdev_nway_reset(struct net_device *dev)
30932 +{
30933 +       struct netdev_private *np = dev->priv;
30934 +       return mii_nway_restart(&np->mii);
30935 +}
30936 +
30937 +static u32 netdev_get_link(struct net_device *dev)
30938 +{
30939 +       struct netdev_private *np = dev->priv;
30940 +       return mii_link_ok(&np->mii);
30941 +}
30942 +
30943 +static u32 netdev_get_msglevel(struct net_device *dev)
30944 +{
30945 +       return debug;
30946 +}
30947  
30948 -       return -EOPNOTSUPP;
30949 +static void netdev_set_msglevel(struct net_device *dev, u32 value)
30950 +{
30951 +       debug = value;
30952  }
30953  
30954 +static struct ethtool_ops netdev_ethtool_ops = {
30955 +       .get_drvinfo            = netdev_get_drvinfo,
30956 +       .get_settings           = netdev_get_settings,
30957 +       .set_settings           = netdev_set_settings,
30958 +       .nway_reset             = netdev_nway_reset,
30959 +       .get_link               = netdev_get_link,
30960 +       .get_msglevel           = netdev_get_msglevel,
30961 +       .set_msglevel           = netdev_set_msglevel,
30962 +       .get_sg                 = ethtool_op_get_sg,
30963 +       .get_tx_csum            = ethtool_op_get_tx_csum,
30964 +};
30965  
30966  static int mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
30967  {
30968 @@ -1846,14 +1838,9 @@
30969         if (!netif_running(dev))
30970                 return -EINVAL;
30971  
30972 -       if (cmd == SIOCETHTOOL)
30973 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
30974 -
30975 -       else {
30976 -               spin_lock_irq(&np->lock);
30977 -               rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
30978 -               spin_unlock_irq(&np->lock);
30979 -       }
30980 +       spin_lock_irq(&np->lock);
30981 +       rc = generic_mii_ioctl(&np->mii, data, cmd, NULL);
30982 +       spin_unlock_irq(&np->lock);
30983  
30984         return rc;
30985  }
30986 diff -Nru a/drivers/net/fmv18x.c b/drivers/net/fmv18x.c
30987 --- a/drivers/net/fmv18x.c      Sun May 11 19:48:01 2003
30988 +++ b/drivers/net/fmv18x.c      Sun Aug 31 06:34:16 2003
30989 @@ -367,7 +367,7 @@
30990         struct net_local *lp = dev->priv;
30991         int ioaddr = dev->base_addr;
30992         short length = skb->len;
30993 -       unsigned char *buf = skb->data;
30994 +       unsigned char *buf;
30995         unsigned long flags;
30996  
30997         /* Block a transmit from overlapping.  */
30998 @@ -385,6 +385,7 @@
30999                         return 0;
31000                 length = ETH_ZLEN;
31001         }
31002 +       buf = skb->data;
31003         
31004         if (net_debug > 4)
31005                 printk("%s: Transmitting a packet of length %lu.\n", dev->name,
31006 diff -Nru a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
31007 --- a/drivers/net/hamradio/bpqether.c   Tue Aug 19 20:58:55 2003
31008 +++ b/drivers/net/hamradio/bpqether.c   Wed Aug 27 23:48:03 2003
31009 @@ -605,6 +605,7 @@
31010  
31011         printk(banner);
31012  
31013 +#ifdef CONFIG_PROC_FS
31014         if (!proc_net_fops_create("bpqether", S_IRUGO, &bpq_info_fops)) {
31015                 printk(KERN_ERR
31016                         "bpq: cannot create /proc/net/bpqether entry.\n");
31017 @@ -612,6 +613,7 @@
31018                 dev_remove_pack(&bpq_packet_type);
31019                 return -ENOENT;
31020         }
31021 +#endif  /* CONFIG_PROC_FS */
31022  
31023         rtnl_lock();
31024         for (dev = dev_base; dev != NULL; dev = dev->next) {
31025 diff -Nru a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
31026 --- a/drivers/net/hamradio/yam.c        Tue Aug 19 20:53:16 2003
31027 +++ b/drivers/net/hamradio/yam.c        Thu Aug 28 01:23:35 2003
31028 @@ -807,7 +807,7 @@
31029         seq_printf(seq, "  RxInt    %u\n", yp->nb_rxint);
31030         seq_printf(seq, "  RxOver   %lu\n", yp->stats.rx_fifo_errors);
31031         seq_printf(seq, "\n");
31032 -
31033 +       return 0;
31034  }
31035  
31036  static struct seq_operations yam_seqops = {
31037 diff -Nru a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig
31038 --- a/drivers/net/irda/Kconfig  Tue Aug 19 21:06:58 2003
31039 +++ b/drivers/net/irda/Kconfig  Sun Aug 24 04:40:39 2003
31040 @@ -319,7 +319,7 @@
31041  
31042  config VLSI_FIR
31043         tristate "VLSI 82C147 SIR/MIR/FIR (EXPERIMENTAL)"
31044 -       depends on EXPERIMENTAL && IRDA
31045 +       depends on EXPERIMENTAL && IRDA && PCI
31046         help
31047           Say Y here if you want to build support for the VLSI 82C147
31048           PCI-IrDA Controller. This controller is used by the HP OmniBook 800
31049 diff -Nru a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c
31050 --- a/drivers/net/irda/via-ircc.c       Fri Aug  8 18:15:54 2003
31051 +++ b/drivers/net/irda/via-ircc.c       Sun Aug 31 16:14:08 2003
31052 @@ -134,10 +134,10 @@
31053  
31054  
31055  static struct pci_driver via_driver = {
31056 -       name:           VIA_MODULE_NAME,
31057 -       id_table:       via_pci_tbl,
31058 -       probe:          via_init_one,
31059 -       remove:         via_remove_one,
31060 +       .name           = VIA_MODULE_NAME,
31061 +       .id_table       = via_pci_tbl,
31062 +       .probe          = via_init_one,
31063 +       .remove         = via_remove_one,
31064  };
31065  
31066  
31067 diff -Nru a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
31068 --- a/drivers/net/irda/vlsi_ir.c        Wed Aug 20 15:31:21 2003
31069 +++ b/drivers/net/irda/vlsi_ir.c        Sun Aug 24 04:45:26 2003
31070 @@ -21,18 +21,20 @@
31071   *
31072   ********************************************************************/
31073  
31074 +#include <linux/config.h>
31075  #include <linux/module.h>
31076   
31077 -MODULE_DESCRIPTION("IrDA SIR/MIR/FIR driver for VLSI 82C147");
31078 -MODULE_AUTHOR("Martin Diehl <info@mdiehl.de>");
31079 -MODULE_LICENSE("GPL");
31080 +#define DRIVER_NAME            "vlsi_ir"
31081 +#define DRIVER_VERSION         "v0.5"
31082 +#define DRIVER_DESCRIPTION     "IrDA SIR/MIR/FIR driver for VLSI 82C147"
31083 +#define DRIVER_AUTHOR          "Martin Diehl <info@mdiehl.de>"
31084  
31085 -#define DRIVER_NAME "vlsi_ir"
31086 -#define DRIVER_VERSION "v0.4a"
31087 +MODULE_DESCRIPTION(DRIVER_DESCRIPTION);
31088 +MODULE_AUTHOR(DRIVER_AUTHOR);
31089 +MODULE_LICENSE("GPL");
31090  
31091  /********************************************************/
31092  
31093 -#include <linux/config.h>
31094  #include <linux/kernel.h>
31095  #include <linux/init.h>
31096  #include <linux/pci.h>
31097 @@ -44,10 +46,12 @@
31098  #include <linux/proc_fs.h>
31099  #include <linux/smp_lock.h>
31100  #include <asm/uaccess.h>
31101 +#include <asm/byteorder.h>
31102  
31103  #include <net/irda/irda.h>
31104  #include <net/irda/irda_device.h>
31105  #include <net/irda/wrapper.h>
31106 +#include <net/irda/crc.h>
31107  
31108  #include <net/irda/vlsi_ir.h>
31109  
31110 @@ -55,14 +59,16 @@
31111  
31112  static /* const */ char drivername[] = DRIVER_NAME;
31113  
31114 -#define PCI_CLASS_WIRELESS_IRDA 0x0d00
31115 -
31116 -static struct pci_device_id vlsi_irda_table [] = { {
31117 -
31118 -       .class =        PCI_CLASS_WIRELESS_IRDA << 8,
31119 -       .vendor =       PCI_VENDOR_ID_VLSI,
31120 -       .device =       PCI_DEVICE_ID_VLSI_82C147,
31121 -       }, { /* all zeroes */ }
31122 +static struct pci_device_id vlsi_irda_table [] = {
31123 +       {
31124 +               .class =        PCI_CLASS_WIRELESS_IRDA << 8,
31125 +               .class_mask =   PCI_CLASS_SUBCLASS_MASK << 8, 
31126 +               .vendor =       PCI_VENDOR_ID_VLSI,
31127 +               .device =       PCI_DEVICE_ID_VLSI_82C147,
31128 +               .subvendor =    PCI_ANY_ID,
31129 +               .subdevice =    PCI_ANY_ID,
31130 +       },
31131 +       { /* all zeroes */ }
31132  };
31133  
31134  MODULE_DEVICE_TABLE(pci, vlsi_irda_table);
31135 @@ -114,7 +120,7 @@
31136  
31137  MODULE_PARM(qos_mtt_bits, "i");
31138  MODULE_PARM_DESC(qos_mtt_bits, "IrLAP bitfield representing min-turn-time");
31139 -static int qos_mtt_bits = 0x04;                /* default is 1 ms */
31140 +static int qos_mtt_bits = 0x07;                /* default is 1 ms or more */
31141  
31142  /********************************************************/
31143  
31144 @@ -164,7 +170,7 @@
31145                 return 0;
31146  
31147         out += sprintf(out, "\n%s (vid/did: %04x/%04x)\n",
31148 -                       pci_name(pdev), (int)pdev->vendor, (int)pdev->device);
31149 +                       PCIDEV_NAME(pdev), (int)pdev->vendor, (int)pdev->device);
31150         out += sprintf(out, "pci-power-state: %u\n", (unsigned) pdev->current_state);
31151         out += sprintf(out, "resources: irq=%u / io=0x%04x / dma_mask=0x%016Lx\n",
31152                         pdev->irq, (unsigned)pci_resource_start(pdev, 0), (u64)pdev->dma_mask);
31153 @@ -198,13 +204,13 @@
31154  
31155         out += sprintf(out, "\nhw-state:\n");
31156         pci_read_config_byte(idev->pdev, VLSI_PCI_IRMISC, &byte);
31157 -       out += sprintf(out, "IRMISC:%s%s%s UART%s",
31158 +       out += sprintf(out, "IRMISC:%s%s%s uart%s",
31159                 (byte&IRMISC_IRRAIL) ? " irrail" : "",
31160                 (byte&IRMISC_IRPD) ? " irpd" : "",
31161                 (byte&IRMISC_UARTTST) ? " uarttest" : "",
31162 -               (byte&IRMISC_UARTEN) ? "" : " disabled\n");
31163 +               (byte&IRMISC_UARTEN) ? "@" : " disabled\n");
31164         if (byte&IRMISC_UARTEN) {
31165 -               out += sprintf(out, "@0x%s\n",
31166 +               out += sprintf(out, "0x%s\n",
31167                         (byte&2) ? ((byte&1) ? "3e8" : "2e8")
31168                                  : ((byte&1) ? "3f8" : "2f8"));
31169         }
31170 @@ -254,7 +260,7 @@
31171                 (word&IRCFG_RXPOL) ? " RXPOL" : "");
31172         word = inw(iobase+VLSI_PIO_IRENABLE);
31173         out += sprintf(out, "IRENABLE:%s%s%s%s%s%s%s%s\n",
31174 -               (word&IRENABLE_IREN) ? " IRENABLE" : "",
31175 +               (word&IRENABLE_PHYANDCLOCK) ? " PHYANDCLOCK" : "",
31176                 (word&IRENABLE_CFGER) ? " CFGERR" : "",
31177                 (word&IRENABLE_FIR_ON) ? " FIR_ON" : "",
31178                 (word&IRENABLE_MIR_ON) ? " MIR_ON" : "",
31179 @@ -358,7 +364,7 @@
31180         char *out = buf;
31181  
31182         if (!ndev || !ndev->priv) {
31183 -               printk(KERN_ERR "%s: invalid ptr!\n", __FUNCTION__);
31184 +               ERROR("%s: invalid ptr!\n", __FUNCTION__);
31185                 return 0;
31186         }
31187  
31188 @@ -539,7 +545,14 @@
31189                 memset(rd, 0, sizeof(*rd));
31190                 rd->hw = hwmap + i;
31191                 rd->buf = kmalloc(len, GFP_KERNEL|GFP_DMA);
31192 -               if (rd->buf == NULL) {
31193 +               if (rd->buf == NULL
31194 +                   ||  !(busaddr = pci_map_single(pdev, rd->buf, len, dir))) {
31195 +                       if (rd->buf) {
31196 +                               ERROR("%s: failed to create PCI-MAP for %p",
31197 +                                       __FUNCTION__, rd->buf);
31198 +                               kfree(rd->buf);
31199 +                               rd->buf = NULL;
31200 +                       }
31201                         for (j = 0; j < i; j++) {
31202                                 rd = r->rd + j;
31203                                 busaddr = rd_get_addr(rd);
31204 @@ -552,12 +565,6 @@
31205                         kfree(r);
31206                         return NULL;
31207                 }
31208 -               busaddr = pci_map_single(pdev, rd->buf, len, dir);
31209 -               if (!busaddr) {
31210 -                       printk(KERN_ERR "%s: failed to create PCI-MAP for %p",
31211 -                               __FUNCTION__, rd->buf);
31212 -                       BUG();
31213 -               }
31214                 rd_set_addr_status(rd, busaddr, 0);
31215                 pci_dma_sync_single(pdev, busaddr, len, dir);
31216                 /* initially, the dma buffer is owned by the CPU */
31217 @@ -597,8 +604,7 @@
31218  
31219         ringarea = pci_alloc_consistent(idev->pdev, HW_RING_AREA_SIZE, &idev->busaddr);
31220         if (!ringarea) {
31221 -               printk(KERN_ERR "%s: insufficient memory for descriptor rings\n",
31222 -                       __FUNCTION__);
31223 +               ERROR("%s: insufficient memory for descriptor rings\n", __FUNCTION__);
31224                 goto out;
31225         }
31226         memset(ringarea, 0, HW_RING_AREA_SIZE);
31227 @@ -666,33 +672,52 @@
31228                         ret |= VLSI_RX_FRAME;
31229                 if (status & RD_RX_CRCERR)  
31230                         ret |= VLSI_RX_CRC;
31231 +               goto done;
31232         }
31233 -       else {
31234 -               len = rd_get_count(rd);
31235 -               crclen = (idev->mode==IFF_FIR) ? sizeof(u32) : sizeof(u16);
31236 -               len -= crclen;          /* remove trailing CRC */
31237 -               if (len <= 0) {
31238 -                       printk(KERN_ERR "%s: strange frame (len=%d)\n",
31239 -                               __FUNCTION__, len);
31240 -                       ret |= VLSI_RX_DROP;
31241 -               }
31242 -               else if (!rd->skb) {
31243 -                       printk(KERN_ERR "%s: rx packet dropped\n", __FUNCTION__);
31244 -                       ret |= VLSI_RX_DROP;
31245 -               }
31246 -               else {
31247 -                       skb = rd->skb;
31248 -                       rd->skb = NULL;
31249 -                       skb->dev = ndev;
31250 -                       memcpy(skb_put(skb,len), rd->buf, len);
31251 -                       skb->mac.raw = skb->data;
31252 -                       if (in_interrupt())
31253 -                               netif_rx(skb);
31254 -                       else
31255 -                               netif_rx_ni(skb);
31256 -                       ndev->last_rx = jiffies;
31257 +
31258 +       len = rd_get_count(rd);
31259 +       crclen = (idev->mode==IFF_FIR) ? sizeof(u32) : sizeof(u16);
31260 +       len -= crclen;          /* remove trailing CRC */
31261 +       if (len <= 0) {
31262 +               IRDA_DEBUG(0, "%s: strange frame (len=%d)\n", __FUNCTION__, len);
31263 +               ret |= VLSI_RX_DROP;
31264 +               goto done;
31265 +       }
31266 +
31267 +       if (idev->mode == IFF_SIR) {    /* hw checks CRC in MIR, FIR mode */
31268 +
31269 +               /* rd->buf is a streaming PCI_DMA_FROMDEVICE map. Doing the
31270 +                * endian-adjustment there just in place will dirty a cache line
31271 +                * which belongs to the map and thus we must be sure it will
31272 +                * get flushed before giving the buffer back to hardware.
31273 +                * vlsi_fill_rx() will do this anyway - but here we rely on.
31274 +                */
31275 +               le16_to_cpus(rd->buf+len);
31276 +               if (irda_calc_crc16(INIT_FCS,rd->buf,len+crclen) != GOOD_FCS) {
31277 +                       IRDA_DEBUG(0, "%s: crc error\n", __FUNCTION__);
31278 +                       ret |= VLSI_RX_CRC;
31279 +                       goto done;
31280                 }
31281         }
31282 +
31283 +       if (!rd->skb) {
31284 +               WARNING("%s: rx packet lost\n", __FUNCTION__);
31285 +               ret |= VLSI_RX_DROP;
31286 +               goto done;
31287 +       }
31288 +
31289 +       skb = rd->skb;
31290 +       rd->skb = NULL;
31291 +       skb->dev = ndev;
31292 +       memcpy(skb_put(skb,len), rd->buf, len);
31293 +       skb->mac.raw = skb->data;
31294 +       if (in_interrupt())
31295 +               netif_rx(skb);
31296 +       else
31297 +               netif_rx_ni(skb);
31298 +       ndev->last_rx = jiffies;
31299 +
31300 +done:
31301         rd_set_status(rd, 0);
31302         rd_set_count(rd, 0);
31303         /* buffer still owned by CPU */
31304 @@ -706,7 +731,9 @@
31305  
31306         for (rd = ring_last(r); rd != NULL; rd = ring_put(r)) {
31307                 if (rd_is_active(rd)) {
31308 -                       BUG();
31309 +                       WARNING("%s: driver bug: rx descr race with hw\n",
31310 +                               __FUNCTION__);
31311 +                       vlsi_ring_debug(r);
31312                         break;
31313                 }
31314                 if (!rd->skb) {
31315 @@ -764,7 +791,7 @@
31316  
31317         if (ring_first(r) == NULL) {
31318                 /* we are in big trouble, if this should ever happen */
31319 -               printk(KERN_ERR "%s: rx ring exhausted!\n", __FUNCTION__);
31320 +               ERROR("%s: rx ring exhausted!\n", __FUNCTION__);
31321                 vlsi_ring_debug(r);
31322         }
31323         else
31324 @@ -785,7 +812,7 @@
31325                 if (rd_is_active(rd)) {
31326                         rd_set_status(rd, 0);
31327                         if (rd_get_count(rd)) {
31328 -                               printk(KERN_INFO "%s - dropping rx packet\n", __FUNCTION__);
31329 +                               IRDA_DEBUG(0, "%s - dropping rx packet\n", __FUNCTION__);
31330                                 ret = -VLSI_RX_DROP;
31331                         }
31332                         rd_set_count(rd, 0);
31333 @@ -850,24 +877,17 @@
31334         return (ret) ? -ret : len;
31335  }
31336  
31337 -static int vlsi_set_baud(struct net_device *ndev, int dolock)
31338 +static int vlsi_set_baud(vlsi_irda_dev_t *idev, unsigned iobase)
31339  {
31340 -       vlsi_irda_dev_t *idev = ndev->priv;
31341 -       unsigned long flags;
31342         u16 nphyctl;
31343 -       unsigned iobase; 
31344         u16 config;
31345         unsigned mode;
31346 -       unsigned idle_retry;
31347         int     ret;
31348         int     baudrate;
31349 -       int     fifocnt = 0;    /* Keep compiler happy */
31350 +       int     fifocnt;
31351  
31352         baudrate = idev->new_baud;
31353 -       iobase = ndev->base_addr;
31354 -#if 0
31355 -       printk(KERN_DEBUG "%s: %d -> %d\n", __FUNCTION__, idev->baud, idev->new_baud);
31356 -#endif
31357 +       IRDA_DEBUG(2, "%s: %d -> %d\n", __FUNCTION__, idev->baud, idev->new_baud);
31358         if (baudrate == 4000000) {
31359                 mode = IFF_FIR;
31360                 config = IRCFG_FIR;
31361 @@ -883,7 +903,7 @@
31362                 config = IRCFG_SIR | IRCFG_SIRFILT  | IRCFG_RXANY;
31363                 switch(baudrate) {
31364                         default:
31365 -                               printk(KERN_ERR "%s: undefined baudrate %d - fallback to 9600!\n",
31366 +                               WARNING("%s: undefined baudrate %d - fallback to 9600!\n",
31367                                         __FUNCTION__, baudrate);
31368                                 baudrate = 9600;
31369                                 /* fallthru */
31370 @@ -897,40 +917,18 @@
31371                                 break;
31372                 }
31373         }
31374 +       config |= IRCFG_MSTR | IRCFG_ENRX;
31375  
31376 -       if (dolock)
31377 -               spin_lock_irqsave(&idev->lock, flags);
31378 -       else
31379 -               flags = 0xdead; /* prevent bogus warning about possible uninitialized use */
31380 -
31381 -       for (idle_retry=0; idle_retry < 100; idle_retry++) {
31382 -               fifocnt = inw(ndev->base_addr+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK;
31383 -               if (fifocnt == 0)
31384 -                       break;
31385 -               if (!idle_retry)
31386 -                       printk(KERN_WARNING "%s: waiting for rx fifo to become empty(%d)\n",
31387 -                               __FUNCTION__, fifocnt);
31388 -               if (dolock) {
31389 -                       spin_unlock_irqrestore(&idev->lock, flags);
31390 -                       udelay(100);
31391 -                       spin_lock_irqsave(&idev->lock, flags);
31392 -               }
31393 -               else
31394 -                       udelay(100);
31395 +       fifocnt = inw(iobase+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK;
31396 +       if (fifocnt != 0) {
31397 +               IRDA_DEBUG(0, "%s: rx fifo not empty(%d)\n", __FUNCTION__, fifocnt);
31398         }
31399 -       if (fifocnt != 0)
31400 -               printk(KERN_ERR "%s: rx fifo not empty(%d)\n", __FUNCTION__, fifocnt);
31401  
31402         outw(0, iobase+VLSI_PIO_IRENABLE);
31403 -       wmb();
31404 -
31405 -       config |= IRCFG_MSTR | IRCFG_ENRX;
31406 -
31407         outw(config, iobase+VLSI_PIO_IRCFG);
31408 -
31409         outw(nphyctl, iobase+VLSI_PIO_NPHYCTL);
31410         wmb();
31411 -       outw(IRENABLE_IREN, iobase+VLSI_PIO_IRENABLE);
31412 +       outw(IRENABLE_PHYANDCLOCK, iobase+VLSI_PIO_IRENABLE);
31413         mb();
31414  
31415         udelay(1);      /* chip applies IRCFG on next rising edge of its 8MHz clock */
31416 @@ -946,14 +944,14 @@
31417         else
31418                 config ^= IRENABLE_SIR_ON;
31419  
31420 -       if (config != (IRENABLE_IREN|IRENABLE_ENRXST)) {
31421 -               printk(KERN_ERR "%s: failed to set %s mode!\n", __FUNCTION__,
31422 +       if (config != (IRENABLE_PHYANDCLOCK|IRENABLE_ENRXST)) {
31423 +               WARNING("%s: failed to set %s mode!\n", __FUNCTION__,
31424                         (mode==IFF_SIR)?"SIR":((mode==IFF_MIR)?"MIR":"FIR"));
31425                 ret = -1;
31426         }
31427         else {
31428                 if (inw(iobase+VLSI_PIO_PHYCTL) != nphyctl) {
31429 -                       printk(KERN_ERR "%s: failed to apply baudrate %d\n",
31430 +                       WARNING("%s: failed to apply baudrate %d\n",
31431                                 __FUNCTION__, baudrate);
31432                         ret = -1;
31433                 }
31434 @@ -964,8 +962,6 @@
31435                         ret = 0;
31436                 }
31437         }
31438 -       if (dolock)
31439 -               spin_unlock_irqrestore(&idev->lock, flags);
31440  
31441         if (ret)
31442                 vlsi_reg_debug(iobase,__FUNCTION__);
31443 @@ -973,16 +969,6 @@
31444         return ret;
31445  }
31446  
31447 -static inline int vlsi_set_baud_lock(struct net_device *ndev)
31448 -{
31449 -       return vlsi_set_baud(ndev, 1);
31450 -}
31451 -
31452 -static inline int vlsi_set_baud_nolock(struct net_device *ndev)
31453 -{
31454 -       return vlsi_set_baud(ndev, 0);
31455 -}
31456 -
31457  static int vlsi_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
31458  {
31459         vlsi_irda_dev_t *idev = ndev->priv;
31460 @@ -995,79 +981,100 @@
31461         int mtt;
31462         int len, speed;
31463         struct timeval  now, ready;
31464 +       char *msg = NULL;
31465  
31466         speed = irda_get_next_speed(skb);
31467 +       spin_lock_irqsave(&idev->lock, flags);
31468         if (speed != -1  &&  speed != idev->baud) {
31469                 netif_stop_queue(ndev);
31470                 idev->new_baud = speed;
31471 -               if (!skb->len) {
31472 -                       dev_kfree_skb_any(skb);
31473 -
31474 -                       /* due to the completely asynch tx operation we might have
31475 -                        * IrLAP racing with the hardware here, f.e. if the controller
31476 -                        * is just sending the last packet with current speed while
31477 -                        * the LAP is already switching the speed using synchronous
31478 -                        * len=0 packet. Immediate execution would lead to hw lockup
31479 -                        * requiring a powercycle to reset. Good candidate to trigger
31480 -                        * this is the final UA:RSP packet after receiving a DISC:CMD
31481 -                        * when getting the LAP down.
31482 -                        * Note that we are not protected by the queue_stop approach
31483 -                        * because the final UA:RSP arrives _without_ request to apply
31484 -                        * new-speed-after-this-packet - hence the driver doesn't know
31485 -                        * this was the last packet and doesn't stop the queue. So the
31486 -                        * forced switch to default speed from LAP gets through as fast
31487 -                        * as only some 10 usec later while the UA:RSP is still processed
31488 -                        * by the hardware and we would get screwed.
31489 -                        * Note: no locking required since we (netdev->xmit) are the only
31490 -                        * supplier for tx and the network layer provides serialization
31491 -                        */
31492 -                       spin_lock_irqsave(&idev->lock, flags);
31493 -                       if (ring_first(idev->tx_ring) == NULL) {
31494 -                               /* no race - tx-ring already empty */
31495 -                               vlsi_set_baud_nolock(ndev);
31496 -                               netif_wake_queue(ndev);
31497 -                       }
31498 -                       else
31499 -                               ; /* keep the speed change pending like it would
31500 -                                  * for any len>0 packet. tx completion interrupt
31501 -                                  * will apply it when the tx ring becomes empty.
31502 -                                  */
31503 -                       spin_unlock_irqrestore(&idev->lock, flags);
31504 -                       return 0;
31505 -               }
31506                 status = RD_TX_CLRENTX;  /* stop tx-ring after this frame */
31507         }
31508         else
31509                 status = 0;
31510  
31511         if (skb->len == 0) {
31512 -               printk(KERN_ERR "%s: dropping len=0 packet\n", __FUNCTION__);
31513 -               goto drop;
31514 +               /* handle zero packets - should be speed change */
31515 +               if (status == 0) {
31516 +                       msg = "bogus zero-length packet";
31517 +                       goto drop_unlock;
31518 +               }
31519 +
31520 +               /* due to the completely asynch tx operation we might have
31521 +                * IrLAP racing with the hardware here, f.e. if the controller
31522 +                * is just sending the last packet with current speed while
31523 +                * the LAP is already switching the speed using synchronous
31524 +                * len=0 packet. Immediate execution would lead to hw lockup
31525 +                * requiring a powercycle to reset. Good candidate to trigger
31526 +                * this is the final UA:RSP packet after receiving a DISC:CMD
31527 +                * when getting the LAP down.
31528 +                * Note that we are not protected by the queue_stop approach
31529 +                * because the final UA:RSP arrives _without_ request to apply
31530 +                * new-speed-after-this-packet - hence the driver doesn't know
31531 +                * this was the last packet and doesn't stop the queue. So the
31532 +                * forced switch to default speed from LAP gets through as fast
31533 +                * as only some 10 usec later while the UA:RSP is still processed
31534 +                * by the hardware and we would get screwed.
31535 +                */
31536 +
31537 +               if (ring_first(idev->tx_ring) == NULL) {
31538 +                       /* no race - tx-ring already empty */
31539 +                       vlsi_set_baud(idev, iobase);
31540 +                       netif_wake_queue(ndev);
31541 +               }
31542 +               else
31543 +                       ;
31544 +                       /* keep the speed change pending like it would
31545 +                        * for any len>0 packet. tx completion interrupt
31546 +                        * will apply it when the tx ring becomes empty.
31547 +                        */
31548 +               spin_unlock_irqrestore(&idev->lock, flags);
31549 +               dev_kfree_skb_any(skb);
31550 +               return 0;
31551         }
31552  
31553 -       /* sanity checks - should never happen!
31554 -        * simply BUGging the violation and dropping the packet
31555 -        */
31556 +       /* sanity checks - simply drop the packet */
31557  
31558         rd = ring_last(r);
31559 -       if (!rd) {                              /* ring full - queue should have been stopped! */
31560 -               BUG();
31561 -               goto drop;
31562 +       if (!rd) {
31563 +               msg = "ring full, but queue wasn't stopped";
31564 +               goto drop_unlock;
31565         }
31566  
31567 -       if (rd_is_active(rd)) {                 /* entry still owned by hw! */
31568 -               BUG();
31569 -               goto drop;
31570 +       if (rd_is_active(rd)) {
31571 +               msg = "entry still owned by hw";
31572 +               goto drop_unlock;
31573         }
31574  
31575 -       if (!rd->buf) {                         /* no memory for this tx entry - weird! */
31576 -               BUG();
31577 -               goto drop;
31578 +       if (!rd->buf) {
31579 +               msg = "tx ring entry without pci buffer";
31580 +               goto drop_unlock;
31581         }
31582  
31583 -       if (rd->skb) {                          /* hm, associated old skb still there */
31584 -               BUG();
31585 -               goto drop;
31586 +       if (rd->skb) {
31587 +               msg = "ring entry with old skb still attached";
31588 +               goto drop_unlock;
31589 +       }
31590 +
31591 +       /* no need for serialization or interrupt disable during mtt */
31592 +       spin_unlock_irqrestore(&idev->lock, flags);
31593 +
31594 +       if ((mtt = irda_get_mtt(skb)) > 0) {
31595 +       
31596 +               ready.tv_usec = idev->last_rx.tv_usec + mtt;
31597 +               ready.tv_sec = idev->last_rx.tv_sec;
31598 +               if (ready.tv_usec >= 1000000) {
31599 +                       ready.tv_usec -= 1000000;
31600 +                       ready.tv_sec++;         /* IrLAP 1.1: mtt always < 1 sec */
31601 +               }
31602 +               for(;;) {
31603 +                       do_gettimeofday(&now);
31604 +                       if (now.tv_sec > ready.tv_sec
31605 +                           ||  (now.tv_sec==ready.tv_sec && now.tv_usec>=ready.tv_usec))
31606 +                               break;
31607 +                       udelay(100);
31608 +                       /* must not sleep here - we are called under xmit_lock! */
31609 +               }
31610         }
31611  
31612         /* tx buffer already owned by CPU due to pci_dma_sync_single() either
31613 @@ -1089,7 +1096,7 @@
31614                  */
31615  
31616                 if (len >= r->len-5)
31617 -                        printk(KERN_WARNING "%s: possible buffer overflow with SIR wrapping!\n",
31618 +                        WARNING("%s: possible buffer overflow with SIR wrapping!\n",
31619                                 __FUNCTION__);
31620         }
31621         else {
31622 @@ -1097,34 +1104,13 @@
31623                 status |= RD_TX_PULSE;          /* send 2 us highspeed indication pulse */
31624                 len = skb->len;
31625                 if (len > r->len) {
31626 -                       printk(KERN_ERR "%s: no space - skb too big (%d)\n",
31627 -                               __FUNCTION__, skb->len);
31628 +                       msg = "frame exceeds tx buffer length";
31629                         goto drop;
31630                 }
31631                 else
31632                         memcpy(rd->buf, skb->data, len);
31633         }
31634  
31635 -       /* do mtt delay before we need to disable interrupts! */
31636 -
31637 -       if ((mtt = irda_get_mtt(skb)) > 0) {
31638 -       
31639 -               ready.tv_usec = idev->last_rx.tv_usec + mtt;
31640 -               ready.tv_sec = idev->last_rx.tv_sec;
31641 -               if (ready.tv_usec >= 1000000) {
31642 -                       ready.tv_usec -= 1000000;
31643 -                       ready.tv_sec++;         /* IrLAP 1.1: mtt always < 1 sec */
31644 -               }
31645 -               for(;;) {
31646 -                       do_gettimeofday(&now);
31647 -                       if (now.tv_sec > ready.tv_sec
31648 -                           ||  (now.tv_sec==ready.tv_sec && now.tv_usec>=ready.tv_usec))
31649 -                               break;
31650 -                       udelay(100);
31651 -                       /* must not sleep here - we are called under xmit_lock! */
31652 -               }
31653 -       }
31654 -
31655         rd->skb = skb;                  /* remember skb for tx-complete stats */
31656  
31657         rd_set_count(rd, len);
31658 @@ -1136,10 +1122,7 @@
31659  
31660         pci_dma_prep_single(r->pdev, rd_get_addr(rd), r->len, r->dir);
31661  
31662 -/*
31663 - *     We need to disable IR output in order to switch to TX mode.
31664 - *     Better not do this blindly anytime we want to transmit something
31665 - *     because TX may already run. However we are racing with the controller
31666 +/*     Switching to TX mode here races with the controller
31667   *     which may stop TX at any time when fetching an inactive descriptor
31668   *     or one with CLR_ENTX set. So we switch on TX only, if TX was not running
31669   *     _after_ the new descriptor was activated on the ring. This ensures
31670 @@ -1158,31 +1141,39 @@
31671                 int fifocnt;
31672  
31673                 fifocnt = inw(ndev->base_addr+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK;
31674 -               if (fifocnt != 0)
31675 -                       printk(KERN_WARNING "%s: rx fifo not empty(%d)\n",
31676 -                               __FUNCTION__, fifocnt);
31677 +               if (fifocnt != 0) {
31678 +                       IRDA_DEBUG(0, "%s: rx fifo not empty(%d)\n", __FUNCTION__, fifocnt);
31679 +               }
31680  
31681                 config = inw(iobase+VLSI_PIO_IRCFG);
31682 -               rmb();
31683 -               outw(config | IRCFG_ENTX, iobase+VLSI_PIO_IRCFG);
31684                 mb();
31685 +               outw(config | IRCFG_ENTX, iobase+VLSI_PIO_IRCFG);
31686 +               wmb();
31687                 outw(0, iobase+VLSI_PIO_PROMPT);
31688         }
31689         ndev->trans_start = jiffies;
31690  
31691         if (ring_put(r) == NULL) {
31692                 netif_stop_queue(ndev);
31693 -               printk(KERN_DEBUG "%s: tx ring full - queue stopped\n", __FUNCTION__);
31694 +               IRDA_DEBUG(3, "%s: tx ring full - queue stopped\n", __FUNCTION__);
31695         }
31696         spin_unlock_irqrestore(&idev->lock, flags);
31697  
31698         return 0;
31699  
31700 +drop_unlock:
31701 +       spin_unlock_irqrestore(&idev->lock, flags);
31702  drop:
31703 +       WARNING("%s: dropping packet - %s\n", __FUNCTION__, msg);
31704         dev_kfree_skb_any(skb);
31705         idev->stats.tx_errors++;
31706         idev->stats.tx_dropped++;
31707 -       return 1;
31708 +       /* Don't even think about returning NET_XMIT_DROP (=1) here!
31709 +        * In fact any retval!=0 causes the packet scheduler to requeue the
31710 +        * packet for later retry of transmission - which isn't exactly
31711 +        * what we want after we've just called dev_kfree_skb_any ;-)
31712 +        */
31713 +       return 0;
31714  }
31715  
31716  static void vlsi_tx_interrupt(struct net_device *ndev)
31717 @@ -1215,12 +1206,12 @@
31718                 }
31719         }
31720  
31721 +       iobase = ndev->base_addr;
31722 +
31723         if (idev->new_baud  &&  rd == NULL)     /* tx ring empty and speed change pending */
31724 -               vlsi_set_baud_lock(ndev);
31725 +               vlsi_set_baud(idev, iobase);
31726  
31727 -       iobase = ndev->base_addr;
31728         config = inw(iobase+VLSI_PIO_IRCFG);
31729 -
31730         if (rd == NULL)                 /* tx ring empty: re-enable rx */
31731                 outw((config & ~IRCFG_ENTX) | IRCFG_ENRX, iobase+VLSI_PIO_IRCFG);
31732  
31733 @@ -1228,9 +1219,10 @@
31734                 int fifocnt;
31735  
31736                 fifocnt = inw(iobase+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK;
31737 -               if (fifocnt != 0)
31738 -                       printk(KERN_WARNING "%s: rx fifo not empty(%d)\n",
31739 +               if (fifocnt != 0) {
31740 +                       IRDA_DEBUG(0, "%s: rx fifo not empty(%d)\n",
31741                                 __FUNCTION__, fifocnt);
31742 +               }
31743                 outw(config | IRCFG_ENTX, iobase+VLSI_PIO_IRCFG);
31744         }
31745  
31746 @@ -1238,7 +1230,7 @@
31747  
31748         if (netif_queue_stopped(ndev)  &&  !idev->new_baud) {
31749                 netif_wake_queue(ndev);
31750 -               printk(KERN_DEBUG "%s: queue awoken\n", __FUNCTION__);
31751 +               IRDA_DEBUG(3, "%s: queue awoken\n", __FUNCTION__);
31752         }
31753  }
31754  
31755 @@ -1261,7 +1253,7 @@
31756                                 dev_kfree_skb_any(rd->skb);
31757                                 rd->skb = NULL;
31758                         }
31759 -                       printk(KERN_INFO "%s - dropping tx packet\n", __FUNCTION__);
31760 +                       IRDA_DEBUG(0, "%s - dropping tx packet\n", __FUNCTION__);
31761                         ret = -VLSI_TX_DROP;
31762                 }
31763                 else
31764 @@ -1310,8 +1302,7 @@
31765                 }
31766                 if (count < 3) {
31767                         if (clksrc == 1) { /* explicitly asked for PLL hence bail out */
31768 -                               printk(KERN_ERR "%s: no PLL or failed to lock!\n",
31769 -                                       __FUNCTION__);
31770 +                               ERROR("%s: no PLL or failed to lock!\n", __FUNCTION__);
31771                                 clkctl = CLKCTL_CLKSTP;
31772                                 pci_write_config_byte(pdev, VLSI_PCI_CLKCTL, clkctl);
31773                                 return -1;
31774 @@ -1319,7 +1310,7 @@
31775                         else                    /* was: clksrc=0(auto) */
31776                                 clksrc = 3;     /* fallback to 40MHz XCLK (OB800) */
31777  
31778 -                       printk(KERN_INFO "%s: PLL not locked, fallback to clksrc=%d\n",
31779 +                       IRDA_DEBUG(0, "%s: PLL not locked, fallback to clksrc=%d\n",
31780                                 __FUNCTION__, clksrc);
31781                 }
31782                 else
31783 @@ -1392,9 +1383,7 @@
31784         /* start the clock and clean the registers */
31785  
31786         if (vlsi_start_clock(pdev)) {
31787 -               printk(KERN_ERR "%s: no valid clock source\n",
31788 -                       __FUNCTION__);
31789 -               pci_disable_device(pdev);
31790 +               ERROR("%s: no valid clock source\n", __FUNCTION__);
31791                 return -1;
31792         }
31793         iobase = ndev->base_addr;
31794 @@ -1422,7 +1411,7 @@
31795         atomic_set(&idev->tx_ring->head, RINGPTR_GET_TX(ptr));
31796         atomic_set(&idev->tx_ring->tail, RINGPTR_GET_TX(ptr));
31797  
31798 -       vlsi_set_baud_lock(ndev);       /* idev->new_baud used as provided by caller */
31799 +       vlsi_set_baud(idev, iobase);    /* idev->new_baud used as provided by caller */
31800  
31801         outb(IRINTR_INT_MASK, iobase+VLSI_PIO_IRINTR);  /* just in case - w/c pending IRQ's */
31802         wmb();
31803 @@ -1455,7 +1444,10 @@
31804         pci_write_config_byte(pdev, VLSI_PCI_MSTRPAGE, MSTRPAGE_VALUE);
31805         pci_set_master(pdev);
31806  
31807 -       vlsi_init_chip(pdev);
31808 +       if (vlsi_init_chip(pdev) < 0) {
31809 +               pci_disable_device(pdev);
31810 +               return -1;
31811 +       }
31812  
31813         vlsi_fill_rx(idev->rx_ring);
31814  
31815 @@ -1476,10 +1468,11 @@
31816         spin_lock_irqsave(&idev->lock,flags);
31817         outw(0, iobase+VLSI_PIO_IRENABLE);
31818         outw(0, iobase+VLSI_PIO_IRCFG);                 /* disable everything */
31819 -       wmb();
31820  
31821 -       outb(IRINTR_INT_MASK, iobase+VLSI_PIO_IRINTR);  /* w/c pending + disable further IRQ */
31822 -       mb();
31823 +       /* disable and w/c irqs */
31824 +       outb(0, iobase+VLSI_PIO_IRINTR);
31825 +       wmb();
31826 +       outb(IRINTR_INT_MASK, iobase+VLSI_PIO_IRINTR);
31827         spin_unlock_irqrestore(&idev->lock,flags);
31828  
31829         vlsi_unarm_tx(idev);
31830 @@ -1521,8 +1514,8 @@
31831                 idev->new_baud = idev->baud;            /* keep current baudrate */
31832  
31833         if (vlsi_start_hw(idev))
31834 -               printk(KERN_CRIT "%s: failed to restart hw - %s(%s) unusable!\n",
31835 -                       __FUNCTION__, pci_name(idev->pdev), ndev->name);
31836 +               ERROR("%s: failed to restart hw - %s(%s) unusable!\n",
31837 +                       __FUNCTION__, PCIDEV_NAME(idev->pdev), ndev->name);
31838         else
31839                 netif_start_queue(ndev);
31840  }
31841 @@ -1547,7 +1540,7 @@
31842                          * if the stack tries to change speed concurrently - which would be
31843                          * pretty strange anyway with the userland having full control...
31844                          */
31845 -                       vlsi_set_baud_nolock(ndev);
31846 +                       vlsi_set_baud(idev, ndev->base_addr);
31847                         spin_unlock_irqrestore(&idev->lock, flags);
31848                         break;
31849                 case SIOCSMEDIABUSY:
31850 @@ -1566,8 +1559,7 @@
31851                         irq->ifr_receiving = (fifocnt!=0) ? 1 : 0;
31852                         break;
31853                 default:
31854 -                       printk(KERN_ERR "%s: notsupp - cmd=%04x\n",
31855 -                               __FUNCTION__, cmd);
31856 +                       WARNING("%s: notsupp - cmd=%04x\n", __FUNCTION__, cmd);
31857                         ret = -EOPNOTSUPP;
31858         }       
31859         
31860 @@ -1583,41 +1575,36 @@
31861         vlsi_irda_dev_t *idev = ndev->priv;
31862         unsigned        iobase;
31863         u8              irintr;
31864 -       int             boguscount = 32;
31865 -       unsigned        got_act;
31866 +       int             boguscount = 5;
31867         unsigned long   flags;
31868         int             handled = 0;
31869  
31870 -       got_act = 0;
31871         iobase = ndev->base_addr;
31872 +       spin_lock_irqsave(&idev->lock,flags);
31873         do {
31874 -               spin_lock_irqsave(&idev->lock,flags);
31875                 irintr = inb(iobase+VLSI_PIO_IRINTR);
31876 -               rmb();
31877 -               outb(irintr, iobase+VLSI_PIO_IRINTR); /* acknowledge asap */
31878 -               spin_unlock_irqrestore(&idev->lock,flags);
31879 +               mb();
31880 +               outb(irintr, iobase+VLSI_PIO_IRINTR);   /* acknowledge asap */
31881  
31882                 if (!(irintr&=IRINTR_INT_MASK))         /* not our INT - probably shared */
31883                         break;
31884 +
31885                 handled = 1;
31886 +
31887 +               if (unlikely(!(irintr & ~IRINTR_ACTIVITY)))
31888 +                       break;                          /* nothing todo if only activity */
31889 +
31890                 if (irintr&IRINTR_RPKTINT)
31891                         vlsi_rx_interrupt(ndev);
31892  
31893                 if (irintr&IRINTR_TPKTINT)
31894                         vlsi_tx_interrupt(ndev);
31895  
31896 -               if (!(irintr & ~IRINTR_ACTIVITY))
31897 -                       break;          /* done if only activity remaining */
31898 -       
31899 -               if (irintr & ~(IRINTR_RPKTINT|IRINTR_TPKTINT|IRINTR_ACTIVITY)) {
31900 -                       printk(KERN_DEBUG "%s: IRINTR = %02x\n",
31901 -                               __FUNCTION__, (unsigned)irintr);
31902 -                       vlsi_reg_debug(iobase,__FUNCTION__);
31903 -               }                       
31904         } while (--boguscount > 0);
31905 +       spin_unlock_irqrestore(&idev->lock,flags);
31906  
31907         if (boguscount <= 0)
31908 -               printk(KERN_WARNING "%s: too much work in interrupt!\n", __FUNCTION__);
31909 +               MESSAGE("%s: too much work in interrupt!\n", __FUNCTION__);
31910         return IRQ_RETVAL(handled);
31911  }
31912  
31913 @@ -1630,7 +1617,7 @@
31914         char    hwname[32];
31915  
31916         if (pci_request_regions(idev->pdev, drivername)) {
31917 -               printk(KERN_ERR "%s: io resource busy\n", __FUNCTION__);
31918 +               WARNING("%s: io resource busy\n", __FUNCTION__);
31919                 goto errout;
31920         }
31921         ndev->base_addr = pci_resource_start(idev->pdev,0);
31922 @@ -1644,8 +1631,7 @@
31923  
31924         if (request_irq(ndev->irq, vlsi_interrupt, SA_SHIRQ,
31925                         drivername, ndev)) {
31926 -               printk(KERN_ERR "%s: couldn't get IRQ: %d\n",
31927 -                       __FUNCTION__, ndev->irq);
31928 +               WARNING("%s: couldn't get IRQ: %d\n", __FUNCTION__, ndev->irq);
31929                 goto errout_io;
31930         }
31931  
31932 @@ -1666,7 +1652,7 @@
31933  
31934         netif_start_queue(ndev);
31935  
31936 -       printk(KERN_INFO "%s: device %s operational\n", __FUNCTION__, ndev->name);
31937 +       MESSAGE("%s: device %s operational\n", __FUNCTION__, ndev->name);
31938  
31939         return 0;
31940  
31941 @@ -1700,7 +1686,7 @@
31942  
31943         pci_release_regions(idev->pdev);
31944  
31945 -       printk(KERN_INFO "%s: device %s stopped\n", __FUNCTION__, ndev->name);
31946 +       MESSAGE("%s: device %s stopped\n", __FUNCTION__, ndev->name);
31947  
31948         return 0;
31949  }
31950 @@ -1721,8 +1707,7 @@
31951  
31952         if (pci_set_dma_mask(pdev,DMA_MASK_USED_BY_HW)
31953             || pci_set_dma_mask(pdev,DMA_MASK_MSTRPAGE)) {
31954 -               printk(KERN_ERR "%s: aborting due to PCI BM-DMA address limitations\n",
31955 -                       __FUNCTION__);
31956 +               ERROR("%s: aborting due to PCI BM-DMA address limitations\n", __FUNCTION__);
31957                 return -1;
31958         }
31959  
31960 @@ -1771,12 +1756,12 @@
31961         else
31962                 pdev->current_state = 0; /* hw must be running now */
31963  
31964 -       printk(KERN_INFO "%s: IrDA PCI controller %s detected\n",
31965 -               drivername, pci_name(pdev));
31966 +       MESSAGE("%s: IrDA PCI controller %s detected\n",
31967 +               drivername, PCIDEV_NAME(pdev));
31968  
31969         if ( !pci_resource_start(pdev,0)
31970              || !(pci_resource_flags(pdev,0) & IORESOURCE_IO) ) {
31971 -               printk(KERN_ERR "%s: bar 0 invalid", __FUNCTION__);
31972 +               ERROR("%s: bar 0 invalid", __FUNCTION__);
31973                 goto out_disable;
31974         }
31975  
31976 @@ -1784,8 +1769,7 @@
31977  
31978         ndev = (struct net_device *) kmalloc (alloc_size, GFP_KERNEL);
31979         if (ndev==NULL) {
31980 -               printk(KERN_ERR "%s: Unable to allocate device memory.\n",
31981 -                       __FUNCTION__);
31982 +               ERROR("%s: Unable to allocate device memory.\n", __FUNCTION__);
31983                 goto out_disable;
31984         }
31985  
31986 @@ -1801,37 +1785,33 @@
31987         ndev->init = vlsi_irda_init;
31988         strcpy(ndev->name,"irda%d");
31989         if (register_netdev(ndev)) {
31990 -               printk(KERN_ERR "%s: register_netdev failed\n",
31991 -                       __FUNCTION__);
31992 +               ERROR("%s: register_netdev failed\n", __FUNCTION__);
31993                 goto out_freedev;
31994         }
31995  
31996 +       idev->proc_entry = NULL;
31997         if (vlsi_proc_root != NULL) {
31998                 struct proc_dir_entry *ent;
31999  
32000                 ent = create_proc_entry(ndev->name, S_IFREG|S_IRUGO, vlsi_proc_root);
32001                 if (!ent) {
32002 -                       printk(KERN_ERR "%s: failed to create proc entry\n", __FUNCTION__);
32003 -                       goto out_unregister;
32004 +                       WARNING("%s: failed to create proc entry\n", __FUNCTION__);
32005 +                       idev->proc_entry = NULL;
32006                 }
32007 -               ent->data = ndev;
32008 -               ent->proc_fops = VLSI_PROC_FOPS;
32009 -               ent->size = 0;
32010 -               idev->proc_entry = ent;
32011 -       } else
32012 -               idev->proc_entry = NULL;
32013 -
32014 -       printk(KERN_INFO "%s: registered device %s\n", drivername, ndev->name);
32015 +               else {
32016 +                       ent->data = ndev;
32017 +                       ent->proc_fops = VLSI_PROC_FOPS;
32018 +                       ent->size = 0;
32019 +                       idev->proc_entry = ent;
32020 +               }
32021 +       }
32022 +       MESSAGE("%s: registered device %s\n", drivername, ndev->name);
32023  
32024         pci_set_drvdata(pdev, ndev);
32025         up(&idev->sem);
32026  
32027         return 0;
32028  
32029 -out_unregister:
32030 -       up(&idev->sem);
32031 -       unregister_netdev(ndev);
32032 -       goto out_disable;
32033  out_freedev:
32034         up(&idev->sem);
32035         kfree(ndev);
32036 @@ -1848,14 +1828,12 @@
32037         vlsi_irda_dev_t *idev;
32038  
32039         if (!ndev) {
32040 -               printk(KERN_CRIT "%s: lost netdevice?\n", drivername);
32041 +               ERROR("%s: lost netdevice?\n", drivername);
32042                 return;
32043         }
32044  
32045         idev = ndev->priv;
32046         down(&idev->sem);
32047 -       pci_set_drvdata(pdev, NULL);
32048 -       pci_disable_device(pdev);
32049         if (idev->proc_entry) {
32050                 remove_proc_entry(ndev->name, vlsi_proc_root);
32051                 idev->proc_entry = NULL;
32052 @@ -1867,7 +1845,9 @@
32053          * ndev->destructor called (if present) when going to free
32054          */
32055  
32056 -       printk(KERN_INFO "%s: %s removed\n", drivername, pci_name(pdev));
32057 +       pci_set_drvdata(pdev, NULL);
32058 +
32059 +       MESSAGE("%s: %s removed\n", drivername, PCIDEV_NAME(pdev));
32060  }
32061  
32062  #ifdef CONFIG_PM
32063 @@ -1882,8 +1862,8 @@
32064  static int vlsi_irda_save_state(struct pci_dev *pdev, u32 state)
32065  {
32066         if (state < 1 || state > 3 ) {
32067 -               printk( KERN_ERR "%s - %s: invalid pm state request: %u\n",
32068 -                       __FUNCTION__, pci_name(pdev), state);
32069 +               ERROR("%s - %s: invalid pm state request: %u\n",
32070 +                       __FUNCTION__, PCIDEV_NAME(pdev), state);
32071                 return -1;
32072         }
32073         return 0;
32074 @@ -1895,12 +1875,12 @@
32075         vlsi_irda_dev_t *idev;
32076  
32077         if (state < 1 || state > 3 ) {
32078 -               printk( KERN_ERR "%s - %s: invalid pm state request: %u\n",
32079 -                       __FUNCTION__, pci_name(pdev), state);
32080 +               ERROR("%s - %s: invalid pm state request: %u\n",
32081 +                       __FUNCTION__, PCIDEV_NAME(pdev), state);
32082                 return 0;
32083         }
32084         if (!ndev) {
32085 -               printk(KERN_ERR "%s - %s: no netdevice \n", __FUNCTION__, pci_name(pdev));
32086 +               ERROR("%s - %s: no netdevice \n", __FUNCTION__, PCIDEV_NAME(pdev));
32087                 return 0;
32088         }
32089         idev = ndev->priv;      
32090 @@ -1911,8 +1891,8 @@
32091                         pdev->current_state = state;
32092                 }
32093                 else
32094 -                       printk(KERN_ERR "%s - %s: invalid suspend request %u -> %u\n",
32095 -                               __FUNCTION__, pci_name(pdev), pdev->current_state, state);
32096 +                       ERROR("%s - %s: invalid suspend request %u -> %u\n",
32097 +                               __FUNCTION__, PCIDEV_NAME(pdev), pdev->current_state, state);
32098                 up(&idev->sem);
32099                 return 0;
32100         }
32101 @@ -1939,14 +1919,14 @@
32102         vlsi_irda_dev_t *idev;
32103  
32104         if (!ndev) {
32105 -               printk(KERN_ERR "%s - %s: no netdevice \n", __FUNCTION__, pci_name(pdev));
32106 +               ERROR("%s - %s: no netdevice \n", __FUNCTION__, PCIDEV_NAME(pdev));
32107                 return 0;
32108         }
32109         idev = ndev->priv;      
32110         down(&idev->sem);
32111         if (pdev->current_state == 0) {
32112                 up(&idev->sem);
32113 -               printk(KERN_ERR "%s - %s: already resumed\n", __FUNCTION__, pci_name(pdev));
32114 +               WARNING("%s - %s: already resumed\n", __FUNCTION__, PCIDEV_NAME(pdev));
32115                 return 0;
32116         }
32117         
32118 @@ -1965,7 +1945,7 @@
32119                  * now we explicitly set pdev->current_state = 0 after enabling the
32120                  * device and independently resume_ok should catch any garbage config.
32121                  */
32122 -               printk(KERN_ERR "%s - hm, nothing to resume?\n", __FUNCTION__);
32123 +               WARNING("%s - hm, nothing to resume?\n", __FUNCTION__);
32124                 up(&idev->sem);
32125                 return 0;
32126         }
32127 @@ -2003,7 +1983,7 @@
32128         int     i, ret;
32129  
32130         if (clksrc < 0  ||  clksrc > 3) {
32131 -               printk(KERN_ERR "%s: invalid clksrc=%d\n", drivername, clksrc);
32132 +               ERROR("%s: invalid clksrc=%d\n", drivername, clksrc);
32133                 return -1;
32134         }
32135  
32136 @@ -2016,9 +1996,8 @@
32137                         case 64:
32138                                 break;
32139                         default:
32140 -                               printk(KERN_WARNING "%s: invalid %s ringsize %d",
32141 +                               WARNING("%s: invalid %s ringsize %d, using default=8",
32142                                         drivername, (i)?"rx":"tx", ringsize[i]);
32143 -                               printk(", using default=8\n");
32144                                 ringsize[i] = 8;
32145                                 break;
32146                 }
32147 diff -Nru a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
32148 --- a/drivers/net/ixgb/ixgb_main.c      Tue Aug 19 20:53:16 2003
32149 +++ b/drivers/net/ixgb/ixgb_main.c      Sun Aug 31 08:08:53 2003
32150 @@ -1914,10 +1914,8 @@
32151                 skb->protocol = eth_type_trans(skb, netdev);
32152                 if (adapter->vlgrp
32153                     && (rx_desc->status & IXGB_RX_DESC_STATUS_VP)) {
32154 -                       vlan_hwaccel_rx(skb, adapter->vlgrp,
32155 -                                       (rx_desc->
32156 -                                        special &
32157 -                                        IXGB_RX_DESC_SPECIAL_VLAN_MASK));
32158 +                       vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
32159 +                               (rx_desc-> special & IXGB_RX_DESC_SPECIAL_VLAN_MASK));
32160                 } else {
32161                         netif_receive_skb(skb);
32162                 }
32163 diff -Nru a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
32164 --- a/drivers/net/ne2k-pci.c    Tue Aug 19 20:53:16 2003
32165 +++ b/drivers/net/ne2k-pci.c    Mon Sep  1 10:03:04 2003
32166 @@ -174,7 +174,7 @@
32167                           struct sk_buff *skb, int ring_offset);
32168  static void ne2k_pci_block_output(struct net_device *dev, const int count,
32169                 const unsigned char *buf, const int start_page);
32170 -static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
32171 +static struct ethtool_ops ne2k_pci_ethtool_ops;
32172  
32173  \f
32174  
32175 @@ -259,7 +259,8 @@
32176                 }
32177         }
32178  
32179 -       dev = alloc_etherdev(0);
32180 +       /* Allocate net_device, dev->priv; fill in 8390 specific dev fields. */
32181 +       dev = alloc_ei_netdev();
32182         if (!dev) {
32183                 printk (KERN_ERR PFX "cannot allocate ethernet device\n");
32184                 goto err_out_free_res;
32185 @@ -331,13 +332,6 @@
32186         dev->base_addr = ioaddr;
32187         pci_set_drvdata(pdev, dev);
32188  
32189 -       /* Allocate dev->priv and fill in 8390 specific dev fields. */
32190 -       if (ethdev_init(dev)) {
32191 -               printk (KERN_ERR "ne2kpci(%s): unable to get memory for dev->priv.\n",
32192 -                       pci_name(pdev));
32193 -               goto err_out_free_netdev;
32194 -       }
32195 -
32196         ei_status.name = pci_clone_list[chip_idx].name;
32197         ei_status.tx_start_page = start_page;
32198         ei_status.stop_page = stop_page;
32199 @@ -361,12 +355,12 @@
32200         ei_status.priv = (unsigned long) pdev;
32201         dev->open = &ne2k_pci_open;
32202         dev->stop = &ne2k_pci_close;
32203 -       dev->do_ioctl = &netdev_ioctl;
32204 +       dev->ethtool_ops = &ne2k_pci_ethtool_ops;
32205         NS8390_init(dev, 0);
32206  
32207         i = register_netdev(dev);
32208         if (i)
32209 -               goto err_out_free_8390;
32210 +               goto err_out_free_netdev;
32211  
32212         printk("%s: %s found at %#lx, IRQ %d, ",
32213                    dev->name, pci_clone_list[chip_idx].name, ioaddr, dev->irq);
32214 @@ -377,10 +371,8 @@
32215  
32216         return 0;
32217  
32218 -err_out_free_8390:
32219 -       kfree(dev->priv);
32220  err_out_free_netdev:
32221 -       kfree (dev);
32222 +       free_netdev (dev);
32223  err_out_free_res:
32224         release_region (ioaddr, NE_IO_EXTENT);
32225         pci_set_drvdata (pdev, NULL);
32226 @@ -591,41 +583,23 @@
32227         return;
32228  }
32229  
32230 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
32231 +static void ne2k_pci_get_drvinfo(struct net_device *dev,
32232 +                                struct ethtool_drvinfo *info)
32233  {
32234         struct ei_device *ei = dev->priv;
32235         struct pci_dev *pci_dev = (struct pci_dev *) ei->priv;
32236 -       u32 ethcmd;
32237 -               
32238 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
32239 -               return -EFAULT;
32240 -
32241 -        switch (ethcmd) {
32242 -        case ETHTOOL_GDRVINFO: {
32243 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
32244 -               strcpy(info.driver, DRV_NAME);
32245 -               strcpy(info.version, DRV_VERSION);
32246 -               strcpy(info.bus_info, pci_name(pci_dev));
32247 -               if (copy_to_user(useraddr, &info, sizeof(info)))
32248 -                       return -EFAULT;
32249 -               return 0;
32250 -       }
32251 -
32252 -        }
32253 -       
32254 -       return -EOPNOTSUPP;
32255 -}
32256  
32257 -static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
32258 -{
32259 -       switch(cmd) {
32260 -       case SIOCETHTOOL:
32261 -               return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
32262 -       default:
32263 -               return -EOPNOTSUPP;
32264 -       }
32265 +       strcpy(info->driver, DRV_NAME);
32266 +       strcpy(info->version, DRV_VERSION);
32267 +       strcpy(info->bus_info, pci_name(pci_dev));
32268  }
32269  
32270 +static struct ethtool_ops ne2k_pci_ethtool_ops = {
32271 +       .get_drvinfo            = ne2k_pci_get_drvinfo,
32272 +       .get_tx_csum            = ethtool_op_get_tx_csum,
32273 +       .get_sg                 = ethtool_op_get_sg,
32274 +};
32275 +
32276  static void __devexit ne2k_pci_remove_one (struct pci_dev *pdev)
32277  {
32278         struct net_device *dev = pci_get_drvdata(pdev);
32279 @@ -635,8 +609,8 @@
32280  
32281         unregister_netdev(dev);
32282         release_region(dev->base_addr, NE_IO_EXTENT);
32283 -       kfree(dev->priv);
32284         free_netdev(dev);
32285 +       pci_disable_device(pdev);
32286         pci_set_drvdata(pdev, NULL);
32287  }
32288  
32289 diff -Nru a/drivers/net/ni5010.c b/drivers/net/ni5010.c
32290 --- a/drivers/net/ni5010.c      Sun Apr 20 23:00:41 2003
32291 +++ b/drivers/net/ni5010.c      Sun Aug 31 16:14:15 2003
32292 @@ -96,6 +96,7 @@
32293         struct net_device_stats stats;
32294         int o_pkt_size;
32295         int i_pkt_size;
32296 +       spinlock_t lock;
32297  };
32298  
32299  /* Index to functions, as function prototypes. */
32300 @@ -280,11 +281,16 @@
32301         /* DMA is not supported (yet?), so no use detecting it */
32302  
32303         if (dev->priv == NULL) {
32304 +               struct ni5010_local* lp;
32305 +
32306                 dev->priv = kmalloc(sizeof(struct ni5010_local), GFP_KERNEL|GFP_DMA);
32307                 if (dev->priv == NULL) {
32308                         printk(KERN_WARNING "%s: Failed to allocate private memory\n", dev->name);
32309                         return -ENOMEM;
32310                 }
32311 +
32312 +               lp = (struct ni5010_local*)dev->priv;
32313 +               spin_lock_init(&lp->lock);
32314         }
32315  
32316         PRINTK2((KERN_DEBUG "%s: I/O #10 passed!\n", dev->name));
32317 @@ -463,6 +469,7 @@
32318         ioaddr = dev->base_addr;
32319         lp = (struct ni5010_local *)dev->priv;
32320         
32321 +       spin_lock(&lp->lock);
32322         status = inb(IE_ISTAT); 
32323         PRINTK3((KERN_DEBUG "%s: IE_ISTAT = %#02x\n", dev->name, status));
32324                 
32325 @@ -479,6 +486,7 @@
32326  
32327         if (!xmit_was_error) 
32328                 reset_receiver(dev); 
32329 +       spin_unlock(&lp->lock);
32330         return IRQ_HANDLED;
32331  }
32332  
32333 @@ -693,8 +701,7 @@
32334          buf_offs = NI5010_BUFSIZE - length - pad;
32335          lp->o_pkt_size = length + pad;
32336  
32337 -       save_flags(flags);      
32338 -       cli();
32339 +       spin_lock_irqsave(&lp->lock, flags);
32340  
32341         outb(0, EDLC_RMASK);    /* Mask all receive interrupts */
32342         outb(0, IE_MMODE);      /* Put Xmit buffer on system bus */
32343 @@ -712,7 +719,7 @@
32344         outb(MM_EN_XMT | MM_MUX, IE_MMODE); /* Begin transmission */
32345         outb(XM_ALL, EDLC_XMASK); /* Cause interrupt after completion or fail */
32346  
32347 -       restore_flags(flags);
32348 +       spin_unlock_irqrestore(&lp->lock, flags);
32349  
32350         netif_wake_queue(dev);
32351         
32352 diff -Nru a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
32353 --- a/drivers/net/pcmcia/3c574_cs.c     Tue Aug 19 20:55:09 2003
32354 +++ b/drivers/net/pcmcia/3c574_cs.c     Sun Aug 31 05:20:57 2003
32355 @@ -253,6 +253,7 @@
32356  static int el3_close(struct net_device *dev);
32357  static void el3_tx_timeout(struct net_device *dev);
32358  static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
32359 +static struct ethtool_ops netdev_ethtool_ops;
32360  static void set_rx_mode(struct net_device *dev);
32361  
32362  static dev_info_t dev_info = "3c574_cs";
32363 @@ -319,6 +320,7 @@
32364         dev->hard_start_xmit = &el3_start_xmit;
32365         dev->get_stats = &el3_get_stats;
32366         dev->do_ioctl = &el3_ioctl;
32367 +       SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
32368         dev->set_multicast_list = &set_rx_mode;
32369         dev->open = &el3_open;
32370         dev->stop = &el3_close;
32371 @@ -1202,26 +1204,16 @@
32372         return worklimit;
32373  }
32374  
32375 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
32376 +static void netdev_get_drvinfo(struct net_device *dev,
32377 +                              struct ethtool_drvinfo *info)
32378  {
32379 -       u32 ethcmd;
32380 -               
32381 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
32382 -               return -EFAULT;
32383 -       
32384 -       switch (ethcmd) {
32385 -       case ETHTOOL_GDRVINFO: {
32386 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
32387 -               strncpy(info.driver, "3c574_cs", sizeof(info.driver)-1);
32388 -               if (copy_to_user(useraddr, &info, sizeof(info)))
32389 -                       return -EFAULT;
32390 -               return 0;
32391 -       }
32392 -       }
32393 -       
32394 -       return -EOPNOTSUPP;
32395 +       strcpy(info->driver, "3c574_cs");
32396  }
32397  
32398 +static struct ethtool_ops netdev_ethtool_ops = {
32399 +       .get_drvinfo            = netdev_get_drvinfo,
32400 +};
32401 +
32402  /* Provide ioctl() calls to examine the MII xcvr state. */
32403  static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
32404  {
32405 @@ -1235,11 +1227,9 @@
32406                   data[0], data[1], data[2], data[3]);
32407  
32408         switch(cmd) {
32409 -       case SIOCETHTOOL:
32410 -               return netdev_ethtool_ioctl(dev, (void *)rq->ifr_data);
32411 -       case SIOCDEVPRIVATE:            /* Get the address of the PHY in use. */
32412 +       case SIOCGMIIPHY:               /* Get the address of the PHY in use. */
32413                 data[0] = phy;
32414 -       case SIOCDEVPRIVATE+1:          /* Read the specified MII register. */
32415 +       case SIOCGMIIREG:               /* Read the specified MII register. */
32416                 {
32417                         int saved_window;
32418                         unsigned long flags;
32419 @@ -1252,7 +1242,7 @@
32420                         spin_unlock_irqrestore(&lp->window_lock, flags);
32421                         return 0;
32422                 }
32423 -       case SIOCDEVPRIVATE+2:          /* Write the specified MII register */
32424 +       case SIOCSMIIREG:               /* Write the specified MII register */
32425                 {
32426                         int saved_window;
32427                         unsigned long flags;
32428 diff -Nru a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
32429 --- a/drivers/net/pcmcia/3c589_cs.c     Tue Aug 19 20:55:09 2003
32430 +++ b/drivers/net/pcmcia/3c589_cs.c     Tue Aug 26 14:27:07 2003
32431 @@ -165,7 +165,7 @@
32432  static int el3_close(struct net_device *dev);
32433  static void el3_tx_timeout(struct net_device *dev);
32434  static void set_multicast_list(struct net_device *dev);
32435 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
32436 +static struct ethtool_ops netdev_ethtool_ops;
32437  
32438  static dev_info_t dev_info = "3c589_cs";
32439  
32440 @@ -249,7 +249,7 @@
32441      dev->tx_timeout = el3_tx_timeout;
32442      dev->watchdog_timeo = TX_TIMEOUT;
32443  #endif
32444 -    dev->do_ioctl = netdev_ioctl;
32445 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
32446  
32447      /* Register with Card Services */
32448      link->next = dev_list;
32449 @@ -639,70 +639,33 @@
32450          | AdapterFailure, ioaddr + EL3_CMD);
32451  }
32452  
32453 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
32454 +static void netdev_get_drvinfo(struct net_device *dev,
32455 +                              struct ethtool_drvinfo *info)
32456  {
32457 -       u32 ethcmd;
32458 -
32459 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
32460 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
32461 -
32462 -       if (get_user(ethcmd, (u32 *)useraddr))
32463 -               return -EFAULT;
32464 -
32465 -       switch (ethcmd) {
32466 -
32467 -       case ETHTOOL_GDRVINFO: {
32468 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
32469 -               strcpy (info.driver, DRV_NAME);
32470 -               strcpy (info.version, DRV_VERSION);
32471 -               sprintf(info.bus_info, "PCMCIA 0x%lx", dev->base_addr);
32472 -               if (copy_to_user (useraddr, &info, sizeof (info)))
32473 -                       return -EFAULT;
32474 -               return 0;
32475 -       }
32476 +       strcpy(info->driver, DRV_NAME);
32477 +       strcpy(info->version, DRV_VERSION);
32478 +       sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr);
32479 +}
32480  
32481  #ifdef PCMCIA_DEBUG
32482 -       /* get message-level */
32483 -       case ETHTOOL_GMSGLVL: {
32484 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
32485 -               edata.data = pc_debug;
32486 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
32487 -                       return -EFAULT;
32488 -               return 0;
32489 -       }
32490 -       /* set message-level */
32491 -       case ETHTOOL_SMSGLVL: {
32492 -               struct ethtool_value edata;
32493 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
32494 -                       return -EFAULT;
32495 -               pc_debug = edata.data;
32496 -               return 0;
32497 -       }
32498 -#endif
32499 -
32500 -       default:
32501 -               break;
32502 -       }
32503 -
32504 -       return -EOPNOTSUPP;
32505 +static u32 netdev_get_msglevel(struct net_device *dev)
32506 +{
32507 +       return pc_debug;
32508  }
32509  
32510 -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
32511 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
32512  {
32513 -       int rc;
32514 -
32515 -       switch (cmd) {
32516 -       case SIOCETHTOOL:
32517 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
32518 -               break;
32519 -
32520 -       default:
32521 -               rc = -EOPNOTSUPP;
32522 -               break;
32523 -       }
32524 -
32525 -       return rc;
32526 +       pc_debug = level;
32527  }
32528 +#endif /* PCMCIA_DEBUG */
32529 +
32530 +static struct ethtool_ops netdev_ethtool_ops = {
32531 +       .get_drvinfo            = netdev_get_drvinfo,
32532 +#ifdef PCMCIA_DEBUG
32533 +       .get_msglevel           = netdev_get_msglevel,
32534 +       .set_msglevel           = netdev_set_msglevel,
32535 +#endif /* PCMCIA_DEBUG */
32536 +};
32537  
32538  static int el3_config(struct net_device *dev, struct ifmap *map)
32539  {
32540 diff -Nru a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
32541 --- a/drivers/net/pcmcia/axnet_cs.c     Tue Aug 19 20:55:09 2003
32542 +++ b/drivers/net/pcmcia/axnet_cs.c     Sun Aug 31 05:20:58 2003
32543 @@ -98,6 +98,7 @@
32544  static int axnet_open(struct net_device *dev);
32545  static int axnet_close(struct net_device *dev);
32546  static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
32547 +static struct ethtool_ops netdev_ethtool_ops;
32548  static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs);
32549  static void ei_watchdog(u_long arg);
32550  static void axnet_reset_8390(struct net_device *dev);
32551 @@ -209,6 +210,7 @@
32552      dev->open = &axnet_open;
32553      dev->stop = &axnet_close;
32554      dev->do_ioctl = &axnet_ioctl;
32555 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
32556  
32557      /* Register with Card Services */
32558      link->next = dev_list;
32559 @@ -807,26 +809,16 @@
32560      add_timer(&info->watchdog);
32561  }
32562  
32563 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
32564 +static void netdev_get_drvinfo(struct net_device *dev,
32565 +                              struct ethtool_drvinfo *info)
32566  {
32567 -       u32 ethcmd;
32568 -               
32569 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
32570 -               return -EFAULT;
32571 -       
32572 -       switch (ethcmd) {
32573 -       case ETHTOOL_GDRVINFO: {
32574 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
32575 -               strncpy(info.driver, "axnet_cs", sizeof(info.driver)-1);
32576 -               if (copy_to_user(useraddr, &info, sizeof(info)))
32577 -                       return -EFAULT;
32578 -               return 0;
32579 -       }
32580 -       }
32581 -       
32582 -       return -EOPNOTSUPP;
32583 +       strcpy(info->driver, "axnet_cs");
32584  }
32585  
32586 +static struct ethtool_ops netdev_ethtool_ops = {
32587 +       .get_drvinfo            = netdev_get_drvinfo,
32588 +};
32589 +
32590  /*====================================================================*/
32591  
32592  static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
32593 @@ -835,14 +827,12 @@
32594      u16 *data = (u16 *)&rq->ifr_data;
32595      ioaddr_t mii_addr = dev->base_addr + AXNET_MII_EEP;
32596      switch (cmd) {
32597 -    case SIOCETHTOOL:
32598 -        return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
32599 -    case SIOCDEVPRIVATE:
32600 +    case SIOCGMIIPHY:
32601         data[0] = info->phy_id;
32602 -    case SIOCDEVPRIVATE+1:
32603 +    case SIOCGMIIREG:          /* Read MII PHY register. */
32604         data[3] = mdio_read(mii_addr, data[0], data[1] & 0x1f);
32605         return 0;
32606 -    case SIOCDEVPRIVATE+2:
32607 +    case SIOCSMIIREG:          /* Write MII PHY register. */
32608         if (!capable(CAP_NET_ADMIN))
32609             return -EPERM;
32610         mdio_write(mii_addr, data[0], data[1] & 0x1f, data[2]);
32611 diff -Nru a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
32612 --- a/drivers/net/pcmcia/fmvj18x_cs.c   Tue Aug 19 20:55:09 2003
32613 +++ b/drivers/net/pcmcia/fmvj18x_cs.c   Tue Aug 26 14:51:25 2003
32614 @@ -113,7 +113,7 @@
32615  static struct net_device_stats *fjn_get_stats(struct net_device *dev);
32616  static void set_rx_mode(struct net_device *dev);
32617  static void fjn_tx_timeout(struct net_device *dev);
32618 -static int fjn_ioctl(struct net_device *, struct ifreq *, int);
32619 +static struct ethtool_ops netdev_ethtool_ops;
32620  
32621  static dev_info_t dev_info = "fmvj18x_cs";
32622  static dev_link_t *dev_list;
32623 @@ -312,7 +312,7 @@
32624      dev->tx_timeout = fjn_tx_timeout;
32625      dev->watchdog_timeo = TX_TIMEOUT;
32626  #endif
32627 -    dev->do_ioctl = fjn_ioctl;
32628 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
32629      
32630      /* Register with Card Services */
32631      link->next = dev_list;
32632 @@ -1186,64 +1186,33 @@
32633  
32634  /*====================================================================*/
32635  
32636 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
32637 +static void netdev_get_drvinfo(struct net_device *dev,
32638 +                              struct ethtool_drvinfo *info)
32639  {
32640 -       u32 ethcmd;
32641 -
32642 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
32643 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
32644 -
32645 -       if (get_user(ethcmd, (u32 *)useraddr))
32646 -               return -EFAULT;
32647 -
32648 -       switch (ethcmd) {
32649 -
32650 -       case ETHTOOL_GDRVINFO: {
32651 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
32652 -               strcpy (info.driver, DRV_NAME);
32653 -               strcpy (info.version, DRV_VERSION);
32654 -               sprintf(info.bus_info, "PCMCIA 0x%lx", dev->base_addr);
32655 -               if (copy_to_user (useraddr, &info, sizeof (info)))
32656 -                       return -EFAULT;
32657 -               return 0;
32658 -       }
32659 +       strcpy(info->driver, DRV_NAME);
32660 +       strcpy(info->version, DRV_VERSION);
32661 +       sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr);
32662 +}
32663  
32664  #ifdef PCMCIA_DEBUG
32665 -       /* get message-level */
32666 -       case ETHTOOL_GMSGLVL: {
32667 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
32668 -               edata.data = pc_debug;
32669 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
32670 -                       return -EFAULT;
32671 -               return 0;
32672 -       }
32673 -       /* set message-level */
32674 -       case ETHTOOL_SMSGLVL: {
32675 -               struct ethtool_value edata;
32676 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
32677 -                       return -EFAULT;
32678 -               pc_debug = edata.data;
32679 -               return 0;
32680 -       }
32681 -#endif
32682 -
32683 -       default:
32684 -               break;
32685 -       }
32686 -
32687 -       return -EOPNOTSUPP;
32688 +static u32 netdev_get_msglevel(struct net_device *dev)
32689 +{
32690 +       return pc_debug;
32691  }
32692  
32693 -static int fjn_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
32694 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
32695  {
32696 -       switch (cmd) {
32697 -       case SIOCETHTOOL:
32698 -               return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
32699 -
32700 -       default:
32701 -               return -EOPNOTSUPP;
32702 -       }
32703 +       pc_debug = level;
32704  }
32705 +#endif /* PCMCIA_DEBUG */
32706 +
32707 +static struct ethtool_ops netdev_ethtool_ops = {
32708 +       .get_drvinfo            = netdev_get_drvinfo,
32709 +#ifdef PCMCIA_DEBUG
32710 +       .get_msglevel           = netdev_get_msglevel,
32711 +       .set_msglevel           = netdev_set_msglevel,
32712 +#endif /* PCMCIA_DEBUG */
32713 +};
32714  
32715  static int fjn_config(struct net_device *dev, struct ifmap *map){
32716      return 0;
32717 diff -Nru a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
32718 --- a/drivers/net/pcmcia/ibmtr_cs.c     Tue Aug 19 20:55:09 2003
32719 +++ b/drivers/net/pcmcia/ibmtr_cs.c     Tue Aug 26 14:51:25 2003
32720 @@ -157,36 +157,15 @@
32721      }
32722  }
32723  
32724 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
32725 +static void netdev_get_drvinfo(struct net_device *dev,
32726 +                              struct ethtool_drvinfo *info)
32727  {
32728 -       u32 ethcmd;
32729 -               
32730 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
32731 -               return -EFAULT;
32732 -       
32733 -       switch (ethcmd) {
32734 -       case ETHTOOL_GDRVINFO: {
32735 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
32736 -               strncpy(info.driver, "ibmtr_cs", sizeof(info.driver)-1);
32737 -               if (copy_to_user(useraddr, &info, sizeof(info)))
32738 -                       return -EFAULT;
32739 -               return 0;
32740 -       }
32741 -       }
32742 -       
32743 -       return -EOPNOTSUPP;
32744 +       strcpy(info->driver, "ibmtr_cs");
32745  }
32746  
32747 -static int private_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
32748 -{
32749 -
32750 -       switch(cmd) {
32751 -       case SIOCETHTOOL:
32752 -              return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
32753 -       default:
32754 -           return -EOPNOTSUPP;
32755 -       }
32756 -}
32757 +static struct ethtool_ops netdev_ethtool_ops = {
32758 +       .get_drvinfo            = netdev_get_drvinfo,
32759 +};
32760  
32761  /*======================================================================
32762  
32763 @@ -235,7 +214,7 @@
32764      link->irq.Instance = info->dev = dev;
32765      
32766      dev->init = &ibmtr_probe;
32767 -    dev->do_ioctl = &private_ioctl;
32768 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
32769  
32770      /* Register with Card Services */
32771      link->next = dev_list;
32772 diff -Nru a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
32773 --- a/drivers/net/pcmcia/nmclan_cs.c    Tue Aug 19 20:55:09 2003
32774 +++ b/drivers/net/pcmcia/nmclan_cs.c    Tue Aug 26 14:51:25 2003
32775 @@ -442,7 +442,8 @@
32776  static int mace_rx(struct net_device *dev, unsigned char RxCnt);
32777  static void restore_multicast_list(struct net_device *dev);
32778  static void set_multicast_list(struct net_device *dev);
32779 -static int mace_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
32780 +static struct ethtool_ops netdev_ethtool_ops;
32781 +
32782  
32783  static dev_link_t *nmclan_attach(void);
32784  static void nmclan_detach(dev_link_t *);
32785 @@ -515,7 +516,7 @@
32786      dev->set_config = &mace_config;
32787      dev->get_stats = &mace_get_stats;
32788      dev->set_multicast_list = &set_multicast_list;
32789 -    dev->do_ioctl = &mace_ioctl;
32790 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
32791      dev->open = &mace_open;
32792      dev->stop = &mace_close;
32793  #ifdef HAVE_TX_TIMEOUT
32794 @@ -1014,65 +1015,33 @@
32795    return 0;
32796  } /* mace_close */
32797  
32798 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
32799 +static void netdev_get_drvinfo(struct net_device *dev,
32800 +                              struct ethtool_drvinfo *info)
32801  {
32802 -       u32 ethcmd;
32803 -
32804 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
32805 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
32806 -
32807 -       if (get_user(ethcmd, (u32 *)useraddr))
32808 -               return -EFAULT;
32809 -
32810 -       switch (ethcmd) {
32811 -
32812 -       case ETHTOOL_GDRVINFO: {
32813 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
32814 -               strcpy (info.driver, DRV_NAME);
32815 -               strcpy (info.version, DRV_VERSION);
32816 -               sprintf(info.bus_info, "PCMCIA 0x%lx", dev->base_addr);
32817 -               if (copy_to_user (useraddr, &info, sizeof (info)))
32818 -                       return -EFAULT;
32819 -               return 0;
32820 -       }
32821 +       strcpy(info->driver, DRV_NAME);
32822 +       strcpy(info->version, DRV_VERSION);
32823 +       sprintf(info->bus_info, "PCMCIA 0x%lx", dev->base_addr);
32824 +}
32825  
32826  #ifdef PCMCIA_DEBUG
32827 -       /* get message-level */
32828 -       case ETHTOOL_GMSGLVL: {
32829 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
32830 -               edata.data = pc_debug;
32831 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
32832 -                       return -EFAULT;
32833 -               return 0;
32834 -       }
32835 -       /* set message-level */
32836 -       case ETHTOOL_SMSGLVL: {
32837 -               struct ethtool_value edata;
32838 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
32839 -                       return -EFAULT;
32840 -               pc_debug = edata.data;
32841 -               return 0;
32842 -       }
32843 -#endif
32844 -
32845 -       default:
32846 -               break;
32847 -       }
32848 -
32849 -       return -EOPNOTSUPP;
32850 +static u32 netdev_get_msglevel(struct net_device *dev)
32851 +{
32852 +       return pc_debug;
32853  }
32854  
32855 -static int mace_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
32856 +static void netdev_set_msglevel(struct net_device *dev, u32 level)
32857  {
32858 -       switch (cmd) {
32859 -       case SIOCETHTOOL:
32860 -               return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
32861 -
32862 -       default:
32863 -               return -EOPNOTSUPP;
32864 -       }
32865 -       return 0;
32866 +       pc_debug = level;
32867  }
32868 +#endif /* PCMCIA_DEBUG */
32869 +
32870 +static struct ethtool_ops netdev_ethtool_ops = {
32871 +       .get_drvinfo            = netdev_get_drvinfo,
32872 +#ifdef PCMCIA_DEBUG
32873 +       .get_msglevel           = netdev_get_msglevel,
32874 +       .set_msglevel           = netdev_set_msglevel,
32875 +#endif /* PCMCIA_DEBUG */
32876 +};
32877  
32878  /* ----------------------------------------------------------------------------
32879  mace_start_xmit
32880 diff -Nru a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
32881 --- a/drivers/net/pcmcia/pcnet_cs.c     Tue Aug 19 20:55:09 2003
32882 +++ b/drivers/net/pcmcia/pcnet_cs.c     Sun Aug 31 05:20:58 2003
32883 @@ -116,7 +116,7 @@
32884  static int pcnet_open(struct net_device *dev);
32885  static int pcnet_close(struct net_device *dev);
32886  static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
32887 -static int do_ioctl_light(struct net_device *dev, struct ifreq *rq, int cmd);
32888 +static struct ethtool_ops netdev_ethtool_ops;
32889  static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs);
32890  static void ei_watchdog(u_long arg);
32891  static void pcnet_reset_8390(struct net_device *dev);
32892 @@ -756,6 +756,7 @@
32893  
32894      strcpy(info->node.dev_name, dev->name);
32895      link->dev = &info->node;
32896 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
32897  
32898      if (info->flags & (IS_DL10019|IS_DL10022)) {
32899         u_char id = inb(dev->base_addr + 0x1a);
32900 @@ -769,7 +770,6 @@
32901             printk("PNA, ");
32902      } else {
32903         printk(KERN_INFO "%s: NE2000 Compatible: ", dev->name);
32904 -       dev->do_ioctl = &do_ioctl_light;        
32905      }
32906      printk("io %#3lx, irq %d,", dev->base_addr, dev->irq);
32907      if (info->flags & USE_SHMEM)
32908 @@ -1205,26 +1205,16 @@
32909  
32910  /*====================================================================*/
32911  
32912 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
32913 +static void netdev_get_drvinfo(struct net_device *dev,
32914 +                              struct ethtool_drvinfo *info)
32915  {
32916 -       u32 ethcmd;
32917 -       
32918 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
32919 -               return -EFAULT;
32920 -       
32921 -       switch (ethcmd) {
32922 -       case ETHTOOL_GDRVINFO: {
32923 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
32924 -               strncpy(info.driver, "pcnet_cs", sizeof(info.driver)-1);
32925 -               if (copy_to_user(useraddr, &info, sizeof(info)))
32926 -                       return -EFAULT;
32927 -               return 0;
32928 -       }
32929 -       }
32930 -       
32931 -       return -EOPNOTSUPP;
32932 +       strcpy(info->driver, "pcnet_cs");
32933  }
32934  
32935 +static struct ethtool_ops netdev_ethtool_ops = {
32936 +       .get_drvinfo            = netdev_get_drvinfo,
32937 +};
32938 +
32939  /*====================================================================*/
32940  
32941  
32942 @@ -1234,31 +1224,18 @@
32943      u16 *data = (u16 *)&rq->ifr_data;
32944      ioaddr_t mii_addr = dev->base_addr + DLINK_GPIO;
32945      switch (cmd) {
32946 -    case SIOCETHTOOL:
32947 -        return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
32948 -    case SIOCDEVPRIVATE:
32949 +    case SIOCGMIIPHY:
32950         data[0] = info->phy_id;
32951 -    case SIOCDEVPRIVATE+1:
32952 +    case SIOCGMIIREG:          /* Read MII PHY register. */
32953         data[3] = mdio_read(mii_addr, data[0], data[1] & 0x1f);
32954         return 0;
32955 -    case SIOCDEVPRIVATE+2:
32956 +    case SIOCSMIIREG:          /* Write MII PHY register. */
32957         if (!capable(CAP_NET_ADMIN))
32958             return -EPERM;
32959         mdio_write(mii_addr, data[0], data[1] & 0x1f, data[2]);
32960         return 0;
32961      }
32962      return -EOPNOTSUPP;
32963 -}
32964 -
32965 -/*====================================================================*/
32966 -
32967 -static int do_ioctl_light(struct net_device *dev, struct ifreq *rq, int cmd)
32968 -{
32969 -    switch (cmd) {
32970 -        case SIOCETHTOOL:
32971 -            return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
32972 -    }      
32973 -    return -EOPNOTSUPP;    
32974  }
32975  
32976  /*====================================================================*/
32977 diff -Nru a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
32978 --- a/drivers/net/pcmcia/xirc2ps_cs.c   Tue Aug 19 20:55:09 2003
32979 +++ b/drivers/net/pcmcia/xirc2ps_cs.c   Sun Aug 31 05:20:58 2003
32980 @@ -382,6 +382,7 @@
32981  static int do_config(struct net_device *dev, struct ifmap *map);
32982  static int do_open(struct net_device *dev);
32983  static int do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
32984 +static struct ethtool_ops netdev_ethtool_ops;
32985  static void hardreset(struct net_device *dev);
32986  static void do_reset(struct net_device *dev, int full);
32987  static int init_mii(struct net_device *dev);
32988 @@ -626,6 +627,7 @@
32989      dev->set_config = &do_config;
32990      dev->get_stats = &do_get_stats;
32991      dev->do_ioctl = &do_ioctl;
32992 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
32993      dev->set_multicast_list = &set_multicast_list;
32994      dev->open = &do_open;
32995      dev->stop = &do_stop;
32996 @@ -1699,26 +1701,16 @@
32997      return 0;
32998  }
32999  
33000 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
33001 +static void netdev_get_drvinfo(struct net_device *dev,
33002 +                              struct ethtool_drvinfo *info)
33003  {
33004 -       u32 ethcmd;
33005 -               
33006 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
33007 -               return -EFAULT;
33008 -       
33009 -       switch (ethcmd) {
33010 -       case ETHTOOL_GDRVINFO: {
33011 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
33012 -               strncpy(info.driver, "xirc2ps_cs", sizeof(info.driver)-1);
33013 -               if (copy_to_user(useraddr, &info, sizeof(info)))
33014 -                       return -EFAULT;
33015 -               return 0;
33016 -       }
33017 -       }
33018 -       
33019 -       return -EOPNOTSUPP;
33020 +       strcpy(info->driver, "xirc2ps_cs");
33021  }
33022  
33023 +static struct ethtool_ops netdev_ethtool_ops = {
33024 +       .get_drvinfo            = netdev_get_drvinfo,
33025 +};
33026 +
33027  static int
33028  do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
33029  {
33030 @@ -1734,15 +1726,13 @@
33031         return -EOPNOTSUPP;
33032  
33033      switch(cmd) {
33034 -      case SIOCETHTOOL:
33035 -        return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
33036 -      case SIOCDEVPRIVATE:     /* Get the address of the PHY in use. */
33037 +      case SIOCGMIIPHY:                /* Get the address of the PHY in use. */
33038         data[0] = 0;            /* we have only this address */
33039         /* fall trough */
33040 -      case SIOCDEVPRIVATE+1:   /* Read the specified MII register. */
33041 +      case SIOCGMIIREG:                /* Read the specified MII register. */
33042         data[3] = mii_rd(ioaddr, data[0] & 0x1f, data[1] & 0x1f);
33043         break;
33044 -      case SIOCDEVPRIVATE+2:   /* Write the specified MII register */
33045 +      case SIOCSMIIREG:                /* Write the specified MII register */
33046         if (!capable(CAP_NET_ADMIN))
33047             return -EPERM;
33048         mii_wr(ioaddr, data[0] & 0x1f, data[1] & 0x1f, data[2], 16);
33049 diff -Nru a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
33050 --- a/drivers/net/pcnet32.c     Tue Aug 19 20:53:16 2003
33051 +++ b/drivers/net/pcnet32.c     Sun Aug 31 16:14:08 2003
33052 @@ -1726,6 +1726,7 @@
33053  /* An additional parameter that may be passed in... */
33054  static int debug = -1;
33055  static int tx_start_pt = -1;
33056 +static int pcnet32_have_pci;
33057  
33058  static int __init pcnet32_init_module(void)
33059  {
33060 @@ -1738,7 +1739,8 @@
33061         tx_start = tx_start_pt;
33062  
33063      /* find the PCI devices */
33064 -    pci_module_init(&pcnet32_driver);
33065 +    if (!pci_module_init(&pcnet32_driver))
33066 +       pcnet32_have_pci = 1;
33067  
33068      /* should we find any remaining VLbus devices ? */
33069      if (pcnet32vlb)
33070 @@ -1747,7 +1749,7 @@
33071      if (cards_found)
33072         printk(KERN_INFO PFX "%d cards_found.\n", cards_found);
33073      
33074 -    return cards_found ? 0 : -ENODEV;
33075 +    return (pcnet32_have_pci + cards_found) ? 0 : -ENODEV;
33076  }
33077  
33078  static void __exit pcnet32_cleanup_module(void)
33079 @@ -1765,6 +1767,9 @@
33080         free_netdev(pcnet32_dev);
33081         pcnet32_dev = next_dev;
33082      }
33083 +
33084 +    if (pcnet32_have_pci)
33085 +       pci_unregister_driver(&pcnet32_driver);
33086  }
33087  
33088  module_init(pcnet32_init_module);
33089 diff -Nru a/drivers/net/seeq8005.c b/drivers/net/seeq8005.c
33090 --- a/drivers/net/seeq8005.c    Thu Aug 21 00:05:02 2003
33091 +++ b/drivers/net/seeq8005.c    Sun Aug 31 06:34:16 2003
33092 @@ -378,7 +378,7 @@
33093  {
33094         struct net_local *lp = (struct net_local *)dev->priv;
33095         short length = skb->len;
33096 -       unsigned char *buf = skb->data;
33097 +       unsigned char *buf;
33098  
33099         if (length < ETH_ZLEN) {
33100                 skb = skb_padto(skb, ETH_ZLEN);
33101 @@ -386,6 +386,8 @@
33102                         return 0;
33103                 length = ETH_ZLEN;
33104         }
33105 +       buf = skb->data;
33106 +
33107         /* Block a timer-based transmit from overlapping */
33108         netif_stop_queue(dev);
33109         
33110 diff -Nru a/drivers/net/sis190.c b/drivers/net/sis190.c
33111 --- a/drivers/net/sis190.c      Tue Aug 19 20:53:16 2003
33112 +++ b/drivers/net/sis190.c      Sun Aug 31 14:10:18 2003
33113 @@ -76,6 +76,8 @@
33114  
33115  #define NUM_TX_DESC    64      /* Number of Tx descriptor registers */
33116  #define NUM_RX_DESC    64      /* Number of Rx descriptor registers */
33117 +#define TX_DESC_TOTAL_SIZE     (NUM_TX_DESC * sizeof (struct TxDesc))
33118 +#define RX_DESC_TOTAL_SIZE     (NUM_RX_DESC * sizeof (struct RxDesc))
33119  #define RX_BUF_SIZE    1536    /* Rx Buffer size */
33120  
33121  #define SiS190_MIN_IO_SIZE 0x80
33122 @@ -311,12 +313,8 @@
33123         unsigned long cur_rx;   /* Index into the Rx descriptor buffer of next Rx pkt. */
33124         unsigned long cur_tx;   /* Index into the Tx descriptor buffer of next Rx pkt. */
33125         unsigned long dirty_tx;
33126 -       void *tx_desc_raw;              /* Tx descriptor buffer */
33127 -       dma_addr_t tx_dma_raw;
33128 -       dma_addr_t tx_dma_aligned;
33129 -       void *rx_desc_raw;              /* Rx descriptor buffer */
33130 -       dma_addr_t rx_dma_raw;
33131 -       dma_addr_t rx_dma_aligned;
33132 +       dma_addr_t tx_dma;
33133 +       dma_addr_t rx_dma;
33134         struct TxDesc *TxDescArray;     /* Index of 256-alignment Tx Descriptor buffer */
33135         struct RxDesc *RxDescArray;     /* Index of 256-alignment Rx Descriptor buffer */
33136         unsigned char *RxBufferRings;   /* Index of Rx Buffer  */
33137 @@ -470,6 +468,10 @@
33138         if (rc)
33139                 goto err_out;
33140  
33141 +       rc = pci_set_dma_mask(pdev, 0xffffffffULL);
33142 +       if (rc)
33143 +               goto err_out;
33144 +
33145         mmio_start = pci_resource_start(pdev, 0);
33146         mmio_end = pci_resource_end(pdev, 0);
33147         mmio_flags = pci_resource_flags(pdev, 0);
33148 @@ -521,7 +523,6 @@
33149  
33150  err_out:
33151         pci_disable_device(pdev);
33152 -       unregister_netdev(dev);
33153         kfree(dev);
33154         return rc;
33155  }
33156 @@ -536,6 +537,7 @@
33157         static int printed_version = 0;
33158         int i, rc;
33159         u16 reg31;
33160 +       int val;
33161  
33162         assert(pdev != NULL);
33163         assert(ent != NULL);
33164 @@ -620,7 +622,7 @@
33165                dev->dev_addr[2], dev->dev_addr[3],
33166                dev->dev_addr[4], dev->dev_addr[5], dev->irq);
33167  
33168 -       int val = smdio_read(ioaddr, PHY_AUTO_NEGO_REG);
33169 +       val = smdio_read(ioaddr, PHY_AUTO_NEGO_REG);
33170  
33171         printk(KERN_INFO "%s: Auto-negotiation Enabled.\n", dev->name);
33172  
33173 @@ -714,54 +716,50 @@
33174  SiS190_open(struct net_device *dev)
33175  {
33176         struct sis190_private *tp = dev->priv;
33177 -       int retval;
33178 -       u8 diff;
33179         int rc;
33180  
33181 -       retval =
33182 -           request_irq(dev->irq, SiS190_interrupt, SA_SHIRQ, dev->name, dev);
33183 -       if (retval) {
33184 -               return retval;
33185 -       }
33186 +       rc = request_irq(dev->irq, SiS190_interrupt, SA_SHIRQ, dev->name, dev);
33187 +       if (rc)
33188 +               goto out;
33189  
33190 -       tp->tx_desc_raw = pci_alloc_consistent(tp->pci_dev,
33191 -               (NUM_TX_DESC * sizeof (struct TxDesc)) + 256,
33192 -               &tp->tx_dma_raw);
33193 -       if (!tp->tx_desc_raw) {
33194 +       /*
33195 +        * Rx and Tx descriptors need 256 bytes alignment.
33196 +        * pci_alloc_consistent() guarantees a stronger alignment.
33197 +        */
33198 +       tp->TxDescArray = pci_alloc_consistent(tp->pci_dev, TX_DESC_TOTAL_SIZE,
33199 +               &tp->tx_dma);
33200 +       if (!tp->TxDescArray) {
33201                 rc = -ENOMEM;
33202                 goto err_out;
33203         }
33204 -       // Tx Desscriptor needs 256 bytes alignment;
33205 -       diff = 256 - (tp->tx_dma_raw - ((tp->tx_dma_raw >> 8) << 8));
33206 -       tp->tx_dma_aligned = tp->tx_dma_raw + diff;
33207 -       tp->TxDescArray = (struct TxDesc *) (tp->tx_desc_raw + diff);
33208 -
33209 -       tp->rx_desc_raw = pci_alloc_consistent(tp->pci_dev,
33210 -               (NUM_RX_DESC * sizeof (struct RxDesc)) + 256,
33211 -               &tp->rx_dma_raw);
33212 -       if (!tp->rx_desc_raw) {
33213 +
33214 +       tp->RxDescArray = pci_alloc_consistent(tp->pci_dev, RX_DESC_TOTAL_SIZE,
33215 +               &tp->rx_dma);
33216 +       if (!tp->RxDescArray) {
33217                 rc = -ENOMEM;
33218                 goto err_out_free_tx;
33219         }
33220 -       // Rx Desscriptor needs 256 bytes alignment;
33221 -       diff = 256 - (tp->rx_dma_raw - ((tp->rx_dma_raw >> 8) << 8));
33222 -       tp->rx_dma_aligned = tp->rx_dma_raw + diff;
33223 -       tp->RxDescArray = (struct RxDesc *) (tp->rx_desc_raw + diff);
33224  
33225         tp->RxBufferRings = kmalloc(RX_BUF_SIZE * NUM_RX_DESC, GFP_KERNEL);
33226         if (tp->RxBufferRings == NULL) {
33227 -               printk(KERN_INFO "Allocate RxBufferRing failed\n");
33228 +               printk(KERN_INFO "%s: allocate RxBufferRing failed\n",
33229 +                       dev->name);
33230 +               rc = -ENOMEM;
33231 +               goto err_out_free_rx;
33232         }
33233  
33234         SiS190_init_ring(dev);
33235         SiS190_hw_start(dev);
33236  
33237 -       return 0;
33238 +out:
33239 +       return rc;
33240  
33241 +err_out_free_rx:
33242 +       pci_free_consistent(tp->pci_dev, RX_DESC_TOTAL_SIZE, tp->RxDescArray,
33243 +               tp->rx_dma);
33244  err_out_free_tx:
33245 -       pci_free_consistent(tp->pci_dev,
33246 -               (NUM_TX_DESC * sizeof (struct TxDesc)) + 256,
33247 -               tp->tx_desc_raw, tp->tx_dma_raw);
33248 +       pci_free_consistent(tp->pci_dev, TX_DESC_TOTAL_SIZE, tp->TxDescArray,
33249 +               tp->tx_dma);
33250  err_out:
33251         free_irq(dev->irq, dev);
33252         return rc;
33253 @@ -780,10 +778,10 @@
33254         SiS_W32(IntrControl, 0x0);
33255  
33256         SiS_W32(0x0, 0x01a00);
33257 -       SiS_W32(0x4, tp->tx_dma_aligned);
33258 +       SiS_W32(0x4, tp->tx_dma);
33259  
33260         SiS_W32(0x10, 0x1a00);
33261 -       SiS_W32(0x14, tp->rx_dma_aligned);
33262 +       SiS_W32(0x14, tp->rx_dma);
33263  
33264         SiS_W32(0x20, 0xffffffff);
33265         SiS_W32(0x24, 0x0);
33266 @@ -830,19 +828,19 @@
33267                 tp->Tx_skbuff[i] = NULL;
33268         }
33269         for (i = 0; i < NUM_RX_DESC; i++) {
33270 +               struct RxDesc *desc = tp->RxDescArray + i;
33271  
33272 -               tp->RxDescArray[i].PSize = 0x0;
33273 +               desc->PSize = 0x0;
33274  
33275                 if (i == (NUM_RX_DESC - 1))
33276 -                       tp->RxDescArray[i].buf_Len = BIT_31 + RX_BUF_SIZE;      //bit 31 is End bit
33277 +                       desc->buf_Len = BIT_31 + RX_BUF_SIZE;   //bit 31 is End bit
33278                 else
33279 -                       tp->RxDescArray[i].buf_Len = RX_BUF_SIZE;
33280 -
33281 -#warning Replace virt_to_bus with DMA mapping
33282 -               tp->RxBufferRing[i] = &(tp->RxBufferRings[i * RX_BUF_SIZE]);
33283 -               tp->RxDescArray[i].buf_addr = virt_to_bus(tp->RxBufferRing[i]);
33284 -               tp->RxDescArray[i].status = OWNbit | INTbit;
33285 +                       desc->buf_Len = RX_BUF_SIZE;
33286  
33287 +               tp->RxBufferRing[i] = tp->RxBufferRings + i * RX_BUF_SIZE;
33288 +               desc->buf_addr = pci_map_single(tp->pci_dev,
33289 +                       tp->RxBufferRing[i], RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
33290 +               desc->status = OWNbit | INTbit;
33291         }
33292  
33293  }
33294 @@ -855,7 +853,14 @@
33295         tp->cur_tx = 0;
33296         for (i = 0; i < NUM_TX_DESC; i++) {
33297                 if (tp->Tx_skbuff[i] != NULL) {
33298 -                       dev_kfree_skb(tp->Tx_skbuff[i]);
33299 +                       struct sk_buff *skb;
33300 +
33301 +                       skb = tp->Tx_skbuff[i];
33302 +                       pci_unmap_single(tp->pci_dev,
33303 +                               le32_to_cpu(tp->TxDescArray[i].buf_addr),
33304 +                               skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len,
33305 +                               PCI_DMA_TODEVICE);
33306 +                       dev_kfree_skb(skb);
33307                         tp->Tx_skbuff[i] = NULL;
33308                         tp->stats.tx_dropped++;
33309                 }
33310 @@ -894,46 +899,58 @@
33311         struct sis190_private *tp = dev->priv;
33312         void *ioaddr = tp->mmio_addr;
33313         int entry = tp->cur_tx % NUM_TX_DESC;
33314 +       u32 len;
33315  
33316 -       if (skb->len < ETH_ZLEN) {
33317 +       if (unlikely(skb->len < ETH_ZLEN)) {
33318                 skb = skb_padto(skb, ETH_ZLEN);
33319                 if (skb == NULL)
33320 -                       return 0;
33321 +                       goto drop_tx;
33322 +               len = ETH_ZLEN;
33323 +       } else {
33324 +               len = skb->len;
33325         }
33326  
33327         spin_lock_irq(&tp->lock);
33328  
33329 -       if ((tp->TxDescArray[entry].status & OWNbit) == 0) {
33330 -#warning Replace virt_to_bus with DMA mapping
33331 +       if ((le32_to_cpu(tp->TxDescArray[entry].status) & OWNbit) == 0) {
33332 +               dma_addr_t mapping;
33333 +
33334 +               mapping = pci_map_single(tp->pci_dev, skb->data, len,
33335 +                                        PCI_DMA_TODEVICE);
33336 +
33337                 tp->Tx_skbuff[entry] = skb;
33338 -               tp->TxDescArray[entry].buf_addr = virt_to_bus(skb->data);
33339 -               tp->TxDescArray[entry].PSize =
33340 -                   ((skb->len > ETH_ZLEN) ? skb->len : ETH_ZLEN);
33341 +               tp->TxDescArray[entry].buf_addr = cpu_to_le32(mapping);
33342 +               tp->TxDescArray[entry].PSize = cpu_to_le32(len);
33343  
33344 -               if (entry != (NUM_TX_DESC - 1)) {
33345 -                       tp->TxDescArray[entry].buf_Len =
33346 -                           tp->TxDescArray[entry].PSize;
33347 -               } else {
33348 +               if (entry != (NUM_TX_DESC - 1))
33349 +                       tp->TxDescArray[entry].buf_Len = cpu_to_le32(len);
33350 +               else
33351                         tp->TxDescArray[entry].buf_Len =
33352 -                           tp->TxDescArray[entry].PSize | ENDbit;
33353 -               }
33354 +                               cpu_to_le32(len | ENDbit);
33355  
33356                 tp->TxDescArray[entry].status |=
33357 -                   (OWNbit | INTbit | DEFbit | CRCbit | PADbit);
33358 +                   cpu_to_le32(OWNbit | INTbit | DEFbit | CRCbit | PADbit);
33359  
33360                 SiS_W32(TxControl, 0x1a11);     //Start Send
33361  
33362                 dev->trans_start = jiffies;
33363  
33364                 tp->cur_tx++;
33365 +       } else {
33366 +               spin_unlock_irq(&tp->lock);
33367 +               goto drop_tx;
33368         }
33369  
33370 +       if ((tp->cur_tx - NUM_TX_DESC) == tp->dirty_tx)
33371 +               netif_stop_queue(dev);
33372 +
33373         spin_unlock_irq(&tp->lock);
33374  
33375 -       if ((tp->cur_tx - NUM_TX_DESC) == tp->dirty_tx) {
33376 -               netif_stop_queue(dev);
33377 -       }
33378 +       return 0;
33379  
33380 +drop_tx:
33381 +       tp->stats.tx_dropped++;
33382 +       dev_kfree_skb(skb);
33383         return 0;
33384  }
33385  
33386 @@ -952,10 +969,18 @@
33387         tx_left = tp->cur_tx - dirty_tx;
33388  
33389         while (tx_left > 0) {
33390 -               if ((tp->TxDescArray[entry].status & OWNbit) == 0) {
33391 -                       dev_kfree_skb_irq(tp->
33392 -                                         Tx_skbuff[dirty_tx % NUM_TX_DESC]);
33393 -                       tp->Tx_skbuff[dirty_tx % NUM_TX_DESC] = NULL;
33394 +               if ((le32_to_cpu(tp->TxDescArray[entry].status) & OWNbit) == 0) {
33395 +                       struct sk_buff *skb;
33396 +
33397 +                       skb = tp->Tx_skbuff[entry];
33398 +
33399 +                       pci_unmap_single(tp->pci_dev,
33400 +                               le32_to_cpu(tp->TxDescArray[entry].buf_addr),
33401 +                               skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len,
33402 +                               PCI_DMA_TODEVICE);
33403 +
33404 +                       dev_kfree_skb_irq(skb);
33405 +                       tp->Tx_skbuff[entry] = NULL;
33406                         tp->stats.tx_packets++;
33407                         dirty_tx++;
33408                         tx_left--;
33409 @@ -965,8 +990,7 @@
33410  
33411         if (tp->dirty_tx != dirty_tx) {
33412                 tp->dirty_tx = dirty_tx;
33413 -               if (netif_queue_stopped(dev))
33414 -                       netif_wake_queue(dev);
33415 +               netif_wake_queue(dev);
33416         }
33417  }
33418  
33419 @@ -974,29 +998,30 @@
33420  SiS190_rx_interrupt(struct net_device *dev, struct sis190_private *tp,
33421                     void *ioaddr)
33422  {
33423 -       int cur_rx;
33424 -       struct sk_buff *skb;
33425 -       int pkt_size = 0;
33426 +       int cur_rx = tp->cur_rx;
33427 +       struct RxDesc *desc = tp->RxDescArray + cur_rx;
33428  
33429         assert(dev != NULL);
33430         assert(tp != NULL);
33431         assert(ioaddr != NULL);
33432  
33433 -       cur_rx = tp->cur_rx;
33434 -       while ((tp->RxDescArray[cur_rx].status & OWNbit) == 0) {
33435 +       while ((desc->status & OWNbit) == 0) {
33436  
33437 -               if (tp->RxDescArray[cur_rx].PSize & 0x0080000) {
33438 +               if (desc->PSize & 0x0080000) {
33439                         printk(KERN_INFO "%s: Rx ERROR!!!\n", dev->name);
33440                         tp->stats.rx_errors++;
33441                         tp->stats.rx_length_errors++;
33442 -               } else if (!(tp->RxDescArray[cur_rx].PSize & 0x0010000)) {
33443 +               } else if (!(desc->PSize & 0x0010000)) {
33444                         printk(KERN_INFO "%s: Rx ERROR!!!\n", dev->name);
33445                         tp->stats.rx_errors++;
33446                         tp->stats.rx_crc_errors++;
33447                 } else {
33448 -                       pkt_size =
33449 -                           (int) (tp->RxDescArray[cur_rx].
33450 -                                  PSize & 0x0000FFFF) - 4;
33451 +                       struct sk_buff *skb;
33452 +                       int pkt_size;
33453 +
33454 +                       pkt_size = (int) (desc->PSize & 0x0000FFFF) - 4;
33455 +                       pci_dma_sync_single(tp->pci_dev, desc->buf_addr,
33456 +                               RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
33457                         skb = dev_alloc_skb(pkt_size + 2);
33458                         if (skb != NULL) {
33459                                 skb->dev = dev;
33460 @@ -1007,24 +1032,18 @@
33461                                 skb->protocol = eth_type_trans(skb, dev);
33462                                 netif_rx(skb);
33463  
33464 -                               tp->RxDescArray[cur_rx].PSize = 0x0;
33465 +                               desc->PSize = 0x0;
33466  
33467                                 if (cur_rx == (NUM_RX_DESC - 1))
33468 -                                       tp->RxDescArray[cur_rx].buf_Len =
33469 -                                           ENDbit + RX_BUF_SIZE;
33470 +                                       desc->buf_Len = ENDbit + RX_BUF_SIZE;
33471                                 else
33472 -                                       tp->RxDescArray[cur_rx].buf_Len =
33473 -                                           RX_BUF_SIZE;
33474 +                                       desc->buf_Len = RX_BUF_SIZE;
33475  
33476 -#warning Replace virt_to_bus with DMA mapping
33477 -                               tp->RxDescArray[cur_rx].buf_addr =
33478 -                                   virt_to_bus(tp->RxBufferRing[cur_rx]);
33479                                 dev->last_rx = jiffies;
33480                                 tp->stats.rx_bytes += pkt_size;
33481                                 tp->stats.rx_packets++;
33482  
33483 -                               tp->RxDescArray[cur_rx].status =
33484 -                                   OWNbit | INTbit;
33485 +                               desc->status = OWNbit | INTbit;
33486                         } else {
33487                                 printk(KERN_WARNING
33488                                        "%s: Memory squeeze, deferring packet.\n",
33489 @@ -1036,7 +1055,7 @@
33490                 }
33491  
33492                 cur_rx = (cur_rx + 1) % NUM_RX_DESC;
33493 -
33494 +               desc = tp->RxDescArray + cur_rx;
33495         }
33496  
33497         tp->cur_rx = cur_rx;
33498 @@ -1111,22 +1130,22 @@
33499  
33500         spin_unlock_irq(&tp->lock);
33501  
33502 -       synchronize_irq();
33503 +       synchronize_irq(dev->irq);
33504         free_irq(dev->irq, dev);
33505  
33506         SiS190_tx_clear(tp);
33507 -       pci_free_consistent(tp->pci_dev,
33508 -               (NUM_TX_DESC * sizeof (struct TxDesc)) + 256,
33509 -               tp->tx_desc_raw, tp->tx_dma_raw);
33510 -       pci_free_consistent(tp->pci_dev,
33511 -               (NUM_RX_DESC * sizeof (struct RxDesc)) + 256,
33512 -               tp->rx_desc_raw, tp->rx_dma_raw);
33513 +       pci_free_consistent(tp->pci_dev, TX_DESC_TOTAL_SIZE, tp->TxDescArray,
33514 +               tp->tx_dma);
33515 +       pci_free_consistent(tp->pci_dev, RX_DESC_TOTAL_SIZE, tp->RxDescArray,
33516 +               tp->rx_dma);
33517         tp->TxDescArray = NULL;
33518 -       tp->RxDescArray = NULL;
33519 -       kfree(tp->RxBufferRings);
33520         for (i = 0; i < NUM_RX_DESC; i++) {
33521 +               pci_unmap_single(tp->pci_dev, tp->RxDescArray[i].buf_addr,
33522 +                       RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
33523                 tp->RxBufferRing[i] = NULL;
33524         }
33525 +       tp->RxDescArray = NULL;
33526 +       kfree(tp->RxBufferRings);
33527  
33528         return 0;
33529  }
33530 diff -Nru a/drivers/net/sis900.c b/drivers/net/sis900.c
33531 --- a/drivers/net/sis900.c      Tue Aug 19 20:53:16 2003
33532 +++ b/drivers/net/sis900.c      Tue Aug 26 16:37:16 2003
33533 @@ -169,6 +169,7 @@
33534         dma_addr_t rx_ring_dma;
33535  
33536         unsigned int tx_full;                   /* The Tx queue is full.    */
33537 +       u8 host_bridge_rev;
33538  };
33539  
33540  MODULE_AUTHOR("Jim Huang <cmhuang@sis.com.tw>, Ollie Lho <ollie@sis.com.tw>");
33541 @@ -210,6 +211,7 @@
33542  static u16 sis900_reset_phy(struct net_device *net_dev, int phy_addr);
33543  static void sis900_auto_negotiate(struct net_device *net_dev, int phy_addr);
33544  static void sis900_set_mode (long ioaddr, int speed, int duplex);
33545 +static struct ethtool_ops sis900_ethtool_ops;
33546  
33547  /**
33548   *     sis900_get_mac_addr - Get MAC address for stand alone SiS900 model
33549 @@ -367,6 +369,7 @@
33550  {
33551         struct sis900_private *sis_priv;
33552         struct net_device *net_dev;
33553 +       struct pci_dev *dev;
33554         dma_addr_t ring_dma;
33555         void *ring_space;
33556         long ioaddr;
33557 @@ -440,6 +443,7 @@
33558         net_dev->do_ioctl = &mii_ioctl;
33559         net_dev->tx_timeout = sis900_tx_timeout;
33560         net_dev->watchdog_timeo = TX_TIMEOUT;
33561 +       net_dev->ethtool_ops = &sis900_ethtool_ops;
33562         
33563         ret = register_netdev(net_dev);
33564         if (ret)
33565 @@ -473,6 +477,11 @@
33566                 goto err_out_unregister;
33567         }
33568  
33569 +       /* save our host bridge revision */
33570 +       dev = pci_find_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_630, NULL);
33571 +       if (dev)
33572 +               pci_read_config_byte(dev, PCI_CLASS_REVISION, &sis_priv->host_bridge_rev);
33573 +
33574         /* print some information about our NIC */
33575         printk(KERN_INFO "%s: %s at %#lx, IRQ %d, ", net_dev->name,
33576                card_name, ioaddr, net_dev->irq);
33577 @@ -1108,18 +1117,12 @@
33578  {
33579         struct sis900_private *sis_priv = net_dev->priv;
33580         u16 reg14h, eq_value=0, max_value=0, min_value=0;
33581 -       u8 host_bridge_rev;
33582         int i, maxcount=10;
33583 -       struct pci_dev *dev=NULL;
33584  
33585         if ( !(revision == SIS630E_900_REV || revision == SIS630EA1_900_REV ||
33586                revision == SIS630A_900_REV || revision ==  SIS630ET_900_REV) )
33587                 return;
33588  
33589 -       dev = pci_find_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_630, dev);
33590 -       if (dev)
33591 -               pci_read_config_byte(dev, PCI_CLASS_REVISION, &host_bridge_rev);
33592 -
33593         if (netif_carrier_ok(net_dev)) {
33594                 reg14h=mdio_read(net_dev, sis_priv->cur_phy, MII_RESV);
33595                 mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, (0x2200 | reg14h) & 0xBFFF);
33596 @@ -1142,7 +1145,8 @@
33597                 }
33598                 /* 630B0&B1 rule to determine the equalizer value */
33599                 if (revision == SIS630A_900_REV && 
33600 -                   (host_bridge_rev == SIS630B0 || host_bridge_rev == SIS630B1)) {
33601 +                   (sis_priv->host_bridge_rev == SIS630B0 || 
33602 +                    sis_priv->host_bridge_rev == SIS630B1)) {
33603                         if (max_value == 0)
33604                                 eq_value=3;
33605                         else
33606 @@ -1157,7 +1161,8 @@
33607         else {
33608                 reg14h=mdio_read(net_dev, sis_priv->cur_phy, MII_RESV);
33609                 if (revision == SIS630A_900_REV && 
33610 -                   (host_bridge_rev == SIS630B0 || host_bridge_rev == SIS630B1)) 
33611 +                   (sis_priv->host_bridge_rev == SIS630B0 || 
33612 +                    sis_priv->host_bridge_rev == SIS630B1)) 
33613                         mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, (reg14h | 0x2200) & 0xBFFF);
33614                 else
33615                         mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, (reg14h | 0x2000) & 0xBFFF);
33616 @@ -1853,39 +1858,27 @@
33617  }
33618  
33619  /**
33620 - *     netdev_ethtool_ioctl - For the basic support of ethtool
33621 - *     @net_dev: the net device to command for
33622 - *     @useraddr: start address of interface request
33623 + *     sis900_get_drvinfo - Return information about driver
33624 + *     @net_dev: the net device to probe
33625 + *     @info: container for info returned
33626   *
33627   *     Process ethtool command such as "ehtool -i" to show information
33628   */
33629 -
33630 -static int netdev_ethtool_ioctl (struct net_device *net_dev, void *useraddr)
33631
33632 +static void sis900_get_drvinfo(struct net_device *net_dev,
33633 +                              struct ethtool_drvinfo *info)
33634  {
33635         struct sis900_private *sis_priv = net_dev->priv;
33636 -       u32 ethcmd;
33637  
33638 -       if (copy_from_user (&ethcmd, useraddr, sizeof (ethcmd)))
33639 -               return -EFAULT;
33640 -       
33641 -       switch (ethcmd) {
33642 -       case ETHTOOL_GDRVINFO:
33643 -               {
33644 -                       struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
33645 -                       strcpy (info.driver, SIS900_MODULE_NAME);
33646 -                       strcpy (info.version, SIS900_DRV_VERSION);
33647 -                       strcpy (info.bus_info, pci_name(sis_priv->pci_dev));
33648 -                       if (copy_to_user (useraddr, &info, sizeof (info)))
33649 -                               return -EFAULT;
33650 -                       return 0;
33651 -               }
33652 -       default:
33653 -               break;
33654 -       }
33655 -
33656 -       return -EOPNOTSUPP;
33657 +       strcpy (info->driver, SIS900_MODULE_NAME);
33658 +       strcpy (info->version, SIS900_DRV_VERSION);
33659 +       strcpy (info->bus_info, pci_name(sis_priv->pci_dev));
33660  }
33661  
33662 +static struct ethtool_ops sis900_ethtool_ops = {
33663 +       .get_drvinfo =          sis900_get_drvinfo,
33664 +};
33665 +
33666  /**
33667   *     mii_ioctl - process MII i/o control command 
33668   *     @net_dev: the net device to command for
33669 @@ -1901,9 +1894,6 @@
33670         struct mii_ioctl_data *data = (struct mii_ioctl_data *)&rq->ifr_data;
33671  
33672         switch(cmd) {
33673 -       case SIOCETHTOOL:
33674 -               return netdev_ethtool_ioctl(net_dev, (void *) rq->ifr_data);
33675 -
33676         case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
33677                 data->phy_id = sis_priv->mii->phy_addr;
33678                 /* Fall Through */
33679 diff -Nru a/drivers/net/sk_mca.c b/drivers/net/sk_mca.c
33680 --- a/drivers/net/sk_mca.c      Fri Jul 25 17:15:35 2003
33681 +++ b/drivers/net/sk_mca.c      Sun Aug 31 22:50:10 2003
33682 @@ -124,7 +124,7 @@
33683  /* dump parts of shared memory - only needed during debugging */
33684  
33685  #ifdef DEBUG
33686 -static void dumpmem(struct SKMCA_NETDEV *dev, u32 start, u32 len)
33687 +static void dumpmem(struct net_device *dev, u32 start, u32 len)
33688  {
33689         int z;
33690  
33691 @@ -217,7 +217,7 @@
33692  
33693  /* reset the whole board */
33694  
33695 -static void ResetBoard(struct SKMCA_NETDEV *dev)
33696 +static void ResetBoard(struct net_device *dev)
33697  {
33698         skmca_priv *priv = (skmca_priv *) dev->priv;
33699  
33700 @@ -228,7 +228,7 @@
33701  
33702  /* wait for LANCE interface to become not busy */
33703  
33704 -static int WaitLANCE(struct SKMCA_NETDEV *dev)
33705 +static int WaitLANCE(struct net_device *dev)
33706  {
33707         skmca_priv *priv = (skmca_priv *) dev->priv;
33708         int t = 0;
33709 @@ -247,7 +247,7 @@
33710  
33711  /* set LANCE register - must be atomic */
33712  
33713 -static void SetLANCE(struct SKMCA_NETDEV *dev, u16 addr, u16 value)
33714 +static void SetLANCE(struct net_device *dev, u16 addr, u16 value)
33715  {
33716         skmca_priv *priv = (skmca_priv *) dev->priv;
33717         unsigned long flags;
33718 @@ -280,12 +280,12 @@
33719  
33720         /* reenable interrupts */
33721  
33722 -       spin_lock_irqrestore(&priv->lock, flags);
33723 +       spin_unlock_irqrestore(&priv->lock, flags);
33724  }
33725  
33726  /* get LANCE register */
33727  
33728 -static u16 GetLANCE(struct SKMCA_NETDEV *dev, u16 addr)
33729 +static u16 GetLANCE(struct net_device *dev, u16 addr)
33730  {
33731         skmca_priv *priv = (skmca_priv *) dev->priv;
33732         unsigned long flags;
33733 @@ -319,14 +319,14 @@
33734  
33735         /* reenable interrupts */
33736  
33737 -       spin_lock_irqrestore(&priv->lock, flags);
33738 +       spin_unlock_irqrestore(&priv->lock, flags);
33739  
33740         return res;
33741  }
33742  
33743  /* build up descriptors in shared RAM */
33744  
33745 -static void InitDscrs(struct SKMCA_NETDEV *dev)
33746 +static void InitDscrs(struct net_device *dev)
33747  {
33748         u32 bufaddr;
33749  
33750 @@ -422,7 +422,7 @@
33751  
33752  /* feed ready-built initialization block into LANCE */
33753  
33754 -static void InitLANCE(struct SKMCA_NETDEV *dev)
33755 +static void InitLANCE(struct net_device *dev)
33756  {
33757         skmca_priv *priv = (skmca_priv *) dev->priv;
33758  
33759 @@ -452,11 +452,7 @@
33760  
33761         /* we don't get ready until the LANCE has read the init block */
33762  
33763 -#if (LINUX_VERSION_CODE >= 0x02032a)
33764         netif_stop_queue(dev);
33765 -#else
33766 -       dev->tbusy = 1;
33767 -#endif
33768  
33769         /* let LANCE read the initialization block.  LANCE is ready
33770            when we receive the corresponding interrupt. */
33771 @@ -466,15 +462,11 @@
33772  
33773  /* stop the LANCE so we can reinitialize it */
33774  
33775 -static void StopLANCE(struct SKMCA_NETDEV *dev)
33776 +static void StopLANCE(struct net_device *dev)
33777  {
33778         /* can't take frames any more */
33779  
33780 -#if (LINUX_VERSION_CODE >= 0x02032a)
33781         netif_stop_queue(dev);
33782 -#else
33783 -       dev->tbusy = 1;
33784 -#endif
33785  
33786         /* disable interrupts, stop it */
33787  
33788 @@ -483,7 +475,7 @@
33789  
33790  /* initialize card and LANCE for proper operation */
33791  
33792 -static void InitBoard(struct SKMCA_NETDEV *dev)
33793 +static void InitBoard(struct net_device *dev)
33794  {
33795         LANCE_InitBlock block;
33796  
33797 @@ -508,7 +500,7 @@
33798  
33799  /* deinitialize card and LANCE */
33800  
33801 -static void DeinitBoard(struct SKMCA_NETDEV *dev)
33802 +static void DeinitBoard(struct net_device *dev)
33803  {
33804         /* stop LANCE */
33805  
33806 @@ -521,7 +513,7 @@
33807  
33808  /* probe for device's irq */
33809  
33810 -static int __init ProbeIRQ(struct SKMCA_NETDEV *dev)
33811 +static int __init ProbeIRQ(struct net_device *dev)
33812  {
33813         unsigned long imaskval, njiffies, irq;
33814         u16 csr0val;
33815 @@ -563,15 +555,11 @@
33816  
33817  /* LANCE has read initialization block -> start it */
33818  
33819 -static u16 irqstart_handler(struct SKMCA_NETDEV *dev, u16 oldcsr0)
33820 +static u16 irqstart_handler(struct net_device *dev, u16 oldcsr0)
33821  {
33822         /* now we're ready to transmit */
33823  
33824 -#if (LINUX_VERSION_CODE >= 0x02032a)
33825         netif_wake_queue(dev);
33826 -#else
33827 -       dev->tbusy = 0;
33828 -#endif
33829  
33830         /* reset IDON bit, start LANCE */
33831  
33832 @@ -581,7 +569,7 @@
33833  
33834  /* did we lose blocks due to a FIFO overrun ? */
33835  
33836 -static u16 irqmiss_handler(struct SKMCA_NETDEV *dev, u16 oldcsr0)
33837 +static u16 irqmiss_handler(struct net_device *dev, u16 oldcsr0)
33838  {
33839         skmca_priv *priv = (skmca_priv *) dev->priv;
33840  
33841 @@ -597,7 +585,7 @@
33842  
33843  /* receive interrupt */
33844  
33845 -static u16 irqrx_handler(struct SKMCA_NETDEV *dev, u16 oldcsr0)
33846 +static u16 irqrx_handler(struct net_device *dev, u16 oldcsr0)
33847  {
33848         skmca_priv *priv = (skmca_priv *) dev->priv;
33849         LANCE_RxDescr descr;
33850 @@ -678,7 +666,7 @@
33851  
33852  /* transmit interrupt */
33853  
33854 -static u16 irqtx_handler(struct SKMCA_NETDEV *dev, u16 oldcsr0)
33855 +static u16 irqtx_handler(struct net_device *dev, u16 oldcsr0)
33856  {
33857         skmca_priv *priv = (skmca_priv *) dev->priv;
33858         LANCE_TxDescr descr;
33859 @@ -740,12 +728,7 @@
33860            a new one */
33861         /* inform upper layers we're in business again */
33862  
33863 -#if (LINUX_VERSION_CODE >= 0x02032a)
33864         netif_wake_queue(dev);
33865 -#else
33866 -       dev->tbusy = 0;
33867 -       mark_bh(NET_BH);
33868 -#endif
33869  
33870         return oldcsr0;
33871  }
33872 @@ -754,7 +737,7 @@
33873  
33874  static irqreturn_t irq_handler(int irq, void *device, struct pt_regs *regs)
33875  {
33876 -       struct SKMCA_NETDEV *dev = (struct SKMCA_NETDEV *) device;
33877 +       struct net_device *dev = (struct net_device *) device;
33878         u16 csr0val;
33879  
33880         /* read CSR0 to get interrupt cause */
33881 @@ -766,13 +749,9 @@
33882         if ((csr0val & CSR0_INTR) == 0)
33883                 return IRQ_NONE;
33884  
33885 -#if (LINUX_VERSION_CODE >= 0x02032a)
33886  #if 0
33887         set_bit(LINK_STATE_RXSEM, &dev->state);
33888  #endif
33889 -#else
33890 -       dev->interrupt = 1;
33891 -#endif
33892  
33893         /* loop through the interrupt bits until everything is clear */
33894  
33895 @@ -796,13 +775,9 @@
33896         }
33897         while ((csr0val & CSR0_INTR) != 0);
33898  
33899 -#if (LINUX_VERSION_CODE >= 0x02032a)
33900  #if 0
33901         clear_bit(LINK_STATE_RXSEM, &dev->state);
33902  #endif
33903 -#else
33904 -       dev->interrupt = 0;
33905 -#endif
33906         return IRQ_HANDLED;
33907  }
33908  
33909 @@ -815,7 +790,7 @@
33910  static int skmca_getinfo(char *buf, int slot, void *d)
33911  {
33912         int len = 0, i;
33913 -       struct SKMCA_NETDEV *dev = (struct SKMCA_NETDEV *) d;
33914 +       struct net_device *dev = (struct net_device *) d;
33915         skmca_priv *priv;
33916  
33917         /* can't say anything about an uninitialized device... */
33918 @@ -846,7 +821,7 @@
33919  
33920  /* open driver.  Means also initialization and start of LANCE */
33921  
33922 -static int skmca_open(struct SKMCA_NETDEV *dev)
33923 +static int skmca_open(struct net_device *dev)
33924  {
33925         int result;
33926         skmca_priv *priv = (skmca_priv *) dev->priv;
33927 @@ -868,21 +843,14 @@
33928  
33929         /* set up flags */
33930  
33931 -#if (LINUX_VERSION_CODE >= 0x02032a)
33932         netif_start_queue(dev);
33933 -#else
33934 -       dev->interrupt = 0;
33935 -       dev->tbusy = 0;
33936 -       dev->start = 0;
33937 -       MOD_INC_USE_COUNT;
33938 -#endif
33939  
33940         return 0;
33941  }
33942  
33943  /* close driver.  Shut down board and free allocated resources */
33944  
33945 -static int skmca_close(struct SKMCA_NETDEV *dev)
33946 +static int skmca_close(struct net_device *dev)
33947  {
33948         /* turn off board */
33949         DeinitBoard(dev);
33950 @@ -892,16 +860,12 @@
33951                 free_irq(dev->irq, dev);
33952         dev->irq = 0;
33953  
33954 -#if (LINUX_VERSION_CODE < 0x02032a)
33955 -       MOD_DEC_USE_COUNT;
33956 -#endif
33957 -
33958         return 0;
33959  }
33960  
33961  /* transmit a block. */
33962  
33963 -static int skmca_tx(struct sk_buff *skb, struct SKMCA_NETDEV *dev)
33964 +static int skmca_tx(struct sk_buff *skb, struct net_device *dev)
33965  {
33966         skmca_priv *priv = (skmca_priv *) dev->priv;
33967         LANCE_TxDescr descr;
33968 @@ -977,11 +941,7 @@
33969         /* are we saturated ? */
33970  
33971         if (priv->txbusy >= TXCOUNT)
33972 -#if (LINUX_VERSION_CODE >= 0x02032a)
33973                 netif_stop_queue(dev);
33974 -#else
33975 -               dev->tbusy = 1;
33976 -#endif
33977  
33978         /* write descriptor back to RAM */
33979         SKMCA_TOIO(dev->mem_start + address, &descr,
33980 @@ -993,7 +953,7 @@
33981         if (priv->txbusy == 0)
33982                 SetLANCE(dev, LANCE_CSR0, CSR0_INEA | CSR0_TDMD);
33983  
33984 -       spin_lock_irqrestore(&priv->lock, flags);
33985 +       spin_unlock_irqrestore(&priv->lock, flags);
33986  
33987        tx_done:
33988  
33989 @@ -1004,7 +964,7 @@
33990  
33991  /* return pointer to Ethernet statistics */
33992  
33993 -static struct net_device_stats *skmca_stats(struct SKMCA_NETDEV *dev)
33994 +static struct net_device_stats *skmca_stats(struct net_device *dev)
33995  {
33996         skmca_priv *priv = (skmca_priv *) dev->priv;
33997  
33998 @@ -1014,7 +974,7 @@
33999  /* we don't support runtime reconfiguration, since an MCA card can
34000     be unambigously identified by its POS registers. */
34001  
34002 -static int skmca_config(struct SKMCA_NETDEV *dev, struct ifmap *map)
34003 +static int skmca_config(struct net_device *dev, struct ifmap *map)
34004  {
34005         return 0;
34006  }
34007 @@ -1022,7 +982,7 @@
34008  /* switch receiver mode.  We use the LANCE's multicast filter to prefilter
34009     multicast addresses. */
34010  
34011 -static void skmca_set_multicast_list(struct SKMCA_NETDEV *dev)
34012 +static void skmca_set_multicast_list(struct net_device *dev)
34013  {
34014         LANCE_InitBlock block;
34015  
34016 @@ -1062,7 +1022,7 @@
34017  
34018  static int startslot;          /* counts through slots when probing multiple devices */
34019  
34020 -int __init skmca_probe(struct SKMCA_NETDEV *dev)
34021 +int __init skmca_probe(struct net_device *dev)
34022  {
34023         int force_detect = 0;
34024         int junior, slot, i;
34025 @@ -1095,14 +1055,12 @@
34026  
34027                 getaddrs(slot, junior, &base, &irq, &medium);
34028  
34029 -#if LINUX_VERSION_CODE >= 0x020300
34030                 /* slot already in use ? */
34031  
34032                 if (mca_is_adapter_used(slot)) {
34033                         slot = dofind(&junior, slot + 1);
34034                         continue;
34035                 }
34036 -#endif
34037  
34038                 /* were we looking for something different ? */
34039  
34040 @@ -1221,24 +1179,13 @@
34041  
34042  #define DEVMAX 5
34043  
34044 -#if (LINUX_VERSION_CODE >= 0x020369)
34045 -static struct SKMCA_NETDEV moddevs[DEVMAX] =
34046 -    { {"    ", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
34047 -{"    ", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
34048 -{"    ", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
34049 -{"    ", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
34050 -{"    ", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe}
34051 -};
34052 -#else
34053 -static char NameSpace[8 * DEVMAX];
34054 -static struct SKMCA_NETDEV moddevs[DEVMAX] =
34055 -    { {NameSpace + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
34056 -{NameSpace + 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
34057 -{NameSpace + 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
34058 -{NameSpace + 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe},
34059 -{NameSpace + 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, skmca_probe}
34060 +static struct net_device moddevs[DEVMAX] = {
34061 +       { .name = "    ", .init = skmca_probe },
34062 +       { .name = "    ", .init = skmca_probe },
34063 +       { .name = "    ", .init = skmca_probe },
34064 +       { .name = "    ", .init = skmca_probe },
34065 +       { .name = "    ", .init = skmca_probe }
34066  };
34067 -#endif
34068  
34069  int irq;
34070  int io;
34071 @@ -1260,7 +1207,7 @@
34072  
34073  void cleanup_module(void)
34074  {
34075 -       struct SKMCA_NETDEV *dev;
34076 +       struct net_device *dev;
34077         skmca_priv *priv;
34078         int z;
34079  
34080 diff -Nru a/drivers/net/sk_mca.h b/drivers/net/sk_mca.h
34081 --- a/drivers/net/sk_mca.h      Tue Jul 15 08:10:44 2003
34082 +++ b/drivers/net/sk_mca.h      Sun Aug 31 08:29:49 2003
34083 @@ -5,7 +5,6 @@
34084  
34085  /* version-dependent functions/structures */
34086  
34087 -#if LINUX_VERSION_CODE >= 0x020318
34088  #define SKMCA_READB(addr) isa_readb(addr)
34089  #define SKMCA_READW(addr) isa_readw(addr)
34090  #define SKMCA_WRITEB(data, addr) isa_writeb(data, addr)
34091 @@ -13,17 +12,6 @@
34092  #define SKMCA_TOIO(dest, src, len) isa_memcpy_toio(dest, src, len)
34093  #define SKMCA_FROMIO(dest, src, len) isa_memcpy_fromio(dest, src, len)
34094  #define SKMCA_SETIO(dest, val, len) isa_memset_io(dest, val, len)
34095 -#define SKMCA_NETDEV net_device
34096 -#else
34097 -#define SKMCA_READB(addr) readb(addr)
34098 -#define SKMCA_READW(addr) readw(addr)
34099 -#define SKMCA_WRITEB(data, addr) writeb(data, addr)
34100 -#define SKMCA_WRITEW(data, addr) writew(data, addr)
34101 -#define SKMCA_TOIO(dest, src, len) memcpy_toio(dest, src, len)
34102 -#define SKMCA_FROMIO(dest, src, len) memcpy_fromio(dest, src, len)
34103 -#define SKMCA_SETIO(dest, val, len) memset_io(dest, val, len)
34104 -#define SKMCA_NETDEV device
34105 -#endif
34106  
34107  /* Adapter ID's */
34108  #define SKNET_MCA_ID 0x6afd
34109 @@ -188,7 +176,7 @@
34110  
34111  #endif                         /* _SK_MCA_DRIVER_ */
34112  
34113 -extern int skmca_probe(struct SKMCA_NETDEV *);
34114 +extern int skmca_probe(struct net_device *);
34115  
34116  
34117  #endif /* _SK_MCA_INCLUDE_ */
34118 diff -Nru a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
34119 --- a/drivers/net/sunbmac.c     Tue Aug 19 20:53:16 2003
34120 +++ b/drivers/net/sunbmac.c     Sun Aug 24 05:58:18 2003
34121 @@ -1,7 +1,7 @@
34122  /* $Id$
34123   * sunbmac.c: Driver for Sparc BigMAC 100baseT ethernet adapters.
34124   *
34125 - * Copyright (C) 1997, 1998, 1999 David S. Miller (davem@redhat.com)
34126 + * Copyright (C) 1997, 1998, 1999, 2003 David S. Miller (davem@redhat.com)
34127   */
34128  
34129  #include <linux/module.h>
34130 @@ -18,6 +18,7 @@
34131  #include <linux/init.h>
34132  #include <linux/crc32.h>
34133  #include <linux/errno.h>
34134 +#include <linux/ethtool.h>
34135  #include <linux/netdevice.h>
34136  #include <linux/etherdevice.h>
34137  #include <linux/skbuff.h>
34138 @@ -37,7 +38,7 @@
34139  #include "sunbmac.h"
34140  
34141  static char version[] __initdata =
34142 -        "sunbmac.c:v1.9 11/Sep/99 David S. Miller (davem@redhat.com)\n";
34143 +        "sunbmac.c:v2.0 24/Nov/03 David S. Miller (davem@redhat.com)\n";
34144  
34145  #undef DEBUG_PROBE
34146  #undef DEBUG_TX
34147 @@ -1035,6 +1036,33 @@
34148         sbus_writel(tmp, bregs + BMAC_RXCFG);
34149  }
34150  
34151 +/* Ethtool support... */
34152 +static void bigmac_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
34153 +{
34154 +       struct bigmac *bp = dev->priv;
34155 +
34156 +       strcpy(info->driver, "sunbmac");
34157 +       strcpy(info->version, "2.0");
34158 +       sprintf(info->bus_info, "SBUS:%d",
34159 +               bp->qec_sdev->slot);
34160 +}
34161 +
34162 +static u32 bigmac_get_link(struct net_device *dev)
34163 +{
34164 +       struct bigmac *bp = dev->priv;
34165 +
34166 +       spin_lock_irq(&bp->lock);
34167 +       bp->sw_bmsr = bigmac_tcvr_read(bp, bp->tregs, BIGMAC_BMSR);
34168 +       spin_unlock_irq(&bp->lock);
34169 +
34170 +       return (bp->sw_bmsr & BMSR_LSTATUS);
34171 +}
34172 +
34173 +static struct ethtool_ops bigmac_ethtool_ops = {
34174 +       .get_drvinfo            = bigmac_get_drvinfo,
34175 +       .get_link               = bigmac_get_link,
34176 +};
34177 +
34178  static int __init bigmac_ether_init(struct sbus_dev *qec_sdev)
34179  {
34180         struct net_device *dev;
34181 @@ -1169,6 +1197,7 @@
34182         dev->open = &bigmac_open;
34183         dev->stop = &bigmac_close;
34184         dev->hard_start_xmit = &bigmac_start_xmit;
34185 +       dev->ethtool_ops = &bigmac_ethtool_ops;
34186  
34187         /* Set links to BigMAC statistic and multi-cast loading code. */
34188         dev->get_stats = &bigmac_get_stats;
34189 diff -Nru a/drivers/net/sungem.c b/drivers/net/sungem.c
34190 --- a/drivers/net/sungem.c      Tue Aug 19 20:53:16 2003
34191 +++ b/drivers/net/sungem.c      Sun Aug 24 05:58:18 2003
34192 @@ -1,7 +1,7 @@
34193  /* $Id$
34194   * sungem.c: Sun GEM ethernet driver.
34195   *
34196 - * Copyright (C) 2000, 2001, 2002 David S. Miller (davem@redhat.com)
34197 + * Copyright (C) 2000, 2001, 2002, 2003 David S. Miller (davem@redhat.com)
34198   * 
34199   * Support for Apple GMAC and assorted PHYs by
34200   * Benjamin Herrenscmidt (benh@kernel.crashing.org)
34201 @@ -70,8 +70,8 @@
34202                          SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full)
34203  
34204  #define DRV_NAME       "sungem"
34205 -#define DRV_VERSION    "0.97"
34206 -#define DRV_RELDATE    "3/20/02"
34207 +#define DRV_VERSION    "0.98"
34208 +#define DRV_RELDATE    "8/24/03"
34209  #define DRV_AUTHOR     "David S. Miller (davem@redhat.com)"
34210  
34211  static char version[] __devinitdata =
34212 @@ -2317,177 +2317,134 @@
34213         spin_unlock_irq(&gp->lock);
34214  }
34215  
34216 -/* Eventually add support for changing the advertisement
34217 - * on autoneg.
34218 - */
34219 -static int gem_ethtool_ioctl(struct net_device *dev, void *ep_user)
34220 +static void gem_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
34221 +{
34222 +       struct gem *gp = dev->priv;
34223 +  
34224 +       strcpy(info->driver, DRV_NAME);
34225 +       strcpy(info->version, DRV_VERSION);
34226 +       strcpy(info->bus_info, pci_name(gp->pdev));
34227 +}
34228 +  
34229 +static int gem_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
34230  {
34231         struct gem *gp = dev->priv;
34232 -       struct ethtool_cmd ecmd;
34233 -
34234 -       if (copy_from_user(&ecmd, ep_user, sizeof(ecmd)))
34235 -               return -EFAULT;
34236 -               
34237 -       switch(ecmd.cmd) {
34238 -        case ETHTOOL_GDRVINFO: {
34239 -               struct ethtool_drvinfo info = { .cmd = ETHTOOL_GDRVINFO };
34240 -
34241 -               strncpy(info.driver, DRV_NAME, ETHTOOL_BUSINFO_LEN);
34242 -               strncpy(info.version, DRV_VERSION, ETHTOOL_BUSINFO_LEN);
34243 -               info.fw_version[0] = '\0';
34244 -               strncpy(info.bus_info, pci_name(gp->pdev), ETHTOOL_BUSINFO_LEN);
34245 -               info.regdump_len = 0; /*SUNGEM_NREGS;*/
34246  
34247 -               if (copy_to_user(ep_user, &info, sizeof(info)))
34248 -                       return -EFAULT;
34249 +       if (gp->phy_type == phy_mii_mdio0 ||
34250 +           gp->phy_type == phy_mii_mdio1) {
34251 +               if (gp->phy_mii.def)
34252 +                       cmd->supported = gp->phy_mii.def->features;
34253 +               else
34254 +                       cmd->supported = (SUPPORTED_10baseT_Half |
34255 +                                         SUPPORTED_10baseT_Full);
34256  
34257 -               return 0;
34258 -       }
34259 +               /* XXX hardcoded stuff for now */
34260 +               cmd->port = PORT_MII;
34261 +               cmd->transceiver = XCVR_EXTERNAL;
34262 +               cmd->phy_address = 0; /* XXX fixed PHYAD */
34263  
34264 -       case ETHTOOL_GSET:
34265 -               if (gp->phy_type == phy_mii_mdio0 ||
34266 -                   gp->phy_type == phy_mii_mdio1) {
34267 -                       if (gp->phy_mii.def)
34268 -                               ecmd.supported = gp->phy_mii.def->features;
34269 -                       else
34270 -                               ecmd.supported = SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full;
34271 -
34272 -                       /* XXX hardcoded stuff for now */
34273 -                       ecmd.port = PORT_MII;
34274 -                       ecmd.transceiver = XCVR_EXTERNAL;
34275 -                       ecmd.phy_address = 0; /* XXX fixed PHYAD */
34276 -
34277 -                       /* Return current PHY settings */
34278 -                       spin_lock_irq(&gp->lock);
34279 -                       ecmd.autoneg = gp->want_autoneg;
34280 -                       ecmd.speed = gp->phy_mii.speed;
34281 -                       ecmd.duplex = gp->phy_mii.duplex;                       
34282 -                       ecmd.advertising = gp->phy_mii.advertising;
34283 -                       /* If we started with a forced mode, we don't have a default
34284 -                        * advertise set, we need to return something sensible so
34285 -                        * userland can re-enable autoneg properly */
34286 -                       if (ecmd.advertising == 0)
34287 -                               ecmd.advertising = ecmd.supported;
34288 -                       spin_unlock_irq(&gp->lock);
34289 -               } else { // XXX PCS ?
34290 -                   ecmd.supported =
34291 +               /* Return current PHY settings */
34292 +               spin_lock_irq(&gp->lock);
34293 +               cmd->autoneg = gp->want_autoneg;
34294 +               cmd->speed = gp->phy_mii.speed;
34295 +               cmd->duplex = gp->phy_mii.duplex;                       
34296 +               cmd->advertising = gp->phy_mii.advertising;
34297 +
34298 +               /* If we started with a forced mode, we don't have a default
34299 +                * advertise set, we need to return something sensible so
34300 +                * userland can re-enable autoneg properly.
34301 +                */
34302 +               if (cmd->advertising == 0)
34303 +                       cmd->advertising = cmd->supported;
34304 +               spin_unlock_irq(&gp->lock);
34305 +       } else { // XXX PCS ?
34306 +               cmd->supported =
34307                         (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
34308                          SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
34309                          SUPPORTED_Autoneg);
34310 -                   ecmd.advertising = ecmd.supported;
34311 -               }
34312 -               if (copy_to_user(ep_user, &ecmd, sizeof(ecmd)))
34313 -                       return -EFAULT;
34314 -               return 0;
34315 +               cmd->advertising = cmd->supported;
34316 +               cmd->speed = 0;
34317 +               cmd->duplex = cmd->port = cmd->phy_address =
34318 +                       cmd->transceiver = cmd->autoneg = 0;
34319 +       }
34320 +       cmd->maxtxpkt = cmd->maxrxpkt = 0;
34321  
34322 -       case ETHTOOL_SSET:
34323 -               /* Verify the settings we care about. */
34324 -               if (ecmd.autoneg != AUTONEG_ENABLE &&
34325 -                   ecmd.autoneg != AUTONEG_DISABLE)
34326 -                       return -EINVAL;
34327 -
34328 -               if (ecmd.autoneg == AUTONEG_ENABLE &&
34329 -                   ecmd.advertising == 0)
34330 -                       return -EINVAL;
34331 -
34332 -               if (ecmd.autoneg == AUTONEG_DISABLE &&
34333 -                   ((ecmd.speed != SPEED_1000 &&
34334 -                     ecmd.speed != SPEED_100 &&
34335 -                     ecmd.speed != SPEED_10) ||
34336 -                    (ecmd.duplex != DUPLEX_HALF &&
34337 -                     ecmd.duplex != DUPLEX_FULL)))
34338 -                       return -EINVAL;
34339 -             
34340 -               /* Apply settings and restart link process. */
34341 -               spin_lock_irq(&gp->lock);
34342 -               gem_begin_auto_negotiation(gp, &ecmd);
34343 -               spin_unlock_irq(&gp->lock);
34344 +       return 0;
34345 +}
34346  
34347 -               return 0;
34348 +static int gem_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
34349 +{
34350 +       struct gem *gp = dev->priv;
34351  
34352 -       case ETHTOOL_NWAY_RST:
34353 -               if (!gp->want_autoneg)
34354 -                       return -EINVAL;
34355 +       /* Verify the settings we care about. */
34356 +       if (cmd->autoneg != AUTONEG_ENABLE &&
34357 +           cmd->autoneg != AUTONEG_DISABLE)
34358 +               return -EINVAL;
34359  
34360 -               /* Restart link process. */
34361 -               spin_lock_irq(&gp->lock);
34362 -               gem_begin_auto_negotiation(gp, NULL);
34363 -               spin_unlock_irq(&gp->lock);
34364 +       if (cmd->autoneg == AUTONEG_ENABLE &&
34365 +           cmd->advertising == 0)
34366 +               return -EINVAL;
34367  
34368 -               return 0;
34369 +       if (cmd->autoneg == AUTONEG_DISABLE &&
34370 +           ((cmd->speed != SPEED_1000 &&
34371 +             cmd->speed != SPEED_100 &&
34372 +             cmd->speed != SPEED_10) ||
34373 +            (cmd->duplex != DUPLEX_HALF &&
34374 +             cmd->duplex != DUPLEX_FULL)))
34375 +               return -EINVAL;
34376 +             
34377 +       /* Apply settings and restart link process. */
34378 +       spin_lock_irq(&gp->lock);
34379 +       gem_begin_auto_negotiation(gp, cmd);
34380 +       spin_unlock_irq(&gp->lock);
34381  
34382 -       case ETHTOOL_GWOL:
34383 -       case ETHTOOL_SWOL:
34384 -               break; /* todo */
34385 -
34386 -       /* get link status */
34387 -       case ETHTOOL_GLINK: {
34388 -               struct ethtool_value edata = { .cmd = ETHTOOL_GLINK };
34389 -
34390 -               edata.data = (gp->lstate == link_up);
34391 -               if (copy_to_user(ep_user, &edata, sizeof(edata)))
34392 -                       return -EFAULT;
34393 -               return 0;
34394 -       }
34395 +       return 0;
34396 +}
34397  
34398 -       /* get message-level */
34399 -       case ETHTOOL_GMSGLVL: {
34400 -               struct ethtool_value edata = { .cmd = ETHTOOL_GMSGLVL };
34401 -
34402 -               edata.data = gp->msg_enable;
34403 -               if (copy_to_user(ep_user, &edata, sizeof(edata)))
34404 -                       return -EFAULT;
34405 -               return 0;
34406 -       }
34407 +static int gem_nway_reset(struct net_device *dev)
34408 +{
34409 +       struct gem *gp = dev->priv;
34410  
34411 -       /* set message-level */
34412 -       case ETHTOOL_SMSGLVL: {
34413 -               struct ethtool_value edata;
34414 -
34415 -               if (copy_from_user(&edata, ep_user, sizeof(edata)))
34416 -                       return -EFAULT;
34417 -               gp->msg_enable = edata.data;
34418 -               return 0;
34419 -       }
34420 +       if (!gp->want_autoneg)
34421 +               return -EINVAL;
34422  
34423 -#if 0
34424 -       case ETHTOOL_GREGS: {
34425 -               struct ethtool_regs regs;
34426 -               u32 *regbuf;
34427 -               int r = 0;
34428 +       /* Restart link process. */
34429 +       spin_lock_irq(&gp->lock);
34430 +       gem_begin_auto_negotiation(gp, NULL);
34431 +       spin_unlock_irq(&gp->lock);
34432  
34433 -               if (copy_from_user(&regs, useraddr, sizeof(regs)))
34434 -                       return -EFAULT;
34435 -               
34436 -               if (regs.len > SUNGEM_NREGS) {
34437 -                       regs.len = SUNGEM_NREGS;
34438 -               }
34439 -               regs.version = 0;
34440 -               if (copy_to_user(useraddr, &regs, sizeof(regs)))
34441 -                       return -EFAULT;
34442 +       return 0;
34443 +}
34444  
34445 -               if (!gp->hw_running)
34446 -                       return -ENODEV;
34447 -               useraddr += offsetof(struct ethtool_regs, data);
34448 +static u32 gem_get_link(struct net_device *dev)
34449 +{
34450 +       struct gem *gp = dev->priv;
34451  
34452 -               /* Use kmalloc to avoid bloating the stack */
34453 -               regbuf = kmalloc(4 * SUNGEM_NREGS, GFP_KERNEL);
34454 -               if (!regbuf)
34455 -                       return -ENOMEM;
34456 -               spin_lock_irq(&np->lock);
34457 -               gem_get_regs(gp, regbuf);
34458 -               spin_unlock_irq(&np->lock);
34459 -
34460 -               if (copy_to_user(useraddr, regbuf, regs.len*sizeof(u32)))
34461 -                       r = -EFAULT;
34462 -               kfree(regbuf);
34463 -               return r;
34464 -       }
34465 -#endif 
34466 -       };
34467 +       return (gp->lstate == link_up);
34468 +}
34469  
34470 -       return -EOPNOTSUPP;
34471 +static u32 gem_get_msglevel(struct net_device *dev)
34472 +{
34473 +       struct gem *gp = dev->priv;
34474 +       return gp->msg_enable;
34475 +}
34476 +  
34477 +static void gem_set_msglevel(struct net_device *dev, u32 value)
34478 +{
34479 +       struct gem *gp = dev->priv;
34480 +       gp->msg_enable = value;
34481  }
34482 +  
34483 +static struct ethtool_ops gem_ethtool_ops = {
34484 +       .get_drvinfo            = gem_get_drvinfo,
34485 +       .get_link               = ethtool_op_get_link,
34486 +       .get_settings           = gem_get_settings,
34487 +       .set_settings           = gem_set_settings,
34488 +       .nway_reset             = gem_nway_reset,
34489 +       .get_link               = gem_get_link,
34490 +       .get_msglevel           = gem_get_msglevel,
34491 +       .set_msglevel           = gem_set_msglevel,
34492 +};
34493  
34494  static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34495  {
34496 @@ -2501,10 +2458,6 @@
34497         down(&gp->pm_sem);
34498         
34499         switch (cmd) {
34500 -       case SIOCETHTOOL:
34501 -               rc = gem_ethtool_ioctl(dev, ifr->ifr_data);
34502 -               break;
34503 -
34504         case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
34505                 data->phy_id = gp->mii_phy_addr;
34506                 /* Fallthrough... */
34507 @@ -2812,6 +2765,7 @@
34508         dev->get_stats = gem_get_stats;
34509         dev->set_multicast_list = gem_set_multicast;
34510         dev->do_ioctl = gem_ioctl;
34511 +       dev->ethtool_ops = &gem_ethtool_ops;
34512         dev->tx_timeout = gem_tx_timeout;
34513         dev->watchdog_timeo = 5 * HZ;
34514         dev->change_mtu = gem_change_mtu;
34515 diff -Nru a/drivers/net/sungem_phy.c b/drivers/net/sungem_phy.c
34516 --- a/drivers/net/sungem_phy.c  Mon May 19 23:38:25 2003
34517 +++ b/drivers/net/sungem_phy.c  Sun Aug 31 16:14:08 2003
34518 @@ -634,116 +634,116 @@
34519  
34520  /* Broadcom BCM 5201 */
34521  static struct mii_phy_ops bcm5201_phy_ops = {
34522 -       init:           bcm5201_init,
34523 -       suspend:        bcm5201_suspend,
34524 -       setup_aneg:     genmii_setup_aneg,
34525 -       setup_forced:   genmii_setup_forced,
34526 -       poll_link:      genmii_poll_link,
34527 -       read_link:      genmii_read_link,
34528 +       .init           = bcm5201_init,
34529 +       .suspend        = bcm5201_suspend,
34530 +       .setup_aneg     = genmii_setup_aneg,
34531 +       .setup_forced   = genmii_setup_forced,
34532 +       .poll_link      = genmii_poll_link,
34533 +       .read_link      = genmii_read_link,
34534  };
34535  
34536  static struct mii_phy_def bcm5201_phy_def = {
34537 -       phy_id:         0x00406210,
34538 -       phy_id_mask:    0xfffffff0,
34539 -       name:           "BCM5201",
34540 -       features:       MII_BASIC_FEATURES,
34541 -       magic_aneg:     0,
34542 -       ops:            &bcm5201_phy_ops
34543 +       .phy_id         = 0x00406210,
34544 +       .phy_id_mask    = 0xfffffff0,
34545 +       .name           = "BCM5201",
34546 +       .features       = MII_BASIC_FEATURES,
34547 +       .magic_aneg     = 0,
34548 +       .ops            = &bcm5201_phy_ops
34549  };
34550  
34551  /* Broadcom BCM 5221 */
34552  static struct mii_phy_ops bcm5221_phy_ops = {
34553 -       suspend:        bcm5201_suspend,
34554 -       init:           bcm5221_init,
34555 -       setup_aneg:     genmii_setup_aneg,
34556 -       setup_forced:   genmii_setup_forced,
34557 -       poll_link:      genmii_poll_link,
34558 -       read_link:      genmii_read_link,
34559 +       .suspend        = bcm5201_suspend,
34560 +       .init           = bcm5221_init,
34561 +       .setup_aneg     = genmii_setup_aneg,
34562 +       .setup_forced   = genmii_setup_forced,
34563 +       .poll_link      = genmii_poll_link,
34564 +       .read_link      = genmii_read_link,
34565  };
34566  
34567  static struct mii_phy_def bcm5221_phy_def = {
34568 -       phy_id:         0x004061e0,
34569 -       phy_id_mask:    0xfffffff0,
34570 -       name:           "BCM5221",
34571 -       features:       MII_BASIC_FEATURES,
34572 -       magic_aneg:     0,
34573 -       ops:            &bcm5221_phy_ops
34574 +       .phy_id         = 0x004061e0,
34575 +       .phy_id_mask    = 0xfffffff0,
34576 +       .name           = "BCM5221",
34577 +       .features       = MII_BASIC_FEATURES,
34578 +       .magic_aneg     = 0,
34579 +       .ops            = &bcm5221_phy_ops
34580  };
34581  
34582  /* Broadcom BCM 5400 */
34583  static struct mii_phy_ops bcm5400_phy_ops = {
34584 -       init:           bcm5400_init,
34585 -       suspend:        bcm5400_suspend,
34586 -       setup_aneg:     bcm54xx_setup_aneg,
34587 -       setup_forced:   bcm54xx_setup_forced,
34588 -       poll_link:      genmii_poll_link,
34589 -       read_link:      bcm54xx_read_link,
34590 +       .init           = bcm5400_init,
34591 +       .suspend        = bcm5400_suspend,
34592 +       .setup_aneg     = bcm54xx_setup_aneg,
34593 +       .setup_forced   = bcm54xx_setup_forced,
34594 +       .poll_link      = genmii_poll_link,
34595 +       .read_link      = bcm54xx_read_link,
34596  };
34597  
34598  static struct mii_phy_def bcm5400_phy_def = {
34599 -       phy_id:         0x00206040,
34600 -       phy_id_mask:    0xfffffff0,
34601 -       name:           "BCM5400",
34602 -       features:       MII_GBIT_FEATURES,
34603 -       magic_aneg:     1,
34604 -       ops:            &bcm5400_phy_ops
34605 +       .phy_id         = 0x00206040,
34606 +       .phy_id_mask    = 0xfffffff0,
34607 +       .name           = "BCM5400",
34608 +       .features       = MII_GBIT_FEATURES,
34609 +       .magic_aneg     = 1,
34610 +       .ops            = &bcm5400_phy_ops
34611  };
34612  
34613  /* Broadcom BCM 5401 */
34614  static struct mii_phy_ops bcm5401_phy_ops = {
34615 -       init:           bcm5401_init,
34616 -       suspend:        bcm5401_suspend,
34617 -       setup_aneg:     bcm54xx_setup_aneg,
34618 -       setup_forced:   bcm54xx_setup_forced,
34619 -       poll_link:      genmii_poll_link,
34620 -       read_link:      bcm54xx_read_link,
34621 +       .init           = bcm5401_init,
34622 +       .suspend        = bcm5401_suspend,
34623 +       .setup_aneg     = bcm54xx_setup_aneg,
34624 +       .setup_forced   = bcm54xx_setup_forced,
34625 +       .poll_link      = genmii_poll_link,
34626 +       .read_link      = bcm54xx_read_link,
34627  };
34628  
34629  static struct mii_phy_def bcm5401_phy_def = {
34630 -       phy_id:         0x00206050,
34631 -       phy_id_mask:    0xfffffff0,
34632 -       name:           "BCM5401",
34633 -       features:       MII_GBIT_FEATURES,
34634 -       magic_aneg:     1,
34635 -       ops:            &bcm5401_phy_ops
34636 +       .phy_id         = 0x00206050,
34637 +       .phy_id_mask    = 0xfffffff0,
34638 +       .name           = "BCM5401",
34639 +       .features       = MII_GBIT_FEATURES,
34640 +       .magic_aneg     = 1,
34641 +       .ops            = &bcm5401_phy_ops
34642  };
34643  
34644  /* Broadcom BCM 5411 */
34645  static struct mii_phy_ops bcm5411_phy_ops = {
34646 -       init:           bcm5411_init,
34647 -       suspend:        bcm5411_suspend,
34648 -       setup_aneg:     bcm54xx_setup_aneg,
34649 -       setup_forced:   bcm54xx_setup_forced,
34650 -       poll_link:      genmii_poll_link,
34651 -       read_link:      bcm54xx_read_link,
34652 +       .init           = bcm5411_init,
34653 +       .suspend        = bcm5411_suspend,
34654 +       .setup_aneg     = bcm54xx_setup_aneg,
34655 +       .setup_forced   = bcm54xx_setup_forced,
34656 +       .poll_link      = genmii_poll_link,
34657 +       .read_link      = bcm54xx_read_link,
34658  };
34659  
34660  static struct mii_phy_def bcm5411_phy_def = {
34661 -       phy_id:         0x00206070,
34662 -       phy_id_mask:    0xfffffff0,
34663 -       name:           "BCM5411",
34664 -       features:       MII_GBIT_FEATURES,
34665 -       magic_aneg:     1,
34666 -       ops:            &bcm5411_phy_ops
34667 +       .phy_id         = 0x00206070,
34668 +       .phy_id_mask    = 0xfffffff0,
34669 +       .name           = "BCM5411",
34670 +       .features       = MII_GBIT_FEATURES,
34671 +       .magic_aneg     = 1,
34672 +       .ops            = &bcm5411_phy_ops
34673  };
34674  
34675  /* Broadcom BCM 5421 */
34676  static struct mii_phy_ops bcm5421_phy_ops = {
34677 -       init:           bcm5421_init,
34678 -       suspend:        bcm5411_suspend,
34679 -       setup_aneg:     bcm54xx_setup_aneg,
34680 -       setup_forced:   bcm54xx_setup_forced,
34681 -       poll_link:      genmii_poll_link,
34682 -       read_link:      bcm54xx_read_link,
34683 +       .init           = bcm5421_init,
34684 +       .suspend        = bcm5411_suspend,
34685 +       .setup_aneg     = bcm54xx_setup_aneg,
34686 +       .setup_forced   = bcm54xx_setup_forced,
34687 +       .poll_link      = genmii_poll_link,
34688 +       .read_link      = bcm54xx_read_link,
34689  };
34690  
34691  static struct mii_phy_def bcm5421_phy_def = {
34692 -       phy_id:         0x002060e0,
34693 -       phy_id_mask:    0xfffffff0,
34694 -       name:           "BCM5421",
34695 -       features:       MII_GBIT_FEATURES,
34696 -       magic_aneg:     1,
34697 -       ops:            &bcm5421_phy_ops
34698 +       .phy_id         = 0x002060e0,
34699 +       .phy_id_mask    = 0xfffffff0,
34700 +       .name           = "BCM5421",
34701 +       .features       = MII_GBIT_FEATURES,
34702 +       .magic_aneg     = 1,
34703 +       .ops            = &bcm5421_phy_ops
34704  };
34705  
34706  /* Marvell 88E1101 (Apple seem to deal with 2 different revs,
34707 @@ -751,36 +751,36 @@
34708   * would be useful here) --BenH.
34709   */
34710  static struct mii_phy_ops marvell_phy_ops = {
34711 -       setup_aneg:     marvell_setup_aneg,
34712 -       setup_forced:   marvell_setup_forced,
34713 -       poll_link:      genmii_poll_link,
34714 -       read_link:      marvell_read_link
34715 +       .setup_aneg     = marvell_setup_aneg,
34716 +       .setup_forced   = marvell_setup_forced,
34717 +       .poll_link      = genmii_poll_link,
34718 +       .read_link      = marvell_read_link
34719  };
34720  
34721  static struct mii_phy_def marvell_phy_def = {
34722 -       phy_id:         0x01410c00,
34723 -       phy_id_mask:    0xffffff00,
34724 -       name:           "Marvell 88E1101",
34725 -       features:       MII_GBIT_FEATURES,
34726 -       magic_aneg:     1,
34727 -       ops:            &marvell_phy_ops
34728 +       .phy_id         = 0x01410c00,
34729 +       .phy_id_mask    = 0xffffff00,
34730 +       .name           = "Marvell 88E1101",
34731 +       .features       = MII_GBIT_FEATURES,
34732 +       .magic_aneg     = 1,
34733 +       .ops            = &marvell_phy_ops
34734  };
34735  
34736  /* Generic implementation for most 10/100 PHYs */
34737  static struct mii_phy_ops generic_phy_ops = {
34738 -       setup_aneg:     genmii_setup_aneg,
34739 -       setup_forced:   genmii_setup_forced,
34740 -       poll_link:      genmii_poll_link,
34741 -       read_link:      genmii_read_link
34742 +       .setup_aneg     = genmii_setup_aneg,
34743 +       .setup_forced   = genmii_setup_forced,
34744 +       .poll_link      = genmii_poll_link,
34745 +       .read_link      = genmii_read_link
34746  };
34747  
34748  static struct mii_phy_def genmii_phy_def = {
34749 -       phy_id:         0x00000000,
34750 -       phy_id_mask:    0x00000000,
34751 -       name:           "Generic MII",
34752 -       features:       MII_BASIC_FEATURES,
34753 -       magic_aneg:     0,
34754 -       ops:            &generic_phy_ops
34755 +       .phy_id         = 0x00000000,
34756 +       .phy_id_mask    = 0x00000000,
34757 +       .name           = "Generic MII",
34758 +       .features       = MII_BASIC_FEATURES,
34759 +       .magic_aneg     = 0,
34760 +       .ops            = &generic_phy_ops
34761  };
34762  
34763  static struct mii_phy_def* mii_phy_table[] = {
34764 diff -Nru a/drivers/net/sunhme.c b/drivers/net/sunhme.c
34765 --- a/drivers/net/sunhme.c      Tue Aug 19 20:53:16 2003
34766 +++ b/drivers/net/sunhme.c      Sun Aug 24 05:58:18 2003
34767 @@ -3,7 +3,7 @@
34768   *           auto carrier detecting ethernet driver.  Also known as the
34769   *           "Happy Meal Ethernet" found on SunSwift SBUS cards.
34770   *
34771 - * Copyright (C) 1996, 1998, 1999, 2002 David S. Miller (davem@redhat.com)
34772 + * Copyright (C) 1996, 1998, 1999, 2002, 2003 David S. Miller (davem@redhat.com)
34773   *
34774   * Changes :
34775   * 2000/11/11 Willy Tarreau <willy AT meta-x.org>
34776 @@ -14,7 +14,7 @@
34777   */
34778  
34779  static char version[] =
34780 -        "sunhme.c:v2.01 26/Mar/2002 David S. Miller (davem@redhat.com)\n";
34781 +        "sunhme.c:v2.02 24/Aug/2003 David S. Miller (davem@redhat.com)\n";
34782  
34783  #include <linux/module.h>
34784  #include <linux/config.h>
34785 @@ -2426,85 +2426,109 @@
34786  }
34787  
34788  /* Ethtool support... */
34789 -static int happy_meal_ioctl(struct net_device *dev,
34790 -                           struct ifreq *rq, int cmd)
34791 +static int hme_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
34792  {
34793         struct happy_meal *hp = dev->priv;
34794 -       struct ethtool_cmd *ep_user = (struct ethtool_cmd *) rq->ifr_data;
34795 -       struct ethtool_cmd ecmd;
34796  
34797 -       if (cmd != SIOCETHTOOL)
34798 -               return -EOPNOTSUPP;
34799 -       if (copy_from_user(&ecmd, ep_user, sizeof(ecmd)))
34800 -               return -EFAULT;
34801 -
34802 -       if (ecmd.cmd == ETHTOOL_GSET) {
34803 -               ecmd.supported =
34804 -                       (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
34805 -                        SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
34806 -                        SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII);
34807 -
34808 -               /* XXX hardcoded stuff for now */
34809 -               ecmd.port = PORT_TP; /* XXX no MII support */
34810 -               ecmd.transceiver = XCVR_INTERNAL; /* XXX no external xcvr support */
34811 -               ecmd.phy_address = 0; /* XXX fixed PHYAD */
34812 -
34813 -               /* Record PHY settings. */
34814 -               spin_lock_irq(&hp->happy_lock);
34815 -               hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR);
34816 -               hp->sw_lpa = happy_meal_tcvr_read(hp, hp->tcvregs, MII_LPA);
34817 -               spin_unlock_irq(&hp->happy_lock);
34818 +       cmd->supported =
34819 +               (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
34820 +                SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
34821 +                SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII);
34822 +
34823 +       /* XXX hardcoded stuff for now */
34824 +       cmd->port = PORT_TP; /* XXX no MII support */
34825 +       cmd->transceiver = XCVR_INTERNAL; /* XXX no external xcvr support */
34826 +       cmd->phy_address = 0; /* XXX fixed PHYAD */
34827  
34828 -               if (hp->sw_bmcr & BMCR_ANENABLE) {
34829 -                       ecmd.autoneg = AUTONEG_ENABLE;
34830 -                       ecmd.speed =
34831 -                               (hp->sw_lpa & (LPA_100HALF | LPA_100FULL)) ?
34832 -                               SPEED_100 : SPEED_10;
34833 -                       if (ecmd.speed == SPEED_100)
34834 -                               ecmd.duplex =
34835 -                                       (hp->sw_lpa & (LPA_100FULL)) ?
34836 -                                       DUPLEX_FULL : DUPLEX_HALF;
34837 -                       else
34838 -                               ecmd.duplex =
34839 -                                       (hp->sw_lpa & (LPA_10FULL)) ?
34840 -                                       DUPLEX_FULL : DUPLEX_HALF;
34841 -               } else {
34842 -                       ecmd.autoneg = AUTONEG_DISABLE;
34843 -                       ecmd.speed =
34844 -                               (hp->sw_bmcr & BMCR_SPEED100) ?
34845 -                               SPEED_100 : SPEED_10;
34846 -                       ecmd.duplex =
34847 -                               (hp->sw_bmcr & BMCR_FULLDPLX) ?
34848 +       /* Record PHY settings. */
34849 +       spin_lock_irq(&hp->happy_lock);
34850 +       hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR);
34851 +       hp->sw_lpa = happy_meal_tcvr_read(hp, hp->tcvregs, MII_LPA);
34852 +       spin_unlock_irq(&hp->happy_lock);
34853 +
34854 +       if (hp->sw_bmcr & BMCR_ANENABLE) {
34855 +               cmd->autoneg = AUTONEG_ENABLE;
34856 +               cmd->speed =
34857 +                       (hp->sw_lpa & (LPA_100HALF | LPA_100FULL)) ?
34858 +                       SPEED_100 : SPEED_10;
34859 +               if (cmd->speed == SPEED_100)
34860 +                       cmd->duplex =
34861 +                               (hp->sw_lpa & (LPA_100FULL)) ?
34862                                 DUPLEX_FULL : DUPLEX_HALF;
34863 -               }
34864 -               if (copy_to_user(ep_user, &ecmd, sizeof(ecmd)))
34865 -                       return -EFAULT;
34866 -               return 0;
34867 -       } else if (ecmd.cmd == ETHTOOL_SSET) {
34868 -               /* Verify the settings we care about. */
34869 -               if (ecmd.autoneg != AUTONEG_ENABLE &&
34870 -                   ecmd.autoneg != AUTONEG_DISABLE)
34871 -                       return -EINVAL;
34872 -               if (ecmd.autoneg == AUTONEG_DISABLE &&
34873 -                   ((ecmd.speed != SPEED_100 &&
34874 -                     ecmd.speed != SPEED_10) ||
34875 -                    (ecmd.duplex != DUPLEX_HALF &&
34876 -                     ecmd.duplex != DUPLEX_FULL)))
34877 -                       return -EINVAL;
34878 -
34879 -               /* Ok, do it to it. */
34880 -               spin_lock_irq(&hp->happy_lock);
34881 -               del_timer(&hp->happy_timer);
34882 -               happy_meal_begin_auto_negotiation(hp,
34883 -                                                 hp->tcvregs,
34884 -                                                 &ecmd);
34885 -               spin_unlock_irq(&hp->happy_lock);
34886 +               else
34887 +                       cmd->duplex =
34888 +                               (hp->sw_lpa & (LPA_10FULL)) ?
34889 +                               DUPLEX_FULL : DUPLEX_HALF;
34890 +       } else {
34891 +               cmd->autoneg = AUTONEG_DISABLE;
34892 +               cmd->speed =
34893 +                       (hp->sw_bmcr & BMCR_SPEED100) ?
34894 +                       SPEED_100 : SPEED_10;
34895 +               cmd->duplex =
34896 +                       (hp->sw_bmcr & BMCR_FULLDPLX) ?
34897 +                       DUPLEX_FULL : DUPLEX_HALF;
34898 +       }
34899 +       return 0;
34900 +}
34901  
34902 -               return 0;
34903 -       } else
34904 -               return -EOPNOTSUPP;
34905 +static int hme_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
34906 +{
34907 +       struct happy_meal *hp = dev->priv;
34908 +
34909 +       /* Verify the settings we care about. */
34910 +       if (cmd->autoneg != AUTONEG_ENABLE &&
34911 +           cmd->autoneg != AUTONEG_DISABLE)
34912 +               return -EINVAL;
34913 +       if (cmd->autoneg == AUTONEG_DISABLE &&
34914 +           ((cmd->speed != SPEED_100 &&
34915 +             cmd->speed != SPEED_10) ||
34916 +            (cmd->duplex != DUPLEX_HALF &&
34917 +             cmd->duplex != DUPLEX_FULL)))
34918 +               return -EINVAL;
34919 +
34920 +       /* Ok, do it to it. */
34921 +       spin_lock_irq(&hp->happy_lock);
34922 +       del_timer(&hp->happy_timer);
34923 +       happy_meal_begin_auto_negotiation(hp, hp->tcvregs, cmd);
34924 +       spin_unlock_irq(&hp->happy_lock);
34925 +
34926 +       return 0;
34927 +}
34928 +
34929 +static void hme_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
34930 +{
34931 +       struct happy_meal *hp = dev->priv;
34932 +
34933 +       strcpy(info->driver, "sunhme");
34934 +       strcpy(info->version, "2.02");
34935 +       if (hp->happy_flags & HFLAG_PCI) {
34936 +               struct pci_dev *pdev = hp->happy_dev;
34937 +               strcpy(info->bus_info, pci_name(pdev));
34938 +       } else {
34939 +               struct sbus_dev *sdev = hp->happy_dev;
34940 +               sprintf(info->bus_info, "SBUS:%d",
34941 +                       sdev->slot);
34942 +       }
34943  }
34944  
34945 +static u32 hme_get_link(struct net_device *dev)
34946 +{
34947 +       struct happy_meal *hp = dev->priv;
34948 +
34949 +       spin_lock_irq(&hp->happy_lock);
34950 +       hp->sw_bmcr = happy_meal_tcvr_read(hp, hp->tcvregs, MII_BMCR);
34951 +       spin_unlock_irq(&hp->happy_lock);
34952 +
34953 +       return (hp->sw_bmsr & BMSR_LSTATUS);
34954 +}
34955 +
34956 +static struct ethtool_ops hme_ethtool_ops = {
34957 +       .get_settings           = hme_get_settings,
34958 +       .set_settings           = hme_set_settings,
34959 +       .get_drvinfo            = hme_get_drvinfo,
34960 +       .get_link               = hme_get_link,
34961 +};
34962 +
34963  static int hme_version_printed;
34964  
34965  #ifdef CONFIG_SBUS
34966 @@ -2797,7 +2821,7 @@
34967         dev->set_multicast_list = &happy_meal_set_multicast;
34968         dev->tx_timeout = &happy_meal_tx_timeout;
34969         dev->watchdog_timeo = 5*HZ;
34970 -       dev->do_ioctl = &happy_meal_ioctl;
34971 +       dev->ethtool_ops = &hme_ethtool_ops;
34972  
34973         /* Happy Meal can do it all... except VLAN. */
34974         dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_VLAN_CHALLENGED;
34975 @@ -3141,7 +3165,7 @@
34976         dev->set_multicast_list = &happy_meal_set_multicast;
34977         dev->tx_timeout = &happy_meal_tx_timeout;
34978         dev->watchdog_timeo = 5*HZ;
34979 -       dev->do_ioctl = &happy_meal_ioctl;
34980 +       dev->ethtool_ops = &hme_ethtool_ops;
34981         dev->irq = pdev->irq;
34982         dev->dma = 0;
34983  
34984 diff -Nru a/drivers/net/sunlance.c b/drivers/net/sunlance.c
34985 --- a/drivers/net/sunlance.c    Tue Aug 19 20:53:17 2003
34986 +++ b/drivers/net/sunlance.c    Sun Aug 24 05:58:18 2003
34987 @@ -70,7 +70,7 @@
34988  #undef DEBUG_DRIVER
34989  
34990  static char version[] =
34991 -       "sunlance.c:v2.01 08/Nov/01 Miguel de Icaza (miguel@nuclecu.unam.mx)\n";
34992 +       "sunlance.c:v2.02 24/Aug/03 Miguel de Icaza (miguel@nuclecu.unam.mx)\n";
34993  
34994  static char lancestr[] = "LANCE";
34995  
34996 @@ -93,6 +93,7 @@
34997  #include <linux/netdevice.h>
34998  #include <linux/etherdevice.h>
34999  #include <linux/skbuff.h>
35000 +#include <linux/ethtool.h>
35001  
35002  #include <asm/system.h>
35003  #include <asm/bitops.h>
35004 @@ -1287,6 +1288,30 @@
35005         }
35006  }
35007  
35008 +/* Ethtool support... */
35009 +static void sparc_lance_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
35010 +{
35011 +       struct lance_private *lp = dev->priv;
35012 +
35013 +       strcpy(info->driver, "sunlance");
35014 +       strcpy(info->version, "2.02");
35015 +       sprintf(info->bus_info, "SBUS:%d",
35016 +               lp->sdev->slot);
35017 +}
35018 +
35019 +static u32 sparc_lance_get_link(struct net_device *dev)
35020 +{
35021 +       /* We really do not keep track of this, but this
35022 +        * is better than not reporting anything at all.
35023 +        */
35024 +       return 1;
35025 +}
35026 +
35027 +static struct ethtool_ops sparc_lance_ethtool_ops = {
35028 +       .get_drvinfo            = sparc_lance_get_drvinfo,
35029 +       .get_link               = sparc_lance_get_link,
35030 +};
35031 +
35032  static int __init sparc_lance_init(struct net_device *dev,
35033                                    struct sbus_dev *sdev,
35034                                    struct sbus_dma *ledma,
35035 @@ -1456,6 +1481,7 @@
35036         dev->watchdog_timeo = 5*HZ;
35037         dev->get_stats = &lance_get_stats;
35038         dev->set_multicast_list = &lance_set_multicast;
35039 +       dev->ethtool_ops = &sparc_lance_ethtool_ops;
35040  
35041         dev->irq = sdev->irqs[0];
35042  
35043 diff -Nru a/drivers/net/sunqe.c b/drivers/net/sunqe.c
35044 --- a/drivers/net/sunqe.c       Tue Aug 19 20:53:17 2003
35045 +++ b/drivers/net/sunqe.c       Sun Aug 24 05:58:18 2003
35046 @@ -4,11 +4,11 @@
35047   *          controller out there can be most efficiently programmed
35048   *          if you make it look like a LANCE.
35049   *
35050 - * Copyright (C) 1996, 1999 David S. Miller (davem@redhat.com)
35051 + * Copyright (C) 1996, 1999, 2003 David S. Miller (davem@redhat.com)
35052   */
35053  
35054  static char version[] =
35055 -        "sunqe.c:v2.9 9/11/99 David S. Miller (davem@redhat.com)\n";
35056 +        "sunqe.c:v3.0 8/24/03 David S. Miller (davem@redhat.com)\n";
35057  
35058  #include <linux/module.h>
35059  #include <linux/kernel.h>
35060 @@ -26,6 +26,7 @@
35061  #include <linux/netdevice.h>
35062  #include <linux/etherdevice.h>
35063  #include <linux/skbuff.h>
35064 +#include <linux/ethtool.h>
35065  
35066  #include <asm/system.h>
35067  #include <asm/bitops.h>
35068 @@ -684,6 +685,35 @@
35069         netif_wake_queue(dev);
35070  }
35071  
35072 +/* Ethtool support... */
35073 +static void qe_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
35074 +{
35075 +       struct sunqe *qep = dev->priv;
35076 +
35077 +       strcpy(info->driver, "sunqe");
35078 +       strcpy(info->version, "3.0");
35079 +       sprintf(info->bus_info, "SBUS:%d",
35080 +               qep->qe_sdev->slot);
35081 +}
35082 +
35083 +static u32 qe_get_link(struct net_device *dev)
35084 +{
35085 +       struct sunqe *qep = dev->priv;
35086 +       unsigned long mregs = qep->mregs;
35087 +       u8 phyconfig;
35088 +
35089 +       spin_lock_irq(&qep->lock);
35090 +       phyconfig = sbus_readb(mregs + MREGS_PHYCONFIG);
35091 +       spin_unlock_irq(&qep->lock);
35092 +
35093 +       return (phyconfig & MREGS_PHYCONFIG_LSTAT);
35094 +}
35095 +
35096 +static struct ethtool_ops qe_ethtool_ops = {
35097 +       .get_drvinfo            = qe_get_drvinfo,
35098 +       .get_link               = qe_get_link,
35099 +};
35100 +
35101  /* This is only called once at boot time for each card probed. */
35102  static inline void qec_init_once(struct sunqec *qecp, struct sbus_dev *qsdev)
35103  {
35104 @@ -850,6 +880,7 @@
35105                 qe_devs[i]->watchdog_timeo = 5*HZ;
35106                 qe_devs[i]->irq = sdev->irqs[0];
35107                 qe_devs[i]->dma = 0;
35108 +               qe_devs[i]->ethtool_ops = &qe_ethtool_ops;
35109         }
35110  
35111         /* QEC receives interrupts from each QE, then it sends the actual
35112 diff -Nru a/drivers/net/tg3.c b/drivers/net/tg3.c
35113 --- a/drivers/net/tg3.c Tue Aug 19 20:53:17 2003
35114 +++ b/drivers/net/tg3.c Mon Sep  1 12:14:20 2003
35115 @@ -2,7 +2,7 @@
35116   * tg3.c: Broadcom Tigon3 ethernet driver.
35117   *
35118   * Copyright (C) 2001, 2002, 2003 David S. Miller (davem@redhat.com)
35119 - * Copyright (C) 2001, 2002 Jeff Garzik (jgarzik@pobox.com)
35120 + * Copyright (C) 2001, 2002, 2003 Jeff Garzik (jgarzik@pobox.com)
35121   */
35122  
35123  #include <linux/config.h>
35124 @@ -27,6 +27,8 @@
35125  #include <linux/tcp.h>
35126  #include <linux/workqueue.h>
35127  
35128 +#include <net/checksum.h>
35129 +
35130  #include <asm/system.h>
35131  #include <asm/io.h>
35132  #include <asm/byteorder.h>
35133 @@ -45,20 +47,17 @@
35134  #endif
35135  
35136  #ifdef NETIF_F_TSO
35137 -/* XXX Works but still disabled, decreases TCP performance to 7MB/sec even
35138 - * XXX over gigabit.
35139 - */
35140 -#define TG3_DO_TSO     0
35141 +#define TG3_TSO_SUPPORT        1
35142  #else
35143 -#define TG3_DO_TSO     0
35144 +#define TG3_TSO_SUPPORT        0
35145  #endif
35146  
35147  #include "tg3.h"
35148  
35149  #define DRV_MODULE_NAME                "tg3"
35150  #define PFX DRV_MODULE_NAME    ": "
35151 -#define DRV_MODULE_VERSION     "1.9"
35152 -#define DRV_MODULE_RELDATE     "August 3, 2003"
35153 +#define DRV_MODULE_VERSION     "2.2"
35154 +#define DRV_MODULE_RELDATE     "August 24, 2003"
35155  
35156  #define TG3_DEF_MAC_MODE       0
35157  #define TG3_DEF_RX_MODE                0
35158 @@ -80,7 +79,8 @@
35159  
35160  /* hardware minimum and maximum for a single frame's data payload */
35161  #define TG3_MIN_MTU                    60
35162 -#define TG3_MAX_MTU                    9000
35163 +#define TG3_MAX_MTU(tp)        \
35164 +       (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 ? 9000 : 1500)
35165  
35166  /* These numbers seem to be hard coded in the NIC firmware somehow.
35167   * You can't change the ring sizes, but you can change where you place
35168 @@ -90,7 +90,17 @@
35169  #define TG3_DEF_RX_RING_PENDING                200
35170  #define TG3_RX_JUMBO_RING_SIZE         256
35171  #define TG3_DEF_RX_JUMBO_RING_PENDING  100
35172 -#define TG3_RX_RCB_RING_SIZE           1024
35173 +
35174 +/* Do not place this n-ring entries value into the tp struct itself,
35175 + * we really want to expose these constants to GCC so that modulo et
35176 + * al.  operations are done with shifts and masks instead of with
35177 + * hw multiply/modulo instructions.  Another solution would be to
35178 + * replace things like '% foo' with '& (foo - 1)'.
35179 + */
35180 +#define TG3_RX_RCB_RING_SIZE(tp)       \
35181 +       (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ? \
35182 +        512 : 1024)
35183 +
35184  #define TG3_TX_RING_SIZE               512
35185  #define TG3_DEF_TX_RING_PENDING                (TG3_TX_RING_SIZE - 1)
35186  
35187 @@ -98,8 +108,8 @@
35188                                  TG3_RX_RING_SIZE)
35189  #define TG3_RX_JUMBO_RING_BYTES        (sizeof(struct tg3_rx_buffer_desc) * \
35190                                  TG3_RX_JUMBO_RING_SIZE)
35191 -#define TG3_RX_RCB_RING_BYTES  (sizeof(struct tg3_rx_buffer_desc) * \
35192 -                                TG3_RX_RCB_RING_SIZE)
35193 +#define TG3_RX_RCB_RING_BYTES(tp) (sizeof(struct tg3_rx_buffer_desc) * \
35194 +                                  TG3_RX_RCB_RING_SIZE(tp))
35195  #define TG3_TX_RING_BYTES      (sizeof(struct tg3_tx_buffer_desc) * \
35196                                  TG3_TX_RING_SIZE)
35197  #define TX_RING_GAP(TP)        \
35198 @@ -140,6 +150,14 @@
35199           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35200         { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5702FE,
35201           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35202 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5705,
35203 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35204 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5705_2,
35205 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35206 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5705M,
35207 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35208 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5705M_2,
35209 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35210         { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5702X,
35211           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35212         { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5703X,
35213 @@ -150,12 +168,24 @@
35214           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35215         { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5703A3,
35216           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35217 -       { PCI_VENDOR_ID_SYSKONNECT, 0x4400,
35218 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5782,
35219 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35220 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5788,
35221 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35222 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5901,
35223 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35224 +       { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5901_2,
35225 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35226 +       { PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_9DXX,
35227 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35228 +       { PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_9MXX,
35229           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35230         { PCI_VENDOR_ID_ALTIMA, PCI_DEVICE_ID_ALTIMA_AC1000,
35231           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35232         { PCI_VENDOR_ID_ALTIMA, PCI_DEVICE_ID_ALTIMA_AC1001,
35233           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35234 +       { PCI_VENDOR_ID_ALTIMA, PCI_DEVICE_ID_ALTIMA_AC1003,
35235 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35236         { PCI_VENDOR_ID_ALTIMA, PCI_DEVICE_ID_ALTIMA_AC9100,
35237           PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
35238         { 0, }
35239 @@ -237,38 +267,6 @@
35240         tg3_cond_int(tp);
35241  }
35242  
35243 -/* these netif_xxx funcs should be moved into generic net layer */
35244 -static void netif_poll_disable(struct net_device *dev)
35245 -{
35246 -       while (test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state)) {
35247 -               current->state = TASK_INTERRUPTIBLE;
35248 -               schedule_timeout(1);
35249 -       }
35250 -}
35251 -
35252 -static inline void netif_poll_enable(struct net_device *dev)
35253 -{
35254 -       clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
35255 -}
35256 -
35257 -/* same as netif_rx_complete, except that local_irq_save(flags)
35258 - * has already been issued
35259 - */
35260 -static inline void __netif_rx_complete(struct net_device *dev)
35261 -{
35262 -       if (!test_bit(__LINK_STATE_RX_SCHED, &dev->state)) BUG();
35263 -       list_del(&dev->poll_list);
35264 -       smp_mb__before_clear_bit();
35265 -       clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
35266 -}
35267 -
35268 -static inline void netif_tx_disable(struct net_device *dev)
35269 -{
35270 -       spin_lock_bh(&dev->xmit_lock);
35271 -       netif_stop_queue(dev);
35272 -       spin_unlock_bh(&dev->xmit_lock);
35273 -}
35274 -
35275  static inline void tg3_netif_stop(struct tg3 *tp)
35276  {
35277         netif_poll_disable(tp->dev);
35278 @@ -288,17 +286,28 @@
35279  
35280  static void tg3_switch_clocks(struct tg3 *tp)
35281  {
35282 -       if (tr32(TG3PCI_CLOCK_CTRL) & CLOCK_CTRL_44MHZ_CORE) {
35283 +       u32 clock_ctrl = tr32(TG3PCI_CLOCK_CTRL);
35284 +       u32 orig_clock_ctrl;
35285 +
35286 +       orig_clock_ctrl = clock_ctrl;
35287 +       clock_ctrl &= (CLOCK_CTRL_FORCE_CLKRUN |
35288 +                      CLOCK_CTRL_CLKRUN_OENABLE |
35289 +                      0x1f);
35290 +       tp->pci_clock_ctrl = clock_ctrl;
35291 +
35292 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
35293 +           (orig_clock_ctrl & CLOCK_CTRL_44MHZ_CORE) != 0) {
35294                 tw32(TG3PCI_CLOCK_CTRL,
35295 +                    clock_ctrl |
35296                      (CLOCK_CTRL_44MHZ_CORE | CLOCK_CTRL_ALTCLK));
35297                 tr32(TG3PCI_CLOCK_CTRL);
35298                 udelay(40);
35299                 tw32(TG3PCI_CLOCK_CTRL,
35300 -                    (CLOCK_CTRL_ALTCLK));
35301 +                    clock_ctrl | (CLOCK_CTRL_ALTCLK));
35302                 tr32(TG3PCI_CLOCK_CTRL);
35303                 udelay(40);
35304         }
35305 -       tw32(TG3PCI_CLOCK_CTRL, 0);
35306 +       tw32(TG3PCI_CLOCK_CTRL, clock_ctrl);
35307         tr32(TG3PCI_CLOCK_CTRL);
35308         udelay(40);
35309  }
35310 @@ -401,24 +410,22 @@
35311         return ret;
35312  }
35313  
35314 -/* This will reset the tigon3 PHY if there is no valid
35315 - * link unless the FORCE argument is non-zero.
35316 - */
35317 -static int tg3_phy_reset(struct tg3 *tp, int force)
35318 +static void tg3_phy_set_wirespeed(struct tg3 *tp)
35319  {
35320 -       u32 phy_status, phy_control;
35321 -       int err, limit;
35322 +       u32 val;
35323  
35324 -       err  = tg3_readphy(tp, MII_BMSR, &phy_status);
35325 -       err |= tg3_readphy(tp, MII_BMSR, &phy_status);
35326 -       if (err != 0)
35327 -               return -EBUSY;
35328 +       if (tp->tg3_flags2 & TG3_FLG2_NO_ETH_WIRE_SPEED)
35329 +               return;
35330  
35331 -       /* If we have link, and not forcing a reset, then nothing
35332 -        * to do.
35333 -        */
35334 -       if ((phy_status & BMSR_LSTATUS) != 0 && (force == 0))
35335 -               return 0;
35336 +       tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x7007);
35337 +       tg3_readphy(tp, MII_TG3_AUX_CTRL, &val);
35338 +       tg3_writephy(tp, MII_TG3_AUX_CTRL, (val | (1 << 15) | (1 << 4)));
35339 +}
35340 +
35341 +static int tg3_bmcr_reset(struct tg3 *tp)
35342 +{
35343 +       u32 phy_control;
35344 +       int limit, err;
35345  
35346         /* OK, reset it, and poll the BMCR_RESET bit until it
35347          * clears or we time out.
35348 @@ -436,12 +443,303 @@
35349  
35350                 if ((phy_control & BMCR_RESET) == 0) {
35351                         udelay(40);
35352 -                       return 0;
35353 +                       break;
35354                 }
35355                 udelay(10);
35356         }
35357 +       if (limit <= 0)
35358 +               return -EBUSY;
35359 +
35360 +       return 0;
35361 +}
35362 +
35363 +static int tg3_wait_macro_done(struct tg3 *tp)
35364 +{
35365 +       int limit = 100;
35366 +
35367 +       while (limit--) {
35368 +               u32 tmp32;
35369 +
35370 +               tg3_readphy(tp, 0x16, &tmp32);
35371 +               if ((tmp32 & 0x1000) == 0)
35372 +                       break;
35373 +       }
35374 +       if (limit <= 0)
35375 +               return -EBUSY;
35376 +
35377 +       return 0;
35378 +}
35379 +
35380 +static int tg3_phy_write_and_check_testpat(struct tg3 *tp, int *resetp)
35381 +{
35382 +       static const u32 test_pat[4][6] = {
35383 +       { 0x00005555, 0x00000005, 0x00002aaa, 0x0000000a, 0x00003456, 0x00000003 },
35384 +       { 0x00002aaa, 0x0000000a, 0x00003333, 0x00000003, 0x0000789a, 0x00000005 },
35385 +       { 0x00005a5a, 0x00000005, 0x00002a6a, 0x0000000a, 0x00001bcd, 0x00000003 },
35386 +       { 0x00002a5a, 0x0000000a, 0x000033c3, 0x00000003, 0x00002ef1, 0x00000005 }
35387 +       };
35388 +       int chan;
35389 +
35390 +       for (chan = 0; chan < 4; chan++) {
35391 +               int i;
35392 +
35393 +               tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
35394 +                            (chan * 0x2000) | 0x0200);
35395 +               tg3_writephy(tp, 0x16, 0x0002);
35396 +
35397 +               for (i = 0; i < 6; i++)
35398 +                       tg3_writephy(tp, MII_TG3_DSP_RW_PORT,
35399 +                                    test_pat[chan][i]);
35400 +
35401 +               tg3_writephy(tp, 0x16, 0x0202);
35402 +               if (tg3_wait_macro_done(tp)) {
35403 +                       *resetp = 1;
35404 +                       return -EBUSY;
35405 +               }
35406 +
35407 +               tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
35408 +                            (chan * 0x2000) | 0x0200);
35409 +               tg3_writephy(tp, 0x16, 0x0082);
35410 +               if (tg3_wait_macro_done(tp)) {
35411 +                       *resetp = 1;
35412 +                       return -EBUSY;
35413 +               }
35414 +
35415 +               tg3_writephy(tp, 0x16, 0x0802);
35416 +               if (tg3_wait_macro_done(tp)) {
35417 +                       *resetp = 1;
35418 +                       return -EBUSY;
35419 +               }
35420 +
35421 +               for (i = 0; i < 6; i += 2) {
35422 +                       u32 low, high;
35423 +
35424 +                       tg3_readphy(tp, MII_TG3_DSP_RW_PORT, &low);
35425 +                       tg3_readphy(tp, MII_TG3_DSP_RW_PORT, &high);
35426 +                       if (tg3_wait_macro_done(tp)) {
35427 +                               *resetp = 1;
35428 +                               return -EBUSY;
35429 +                       }
35430 +                       low &= 0x7fff;
35431 +                       high &= 0x000f;
35432 +                       if (low != test_pat[chan][i] ||
35433 +                           high != test_pat[chan][i+1]) {
35434 +                               tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000b);
35435 +                               tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4001);
35436 +                               tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4005);
35437 +
35438 +                               return -EBUSY;
35439 +                       }
35440 +               }
35441 +       }
35442  
35443 -       return -EBUSY;
35444 +       return 0;
35445 +}
35446 +
35447 +static int tg3_phy_reset_chanpat(struct tg3 *tp)
35448 +{
35449 +       int chan;
35450 +
35451 +       for (chan = 0; chan < 4; chan++) {
35452 +               int i;
35453 +
35454 +               tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
35455 +                            (chan * 0x2000) | 0x0200);
35456 +               tg3_writephy(tp, 0x16, 0x0002);
35457 +               for (i = 0; i < 6; i++)
35458 +                       tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x000);
35459 +               tg3_writephy(tp, 0x16, 0x0202);
35460 +               if (tg3_wait_macro_done(tp))
35461 +                       return -EBUSY;
35462 +       }
35463 +
35464 +       return 0;
35465 +}
35466 +
35467 +static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
35468 +{
35469 +       u32 reg32, phy9_orig;
35470 +       int retries, do_phy_reset, err;
35471 +
35472 +       retries = 10;
35473 +       do_phy_reset = 1;
35474 +       do {
35475 +               if (do_phy_reset) {
35476 +                       err = tg3_bmcr_reset(tp);
35477 +                       if (err)
35478 +                               return err;
35479 +                       do_phy_reset = 0;
35480 +               }
35481 +
35482 +               /* Disable transmitter and interrupt.  */
35483 +               tg3_readphy(tp, MII_TG3_EXT_CTRL, &reg32);
35484 +               reg32 |= 0x3000;
35485 +               tg3_writephy(tp, MII_TG3_EXT_CTRL, reg32);
35486 +
35487 +               /* Set full-duplex, 1000 mbps.  */
35488 +               tg3_writephy(tp, MII_BMCR,
35489 +                            BMCR_FULLDPLX | TG3_BMCR_SPEED1000);
35490 +
35491 +               /* Set to master mode.  */
35492 +               tg3_readphy(tp, MII_TG3_CTRL, &phy9_orig);
35493 +               tg3_writephy(tp, MII_TG3_CTRL,
35494 +                            (MII_TG3_CTRL_AS_MASTER |
35495 +                             MII_TG3_CTRL_ENABLE_AS_MASTER));
35496 +
35497 +               /* Enable SM_DSP_CLOCK and 6dB.  */
35498 +               tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00);
35499 +
35500 +               /* Block the PHY control access.  */
35501 +               tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8005);
35502 +               tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x0800);
35503 +
35504 +               err = tg3_phy_write_and_check_testpat(tp, &do_phy_reset);
35505 +               if (!err)
35506 +                       break;
35507 +       } while (--retries);
35508 +
35509 +       err = tg3_phy_reset_chanpat(tp);
35510 +       if (err)
35511 +               return err;
35512 +
35513 +       tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8005);
35514 +       tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x0000);
35515 +
35516 +       tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8200);
35517 +       tg3_writephy(tp, 0x16, 0x0000);
35518 +
35519 +       tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400);
35520 +
35521 +       tg3_writephy(tp, MII_TG3_CTRL, phy9_orig);
35522 +
35523 +       tg3_readphy(tp, MII_TG3_EXT_CTRL, &reg32);
35524 +       reg32 &= ~0x3000;
35525 +       tg3_writephy(tp, MII_TG3_EXT_CTRL, reg32);
35526 +
35527 +       return err;
35528 +}
35529 +
35530 +/* This will reset the tigon3 PHY if there is no valid
35531 + * link unless the FORCE argument is non-zero.
35532 + */
35533 +static int tg3_phy_reset(struct tg3 *tp, int force)
35534 +{
35535 +       u32 phy_status;
35536 +       int err;
35537 +
35538 +       err  = tg3_readphy(tp, MII_BMSR, &phy_status);
35539 +       err |= tg3_readphy(tp, MII_BMSR, &phy_status);
35540 +       if (err != 0)
35541 +               return -EBUSY;
35542 +
35543 +       /* If we have link, and not forcing a reset, then nothing
35544 +        * to do.
35545 +        */
35546 +       if ((phy_status & BMSR_LSTATUS) != 0 && (force == 0))
35547 +               return 0;
35548 +
35549 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 ||
35550 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 ||
35551 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
35552 +               err = tg3_phy_reset_5703_4_5(tp);
35553 +               if (err)
35554 +                       return err;
35555 +               goto out;
35556 +       }
35557 +
35558 +       err = tg3_bmcr_reset(tp);
35559 +       if (err)
35560 +               return err;
35561 +
35562 +out:
35563 +       tg3_phy_set_wirespeed(tp);
35564 +       return 0;
35565 +}
35566 +
35567 +static void tg3_frob_aux_power(struct tg3 *tp)
35568 +{
35569 +       struct tg3 *tp_peer = tp;
35570 +
35571 +       if ((tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) != 0)
35572 +               return;
35573 +
35574 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
35575 +               tp_peer = pci_get_drvdata(tp->pdev_peer);
35576 +               if (!tp_peer)
35577 +                       BUG();
35578 +       }
35579 +
35580 +
35581 +       if ((tp->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 ||
35582 +           (tp_peer->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0) {
35583 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
35584 +                   GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
35585 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
35586 +                            (GRC_LCLCTRL_GPIO_OE0 |
35587 +                             GRC_LCLCTRL_GPIO_OE1 |
35588 +                             GRC_LCLCTRL_GPIO_OE2 |
35589 +                             GRC_LCLCTRL_GPIO_OUTPUT0 |
35590 +                             GRC_LCLCTRL_GPIO_OUTPUT1));
35591 +                       tr32(GRC_LOCAL_CTRL);
35592 +                       udelay(100);
35593 +               } else {
35594 +                       if (tp_peer != tp &&
35595 +                           (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0)
35596 +                               return;
35597 +
35598 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
35599 +                            (GRC_LCLCTRL_GPIO_OE0 |
35600 +                             GRC_LCLCTRL_GPIO_OE1 |
35601 +                             GRC_LCLCTRL_GPIO_OE2 |
35602 +                             GRC_LCLCTRL_GPIO_OUTPUT1 |
35603 +                             GRC_LCLCTRL_GPIO_OUTPUT2));
35604 +                       tr32(GRC_LOCAL_CTRL);
35605 +                       udelay(100);
35606 +
35607 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
35608 +                            (GRC_LCLCTRL_GPIO_OE0 |
35609 +                             GRC_LCLCTRL_GPIO_OE1 |
35610 +                             GRC_LCLCTRL_GPIO_OE2 |
35611 +                             GRC_LCLCTRL_GPIO_OUTPUT0 |
35612 +                             GRC_LCLCTRL_GPIO_OUTPUT1 |
35613 +                             GRC_LCLCTRL_GPIO_OUTPUT2));
35614 +                       tr32(GRC_LOCAL_CTRL);
35615 +                       udelay(100);
35616 +
35617 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
35618 +                            (GRC_LCLCTRL_GPIO_OE0 |
35619 +                             GRC_LCLCTRL_GPIO_OE1 |
35620 +                             GRC_LCLCTRL_GPIO_OE2 |
35621 +                             GRC_LCLCTRL_GPIO_OUTPUT0 |
35622 +                             GRC_LCLCTRL_GPIO_OUTPUT1));
35623 +                       tr32(GRC_LOCAL_CTRL);
35624 +                       udelay(100);
35625 +               }
35626 +       } else {
35627 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700 &&
35628 +                   GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) {
35629 +                       if (tp_peer != tp &&
35630 +                           (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0)
35631 +                               return;
35632 +
35633 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
35634 +                            (GRC_LCLCTRL_GPIO_OE1 |
35635 +                             GRC_LCLCTRL_GPIO_OUTPUT1));
35636 +                       tr32(GRC_LOCAL_CTRL);
35637 +                       udelay(100);
35638 +
35639 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
35640 +                            (GRC_LCLCTRL_GPIO_OE1));
35641 +                       tr32(GRC_LOCAL_CTRL);
35642 +                       udelay(100);
35643 +
35644 +                       tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
35645 +                            (GRC_LCLCTRL_GPIO_OE1 |
35646 +                             GRC_LCLCTRL_GPIO_OUTPUT1));
35647 +                       tr32(GRC_LOCAL_CTRL);
35648 +                       udelay(100);
35649 +               }
35650 +       }
35651  }
35652  
35653  static int tg3_setup_phy(struct tg3 *);
35654 @@ -547,89 +845,65 @@
35655                 udelay(10);
35656         }
35657  
35658 -       if (tp->tg3_flags & TG3_FLAG_WOL_SPEED_100MB) {
35659 +       if (!(tp->tg3_flags & TG3_FLAG_WOL_SPEED_100MB) &&
35660 +           (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
35661 +            GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)) {
35662                 u32 base_val;
35663  
35664 -               base_val = 0;
35665 -               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
35666 -                   GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)
35667 -                       base_val |= (CLOCK_CTRL_RXCLK_DISABLE |
35668 -                                    CLOCK_CTRL_TXCLK_DISABLE);
35669 -
35670 -               tw32(TG3PCI_CLOCK_CTRL, base_val |
35671 -                    CLOCK_CTRL_ALTCLK);
35672 -               tr32(TG3PCI_CLOCK_CTRL);
35673 -               udelay(40);
35674 +               base_val = tp->pci_clock_ctrl;
35675 +               base_val |= (CLOCK_CTRL_RXCLK_DISABLE |
35676 +                            CLOCK_CTRL_TXCLK_DISABLE);
35677  
35678                 tw32(TG3PCI_CLOCK_CTRL, base_val |
35679                      CLOCK_CTRL_ALTCLK |
35680 -                    CLOCK_CTRL_44MHZ_CORE);
35681 -               tr32(TG3PCI_CLOCK_CTRL);
35682 -               udelay(40);
35683 -
35684 -               tw32(TG3PCI_CLOCK_CTRL, base_val |
35685 -                    CLOCK_CTRL_44MHZ_CORE);
35686 +                    CLOCK_CTRL_PWRDOWN_PLL133);
35687                 tr32(TG3PCI_CLOCK_CTRL);
35688                 udelay(40);
35689         } else {
35690 -               u32 base_val;
35691 +               u32 newbits1, newbits2;
35692  
35693 -               base_val = 0;
35694                 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
35695 -                   GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)
35696 -                       base_val |= (CLOCK_CTRL_RXCLK_DISABLE |
35697 -                                    CLOCK_CTRL_TXCLK_DISABLE);
35698 +                   GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
35699 +                       newbits1 = (CLOCK_CTRL_RXCLK_DISABLE |
35700 +                                   CLOCK_CTRL_TXCLK_DISABLE |
35701 +                                   CLOCK_CTRL_ALTCLK);
35702 +                       newbits2 = newbits1 | CLOCK_CTRL_44MHZ_CORE;
35703 +               } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
35704 +                       newbits1 = CLOCK_CTRL_625_CORE;
35705 +                       newbits2 = newbits1 | CLOCK_CTRL_ALTCLK;
35706 +               } else {
35707 +                       newbits1 = CLOCK_CTRL_ALTCLK;
35708 +                       newbits2 = newbits1 | CLOCK_CTRL_44MHZ_CORE;
35709 +               }
35710  
35711 -               tw32(TG3PCI_CLOCK_CTRL, base_val |
35712 -                    CLOCK_CTRL_ALTCLK |
35713 -                    CLOCK_CTRL_PWRDOWN_PLL133);
35714 +               tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits1);
35715                 tr32(TG3PCI_CLOCK_CTRL);
35716                 udelay(40);
35717 -       }
35718  
35719 -       if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) &&
35720 -           (tp->tg3_flags & TG3_FLAG_WOL_ENABLE)) {
35721 -               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
35722 -                   GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
35723 -                       tw32(GRC_LOCAL_CTRL,
35724 -                            (GRC_LCLCTRL_GPIO_OE0 |
35725 -                             GRC_LCLCTRL_GPIO_OE1 |
35726 -                             GRC_LCLCTRL_GPIO_OE2 |
35727 -                             GRC_LCLCTRL_GPIO_OUTPUT0 |
35728 -                             GRC_LCLCTRL_GPIO_OUTPUT1));
35729 -                       tr32(GRC_LOCAL_CTRL);
35730 -                       udelay(100);
35731 -               } else {
35732 -                       tw32(GRC_LOCAL_CTRL,
35733 -                            (GRC_LCLCTRL_GPIO_OE0 |
35734 -                             GRC_LCLCTRL_GPIO_OE1 |
35735 -                             GRC_LCLCTRL_GPIO_OE2 |
35736 -                             GRC_LCLCTRL_GPIO_OUTPUT1 |
35737 -                             GRC_LCLCTRL_GPIO_OUTPUT2));
35738 -                       tr32(GRC_LOCAL_CTRL);
35739 -                       udelay(100);
35740 +               tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits2);
35741 +               tr32(TG3PCI_CLOCK_CTRL);
35742 +               udelay(40);
35743  
35744 -                       tw32(GRC_LOCAL_CTRL,
35745 -                            (GRC_LCLCTRL_GPIO_OE0 |
35746 -                             GRC_LCLCTRL_GPIO_OE1 |
35747 -                             GRC_LCLCTRL_GPIO_OE2 |
35748 -                             GRC_LCLCTRL_GPIO_OUTPUT0 |
35749 -                             GRC_LCLCTRL_GPIO_OUTPUT1 |
35750 -                             GRC_LCLCTRL_GPIO_OUTPUT2));
35751 -                       tr32(GRC_LOCAL_CTRL);
35752 -                       udelay(100);
35753 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
35754 +                       u32 newbits3;
35755  
35756 -                       tw32(GRC_LOCAL_CTRL,
35757 -                            (GRC_LCLCTRL_GPIO_OE0 |
35758 -                             GRC_LCLCTRL_GPIO_OE1 |
35759 -                             GRC_LCLCTRL_GPIO_OE2 |
35760 -                             GRC_LCLCTRL_GPIO_OUTPUT0 |
35761 -                             GRC_LCLCTRL_GPIO_OUTPUT1));
35762 -                       tr32(GRC_LOCAL_CTRL);
35763 -                       udelay(100);
35764 +                       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
35765 +                           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
35766 +                               newbits3 = (CLOCK_CTRL_RXCLK_DISABLE |
35767 +                                           CLOCK_CTRL_TXCLK_DISABLE |
35768 +                                           CLOCK_CTRL_44MHZ_CORE);
35769 +                       } else {
35770 +                               newbits3 = CLOCK_CTRL_44MHZ_CORE;
35771 +                       }
35772 +
35773 +                       tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits3);
35774 +                       tr32(TG3PCI_CLOCK_CTRL);
35775 +                       udelay(40);
35776                 }
35777         }
35778  
35779 +       tg3_frob_aux_power(tp);
35780 +
35781         /* Finally, set the new power state. */
35782         pci_write_config_word(tp->pdev, pm + PCI_PM_CTRL, power_control);
35783  
35784 @@ -948,11 +1222,10 @@
35785  
35786         /* Some third-party PHYs need to be reset on link going
35787          * down.
35788 -        *
35789 -        * XXX 5705 note: This workaround also applies to 5705_a0
35790          */
35791         if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 ||
35792 -            GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) &&
35793 +            GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 ||
35794 +            tp->pci_chip_rev_id == CHIPREV_ID_5705_A0) &&
35795             netif_carrier_ok(tp->dev)) {
35796                 tg3_readphy(tp, MII_BMSR, &bmsr);
35797                 tg3_readphy(tp, MII_BMSR, &bmsr);
35798 @@ -1942,7 +2215,7 @@
35799         int received;
35800  
35801         hw_idx = tp->hw_status->idx[0].rx_producer;
35802 -       sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE;
35803 +       sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp);
35804         work_mask = 0;
35805         received = 0;
35806         while (sw_idx != hw_idx && budget > 0) {
35807 @@ -2043,13 +2316,13 @@
35808                 (*post_ptr)++;
35809  next_pkt_nopost:
35810                 rx_rcb_ptr++;
35811 -               sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE;
35812 +               sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp);
35813         }
35814  
35815         /* ACK the status ring. */
35816         tp->rx_rcb_ptr = rx_rcb_ptr;
35817         tw32_mailbox(MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW,
35818 -                    (rx_rcb_ptr % TG3_RX_RCB_RING_SIZE));
35819 +                    (rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp)));
35820         if (tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER)
35821                 tr32(MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW);
35822  
35823 @@ -2388,19 +2661,34 @@
35824         base_flags = 0;
35825         if (skb->ip_summed == CHECKSUM_HW)
35826                 base_flags |= TXD_FLAG_TCPUDP_CSUM;
35827 -#if TG3_DO_TSO != 0
35828 -       if ((mss = skb_shinfo(skb)->tso_size) != 0) {
35829 -               static int times = 0;
35830 +#if TG3_TSO_SUPPORT != 0
35831 +       mss = 0;
35832 +       if (skb->len > (tp->dev->mtu + ETH_HLEN) &&
35833 +           (mss = skb_shinfo(skb)->tso_size) != 0) {
35834 +               int tcp_opt_len, ip_tcp_len;
35835 +
35836 +               tcp_opt_len = ((skb->h.th->doff - 5) * 4);
35837 +               ip_tcp_len = (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr);
35838  
35839 -               mss += ((skb->h.th->doff * 4) - 20);
35840                 base_flags |= (TXD_FLAG_CPU_PRE_DMA |
35841                                TXD_FLAG_CPU_POST_DMA);
35842  
35843 -               if (times++ < 5) {
35844 -                       printk("tg3_xmit: tso_size[%u] tso_segs[%u] len[%u]\n",
35845 -                              (unsigned int) skb_shinfo(skb)->tso_size,
35846 -                              (unsigned int) skb_shinfo(skb)->tso_segs,
35847 -                              skb->len);
35848 +               skb->nh.iph->check = 0;
35849 +               skb->nh.iph->tot_len = ntohs(mss + ip_tcp_len + tcp_opt_len);
35850 +               skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
35851 +                                                     skb->nh.iph->daddr,
35852 +                                                     0, IPPROTO_TCP, 0);
35853 +
35854 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
35855 +                       if (tcp_opt_len || skb->nh.iph->ihl > 5) {
35856 +                               int tsflags;
35857 +
35858 +                               tsflags = ((skb->nh.iph->ihl - 5) +
35859 +                                          (tcp_opt_len >> 2));
35860 +                               mss |= (tsflags << 11);
35861 +                       }
35862 +               } else {
35863 +                       mss += tcp_opt_len;
35864                 }
35865         }
35866  #else
35867 @@ -2580,23 +2868,34 @@
35868         base_flags = 0;
35869         if (skb->ip_summed == CHECKSUM_HW)
35870                 base_flags |= TXD_FLAG_TCPUDP_CSUM;
35871 -#if TG3_DO_TSO != 0
35872 -       if ((mss = skb_shinfo(skb)->tso_size) != 0) {
35873 -               static int times = 0;
35874 +#if TG3_TSO_SUPPORT != 0
35875 +       mss = 0;
35876 +       if (skb->len > (tp->dev->mtu + ETH_HLEN) &&
35877 +           (mss = skb_shinfo(skb)->tso_size) != 0) {
35878 +               int tcp_opt_len, ip_tcp_len;
35879  
35880 -               /* TSO firmware wants TCP options included in
35881 -                * tx descriptor MSS value.
35882 -                */
35883 -               mss += ((skb->h.th->doff * 4) - 20);
35884 +               tcp_opt_len = ((skb->h.th->doff - 5) * 4);
35885 +               ip_tcp_len = (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr);
35886  
35887                 base_flags |= (TXD_FLAG_CPU_PRE_DMA |
35888                                TXD_FLAG_CPU_POST_DMA);
35889  
35890 -               if (times++ < 5) {
35891 -                       printk("tg3_xmit: tso_size[%u] tso_segs[%u] len[%u]\n",
35892 -                              (unsigned int) skb_shinfo(skb)->tso_size,
35893 -                              (unsigned int) skb_shinfo(skb)->tso_segs,
35894 -                              skb->len);
35895 +               skb->nh.iph->check = 0;
35896 +               skb->nh.iph->tot_len = ntohs(mss + ip_tcp_len + tcp_opt_len);
35897 +               skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
35898 +                                                     skb->nh.iph->daddr,
35899 +                                                     0, IPPROTO_TCP, 0);
35900 +
35901 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
35902 +                       if (tcp_opt_len || skb->nh.iph->ihl > 5) {
35903 +                               int tsflags;
35904 +
35905 +                               tsflags = ((skb->nh.iph->ihl - 5) +
35906 +                                          (tcp_opt_len >> 2));
35907 +                               mss |= (tsflags << 11);
35908 +                       }
35909 +               } else {
35910 +                       mss += tcp_opt_len;
35911                 }
35912         }
35913  #else
35914 @@ -2698,7 +2997,7 @@
35915  {
35916         struct tg3 *tp = dev->priv;
35917  
35918 -       if (new_mtu < TG3_MIN_MTU || new_mtu > TG3_MAX_MTU)
35919 +       if (new_mtu < TG3_MIN_MTU || new_mtu > TG3_MAX_MTU(tp))
35920                 return -EINVAL;
35921  
35922         if (!netif_running(dev)) {
35923 @@ -2816,7 +3115,7 @@
35924         /* Zero out all descriptors. */
35925         memset(tp->rx_std, 0, TG3_RX_RING_BYTES);
35926         memset(tp->rx_jumbo, 0, TG3_RX_JUMBO_RING_BYTES);
35927 -       memset(tp->rx_rcb, 0, TG3_RX_RCB_RING_BYTES);
35928 +       memset(tp->rx_rcb, 0, TG3_RX_RCB_RING_BYTES(tp));
35929  
35930         if (tp->tg3_flags & TG3_FLAG_HOST_TXDS) {
35931                 memset(tp->tx_ring, 0, TG3_TX_RING_BYTES);
35932 @@ -2899,7 +3198,7 @@
35933                 tp->rx_jumbo = NULL;
35934         }
35935         if (tp->rx_rcb) {
35936 -               pci_free_consistent(tp->pdev, TG3_RX_RCB_RING_BYTES,
35937 +               pci_free_consistent(tp->pdev, TG3_RX_RCB_RING_BYTES(tp),
35938                                     tp->rx_rcb, tp->rx_rcb_mapping);
35939                 tp->rx_rcb = NULL;
35940         }
35941 @@ -2957,7 +3256,7 @@
35942         if (!tp->rx_jumbo)
35943                 goto err_out;
35944  
35945 -       tp->rx_rcb = pci_alloc_consistent(tp->pdev, TG3_RX_RCB_RING_BYTES,
35946 +       tp->rx_rcb = pci_alloc_consistent(tp->pdev, TG3_RX_RCB_RING_BYTES(tp),
35947                                           &tp->rx_rcb_mapping);
35948         if (!tp->rx_rcb)
35949                 goto err_out;
35950 @@ -3004,6 +3303,23 @@
35951         unsigned int i;
35952         u32 val;
35953  
35954 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
35955 +               switch (ofs) {
35956 +               case RCVLSC_MODE:
35957 +               case DMAC_MODE:
35958 +               case MBFREE_MODE:
35959 +               case BUFMGR_MODE:
35960 +               case MEMARB_MODE:
35961 +                       /* We can't enable/disable these bits of the
35962 +                        * 5705, just say success.
35963 +                        */
35964 +                       return 0;
35965 +
35966 +               default:
35967 +                       break;
35968 +               };
35969 +       }
35970 +
35971         val = tr32(ofs);
35972         val &= ~enable_bit;
35973         tw32(ofs, val);
35974 @@ -3127,7 +3443,10 @@
35975         tp->tg3_flags &= ~TG3_FLAG_5701_REG_WRITE_BUG;
35976  
35977         /* do the reset */
35978 -       tw32(GRC_MISC_CFG, GRC_MISC_CFG_CORECLK_RESET);
35979 +       val = GRC_MISC_CFG_CORECLK_RESET;
35980 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
35981 +               val |= GRC_MISC_CFG_KEEP_GPHY_POWER;
35982 +       tw32(GRC_MISC_CFG, val);
35983  
35984         /* restore 5701 hardware bug workaround flag */
35985         tp->tg3_flags = flags_save;
35986 @@ -3163,6 +3482,13 @@
35987  
35988         tw32(MEMARB_MODE, MEMARB_MODE_ENABLE);
35989  
35990 +       if ((tp->nic_sram_data_cfg & NIC_SRAM_DATA_CFG_MINI_PCI) != 0 &&
35991 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
35992 +               tp->pci_clock_ctrl |=
35993 +                       (CLOCK_CTRL_FORCE_CLKRUN | CLOCK_CTRL_CLKRUN_OENABLE);
35994 +               tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl);
35995 +       }
35996 +
35997         tw32(TG3PCI_MISC_HOST_CTRL, tp->misc_host_ctrl);
35998  }
35999  
36000 @@ -3358,28 +3684,32 @@
36001  #define TX_CPU_SCRATCH_SIZE    0x04000
36002  
36003  /* tp->lock is held. */
36004 -static int tg3_reset_cpu(struct tg3 *tp, u32 offset)
36005 +static int tg3_halt_cpu(struct tg3 *tp, u32 offset)
36006  {
36007         int i;
36008  
36009 -       tw32(offset + CPU_STATE, 0xffffffff);
36010 -       tw32(offset + CPU_MODE,  CPU_MODE_RESET);
36011 +       if (offset == TX_CPU_BASE &&
36012 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
36013 +               BUG();
36014 +
36015         if (offset == RX_CPU_BASE) {
36016 -               for (i = 0; i < 10000; i++)
36017 -                       if (!(tr32(offset + CPU_MODE) & CPU_MODE_RESET))
36018 +               for (i = 0; i < 10000; i++) {
36019 +                       tw32(offset + CPU_STATE, 0xffffffff);
36020 +                       tw32(offset + CPU_MODE,  CPU_MODE_HALT);
36021 +                       if (tr32(offset + CPU_MODE) & CPU_MODE_HALT)
36022                                 break;
36023 +               }
36024 +
36025                 tw32(offset + CPU_STATE, 0xffffffff);
36026 -               tw32(offset + CPU_MODE,  CPU_MODE_RESET);
36027 +               tw32(offset + CPU_MODE,  CPU_MODE_HALT);
36028                 tr32(offset + CPU_MODE);
36029                 udelay(10);
36030         } else {
36031                 for (i = 0; i < 10000; i++) {
36032 -                       if (!(tr32(offset + CPU_MODE) & CPU_MODE_RESET))
36033 -                               break;
36034                         tw32(offset + CPU_STATE, 0xffffffff);
36035 -                       tw32(offset + CPU_MODE,  CPU_MODE_RESET);
36036 -                       tr32(offset + CPU_MODE);
36037 -                       udelay(10);
36038 +                       tw32(offset + CPU_MODE,  CPU_MODE_HALT);
36039 +                       if (tr32(offset + CPU_MODE) & CPU_MODE_HALT)
36040 +                               break;
36041                 }
36042         }
36043  
36044 @@ -3411,38 +3741,52 @@
36045  {
36046         int err, i;
36047         u32 orig_tg3_flags = tp->tg3_flags;
36048 +       void (*write_op)(struct tg3 *, u32, u32);
36049 +
36050 +       if (cpu_base == TX_CPU_BASE &&
36051 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
36052 +               printk(KERN_ERR PFX "tg3_load_firmware_cpu: Trying to load "
36053 +                      "TX cpu firmware on %s which is 5705.\n",
36054 +                      tp->dev->name);
36055 +               return -EINVAL;
36056 +       }
36057 +
36058 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
36059 +               write_op = tg3_write_mem;
36060 +       else
36061 +               write_op = tg3_write_indirect_reg32;
36062  
36063         /* Force use of PCI config space for indirect register
36064          * write calls.
36065          */
36066         tp->tg3_flags |= TG3_FLAG_PCIX_TARGET_HWBUG;
36067  
36068 -       err = tg3_reset_cpu(tp, cpu_base);
36069 +       err = tg3_halt_cpu(tp, cpu_base);
36070         if (err)
36071                 goto out;
36072  
36073         for (i = 0; i < cpu_scratch_size; i += sizeof(u32))
36074 -               tg3_write_indirect_reg32(tp, cpu_scratch_base + i, 0);
36075 +               write_op(tp, cpu_scratch_base + i, 0);
36076         tw32(cpu_base + CPU_STATE, 0xffffffff);
36077         tw32(cpu_base + CPU_MODE, tr32(cpu_base+CPU_MODE)|CPU_MODE_HALT);
36078         for (i = 0; i < (info->text_len / sizeof(u32)); i++)
36079 -               tg3_write_indirect_reg32(tp, (cpu_scratch_base +
36080 -                                             (info->text_base & 0xffff) +
36081 -                                             (i * sizeof(u32))),
36082 -                                        (info->text_data ?
36083 -                                         info->text_data[i] : 0));
36084 +               write_op(tp, (cpu_scratch_base +
36085 +                             (info->text_base & 0xffff) +
36086 +                             (i * sizeof(u32))),
36087 +                        (info->text_data ?
36088 +                         info->text_data[i] : 0));
36089         for (i = 0; i < (info->rodata_len / sizeof(u32)); i++)
36090 -               tg3_write_indirect_reg32(tp, (cpu_scratch_base +
36091 -                                             (info->rodata_base & 0xffff) +
36092 -                                             (i * sizeof(u32))),
36093 -                                        (info->rodata_data ?
36094 -                                         info->rodata_data[i] : 0));
36095 +               write_op(tp, (cpu_scratch_base +
36096 +                             (info->rodata_base & 0xffff) +
36097 +                             (i * sizeof(u32))),
36098 +                        (info->rodata_data ?
36099 +                         info->rodata_data[i] : 0));
36100         for (i = 0; i < (info->data_len / sizeof(u32)); i++)
36101 -               tg3_write_indirect_reg32(tp, (cpu_scratch_base +
36102 -                                             (info->data_base & 0xffff) +
36103 -                                             (i * sizeof(u32))),
36104 -                                        (info->data_data ?
36105 -                                         info->data_data[i] : 0));
36106 +               write_op(tp, (cpu_scratch_base +
36107 +                             (info->data_base & 0xffff) +
36108 +                             (i * sizeof(u32))),
36109 +                        (info->data_data ?
36110 +                         info->data_data[i] : 0));
36111  
36112         err = 0;
36113  
36114 @@ -3513,269 +3857,318 @@
36115         return 0;
36116  }
36117  
36118 -#if TG3_DO_TSO != 0
36119 +#if TG3_TSO_SUPPORT != 0
36120  
36121  #define TG3_TSO_FW_RELEASE_MAJOR       0x1
36122 -#define TG3_TSO_FW_RELASE_MINOR                0x8
36123 +#define TG3_TSO_FW_RELASE_MINOR                0x3
36124  #define TG3_TSO_FW_RELEASE_FIX         0x0
36125  #define TG3_TSO_FW_START_ADDR          0x08000000
36126  #define TG3_TSO_FW_TEXT_ADDR           0x08000000
36127 -#define TG3_TSO_FW_TEXT_LEN            0x1650
36128 +#define TG3_TSO_FW_TEXT_LEN            0x1ac0
36129  #define TG3_TSO_FW_RODATA_ADDR         0x08001650
36130 -#define TG3_TSO_FW_RODATA_LEN          0x30
36131 +#define TG3_TSO_FW_RODATA_LEN          0x60
36132  #define TG3_TSO_FW_DATA_ADDR           0x080016a0
36133  #define TG3_TSO_FW_DATA_LEN            0x20
36134  #define TG3_TSO_FW_SBSS_ADDR           0x080016c0
36135 -#define TG3_TSO_FW_SBSS_LEN            0x14
36136 +#define TG3_TSO_FW_SBSS_LEN            0x2c
36137  #define TG3_TSO_FW_BSS_ADDR            0x080016e0
36138 -#define TG3_TSO_FW_BSS_LEN             0x8fc
36139 +#define TG3_TSO_FW_BSS_LEN             0x890
36140  
36141  static u32 tg3TsoFwText[] = {
36142         0x00000000, 0x10000003, 0x00000000, 0x0000000d, 0x0000000d, 0x3c1d0800,
36143         0x37bd4000, 0x03a0f021, 0x3c100800, 0x26100000, 0x0e000010, 0x00000000,
36144 -       0x0000000d, 0x00000000, 0x00000000, 0x00000000, 0x27bdffe0, 0x3c1bc000,
36145 -       0xafbf0018, 0x0e000058, 0xaf60680c, 0x3c040800, 0x24841650, 0x03602821,
36146 -       0x24060001, 0x24070004, 0xafa00010, 0x0e00006c, 0xafa00014, 0x8f625c50,
36147 -       0x34420001, 0xaf625c50, 0x8f625c90, 0x34420001, 0xaf625c90, 0x2402ffff,
36148 -       0x0e000098, 0xaf625404, 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x00000000,
36149 -       0x00000000, 0x00000000, 0x24030b60, 0x24050fff, 0xac000b50, 0x00002021,
36150 -       0xac640000, 0x24630004, 0x0065102b, 0x1440fffc, 0x24840001, 0x24030b60,
36151 -       0x0065102b, 0x10400011, 0x00002021, 0x24090b54, 0x3c06dead, 0x34c6beef,
36152 -       0x24080b58, 0x24070b5c, 0x8c620000, 0x50440006, 0x24630004, 0xad260000,
36153 -       0x8c620000, 0xace40000, 0xad020000, 0x24630004, 0x0065102b, 0x1440fff6,
36154 -       0x24840001, 0x03e00008, 0x00000000, 0x27bdfff8, 0x18800009, 0x00002821,
36155 -       0x8f63680c, 0x8f62680c, 0x1043fffe, 0x00000000, 0x24a50001, 0x00a4102a,
36156 -       0x1440fff9, 0x00000000, 0x03e00008, 0x27bd0008, 0x3c020800, 0x34423000,
36157 -       0x3c030800, 0x34633000, 0x3c040800, 0x348437ff, 0x3c010800, 0xac2216c4,
36158 -       0x24020040, 0x3c010800, 0xac2216c8, 0x3c010800, 0xac2016c0, 0xac600000,
36159 -       0x24630004, 0x0083102b, 0x5040fffd, 0xac600000, 0x03e00008, 0x00000000,
36160 -       0x00804821, 0x8faa0010, 0x3c020800, 0x8c4216c0, 0x3c040800, 0x8c8416c8,
36161 -       0x8fab0014, 0x24430001, 0x0044102b, 0x3c010800, 0xac2316c0, 0x14400003,
36162 -       0x00004021, 0x3c010800, 0xac2016c0, 0x3c020800, 0x8c4216c0, 0x3c030800,
36163 -       0x8c6316c4, 0x91240000, 0x00021140, 0x00431021, 0x00481021, 0x25080001,
36164 -       0xa0440000, 0x29020008, 0x1440fff4, 0x25290001, 0x3c020800, 0x8c4216c0,
36165 -       0x3c030800, 0x8c6316c4, 0x8f64680c, 0x00021140, 0x00431021, 0xac440008,
36166 -       0xac45000c, 0xac460010, 0xac470014, 0xac4a0018, 0x03e00008, 0xac4b001c,
36167 -       0x00000000, 0x00000000, 0x27bdffe0, 0xafbf0018, 0xafb10014, 0x0e0000b6,
36168 -       0xafb00010, 0x24110001, 0x8f706820, 0x32020100, 0x10400003, 0x00000000,
36169 -       0x0e000127, 0x00000000, 0x8f706820, 0x32022000, 0x10400004, 0x32020001,
36170 -       0x0e00025a, 0x24040001, 0x32020001, 0x10400003, 0x00000000, 0x0e0000e6,
36171 -       0x00000000, 0x0a00009e, 0xaf715028, 0x8fbf0018, 0x8fb10014, 0x8fb00010,
36172 -       0x03e00008, 0x27bd0020, 0x27bdffe0, 0x3c040800, 0x24841660, 0x00002821,
36173 -       0x00003021, 0x00003821, 0xafbf0018, 0xafa00010, 0x0e00006c, 0xafa00014,
36174 -       0x3c010800, 0xa4201fb8, 0x3c010800, 0xa02016f8, 0x3c010800, 0xac2016fc,
36175 -       0x3c010800, 0xac201700, 0x3c010800, 0xac201704, 0x3c010800, 0xac20170c,
36176 -       0x3c010800, 0xac201718, 0x3c010800, 0xac20171c, 0x8f624434, 0x3c010800,
36177 -       0xac2216e8, 0x8f624438, 0x3c010800, 0xac2216ec, 0x8f624410, 0x3c010800,
36178 -       0xac2016e0, 0x3c010800, 0xac2016e4, 0x3c010800, 0xac201fc0, 0x3c010800,
36179 -       0xac201f68, 0x3c010800, 0xac201f6c, 0x3c010800, 0xac2216f0, 0x8fbf0018,
36180 -       0x03e00008, 0x27bd0020, 0x27bdffe0, 0x3c040800, 0x2484166c, 0x00002821,
36181 -       0x00003021, 0x00003821, 0xafbf0018, 0xafa00010, 0x0e00006c, 0xafa00014,
36182 -       0x3c040800, 0x24841660, 0x00002821, 0x00003021, 0x00003821, 0xafa00010,
36183 -       0x0e00006c, 0xafa00014, 0x3c010800, 0xa4201fb8, 0x3c010800, 0xa02016f8,
36184 -       0x3c010800, 0xac2016fc, 0x3c010800, 0xac201700, 0x3c010800, 0xac201704,
36185 -       0x3c010800, 0xac20170c, 0x3c010800, 0xac201718, 0x3c010800, 0xac20171c,
36186 -       0x8f624434, 0x3c010800, 0xac2216e8, 0x8f624438, 0x3c010800, 0xac2216ec,
36187 -       0x8f624410, 0x3c010800, 0xac2016e0, 0x3c010800, 0xac2016e4, 0x3c010800,
36188 -       0xac201fc0, 0x3c010800, 0xac201f68, 0x3c010800, 0xac201f6c, 0x3c010800,
36189 -       0xac2216f0, 0x0e000120, 0x00002021, 0x8fbf0018, 0x03e00008, 0x27bd0020,
36190 -       0x24020001, 0x8f636820, 0x00821004, 0x00021027, 0x00621824, 0x03e00008,
36191 -       0xaf636820, 0x27bdffd0, 0x3c0300ff, 0xafbf002c, 0xafb60028, 0xafb50024,
36192 -       0xafb40020, 0xafb3001c, 0xafb20018, 0xafb10014, 0xafb00010, 0x8f665c5c,
36193 -       0x3c040800, 0x2484171c, 0x8c820000, 0x3463fff8, 0x14460005, 0x00c38824,
36194 -       0x3c020800, 0x904216f8, 0x14400115, 0x00000000, 0x00111902, 0x306300ff,
36195 -       0x30c20003, 0x000211c0, 0x00623825, 0x00e02821, 0x00061602, 0xac860000,
36196 -       0x3c030800, 0x906316f8, 0x3044000f, 0x1460002b, 0x00804021, 0x24020001,
36197 -       0x3c010800, 0xa02216f8, 0x00071100, 0x00821025, 0x3c010800, 0xac2016fc,
36198 -       0x3c010800, 0xac201700, 0x3c010800, 0xac201704, 0x3c010800, 0xac20170c,
36199 -       0x3c010800, 0xac201718, 0x3c010800, 0xac201710, 0x3c010800, 0xac201714,
36200 -       0x3c010800, 0xa4221fb8, 0x9623000c, 0x30628000, 0x10400008, 0x30627fff,
36201 -       0x2442003e, 0x3c010800, 0xa42216f6, 0x24020001, 0x3c010800, 0x0a00016e,
36202 -       0xac221fd4, 0x24620036, 0x3c010800, 0xa42216f6, 0x3c010800, 0xac201fd4,
36203 -       0x3c010800, 0xac201fd0, 0x3c010800, 0x0a000176, 0xac201fd8, 0x9622000c,
36204 -       0x3c010800, 0xa4221fcc, 0x3c040800, 0x248416fc, 0x8c820000, 0x00021100,
36205 -       0x3c010800, 0x00220821, 0xac311728, 0x8c820000, 0x00021100, 0x3c010800,
36206 -       0x00220821, 0xac26172c, 0x8c820000, 0x24a30001, 0x306701ff, 0x00021100,
36207 -       0x3c010800, 0x00220821, 0xac271730, 0x8c820000, 0x00021100, 0x3c010800,
36208 -       0x00220821, 0xac281734, 0x96230008, 0x3c020800, 0x8c42170c, 0x00432821,
36209 -       0x3c010800, 0xac25170c, 0x9622000a, 0x30420004, 0x14400019, 0x00071100,
36210 -       0x3c02c000, 0x00c21825, 0xaf635c5c, 0x8f625c50, 0x30420002, 0x1440fffc,
36211 -       0x00000000, 0x8f630c14, 0x3063000f, 0x2c620002, 0x1440001e, 0x00000000,
36212 -       0x8f630c14, 0x3c020800, 0x8c4216b4, 0x3063000f, 0x24420001, 0x3c010800,
36213 -       0xac2216b4, 0x2c620002, 0x1040fff7, 0x00000000, 0x0a0001c1, 0x00000000,
36214 -       0x3c030800, 0x8c6316e0, 0x3c040800, 0x948416f4, 0x01021025, 0x3c010800,
36215 -       0xa4221fba, 0x24020001, 0x3c010800, 0xac221718, 0x24630001, 0x0085202a,
36216 -       0x3c010800, 0x10800003, 0xac2316e0, 0x3c010800, 0xa42516f4, 0x3c030800,
36217 -       0x246316fc, 0x8c620000, 0x24420001, 0xac620000, 0x28420080, 0x14400005,
36218 -       0x24020001, 0x0e0002df, 0x24040002, 0x0a000250, 0x00000000, 0x3c030800,
36219 -       0x906316f8, 0x1462007c, 0x24020003, 0x3c160800, 0x96d616f6, 0x3c050800,
36220 -       0x8ca5170c, 0x32c4ffff, 0x00a4102a, 0x14400078, 0x00000000, 0x3c020800,
36221 -       0x8c421718, 0x10400005, 0x32c2ffff, 0x14a40003, 0x00000000, 0x3c010800,
36222 -       0xac231fd0, 0x10400062, 0x00009021, 0x0040a021, 0x3c150800, 0x26b51700,
36223 -       0x26b30010, 0x8ea20000, 0x00028100, 0x3c110800, 0x02308821, 0x0e0002e1,
36224 -       0x8e311728, 0x00403021, 0x10c00059, 0x00000000, 0x9628000a, 0x31020040,
36225 -       0x10400004, 0x2407180c, 0x8e22000c, 0x2407188c, 0xacc20018, 0x31021000,
36226 -       0x10400004, 0x34e32000, 0x00081040, 0x3042c000, 0x00623825, 0x3c030800,
36227 -       0x00701821, 0x8c631730, 0x3c020800, 0x00501021, 0x8c421734, 0x00031d00,
36228 -       0x00021400, 0x00621825, 0xacc30014, 0x8ea30004, 0x96220008, 0x00432023,
36229 -       0x3242ffff, 0x3083ffff, 0x00431021, 0x0282102a, 0x14400002, 0x02d22823,
36230 -       0x00802821, 0x8e620000, 0x30a4ffff, 0x00441021, 0xae620000, 0x8e220000,
36231 -       0xacc20000, 0x8e220004, 0x8e63fff4, 0x00431021, 0xacc20004, 0xa4c5000e,
36232 -       0x8e62fff4, 0x00441021, 0xae62fff4, 0x96230008, 0x0043102a, 0x14400005,
36233 -       0x02459021, 0x8e62fff0, 0xae60fff4, 0x24420001, 0xae62fff0, 0xacc00008,
36234 -       0x3242ffff, 0x14540008, 0x24020305, 0x31020080, 0x54400001, 0x34e70010,
36235 -       0x24020905, 0xa4c2000c, 0x0a000233, 0x34e70020, 0xa4c2000c, 0x30e2ffff,
36236 -       0xacc20010, 0x3c020800, 0x8c421fd0, 0x10400003, 0x3c024b65, 0x0a00023d,
36237 -       0x34427654, 0x3c02b49a, 0x344289ab, 0xacc2001c, 0x0e000560, 0x00c02021,
36238 -       0x3242ffff, 0x0054102b, 0x1440ffa4, 0x00000000, 0x24020002, 0x3c010800,
36239 -       0x0a000250, 0xa02216f8, 0x8ea208bc, 0x24420001, 0x0a000250, 0xaea208bc,
36240 -       0x14620003, 0x00000000, 0x0e000450, 0x00000000, 0x8fbf002c, 0x8fb60028,
36241 -       0x8fb50024, 0x8fb40020, 0x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010,
36242 -       0x03e00008, 0x27bd0030, 0x27bdffd8, 0xafb3001c, 0x00809821, 0xafbf0020,
36243 -       0xafb20018, 0xafb10014, 0xafb00010, 0x8f725c9c, 0x3c0200ff, 0x3442fff8,
36244 -       0x3c040800, 0x24841714, 0x02428824, 0x9623000e, 0x8c820000, 0x00431021,
36245 -       0xac820000, 0x8e220010, 0x30420020, 0x14400011, 0x00000000, 0x0e0002f7,
36246 +       0x0000000d, 0x00000000, 0x00000000, 0x00000000, 0x27bdffe0, 0x3c04fefe,
36247 +       0xafbf0018, 0x0e0005e0, 0x34840002, 0x0e000670, 0x00000000, 0x3c030800,
36248 +       0x90631b78, 0x24020002, 0x3c040800, 0x24841acc, 0x14620003, 0x24050001,
36249 +       0x3c040800, 0x24841ac0, 0x24060002, 0x00003821, 0xafa00010, 0x0e000684,
36250 +       0xafa00014, 0x8f625c50, 0x34420001, 0xaf625c50, 0x8f625c90, 0x34420001,
36251 +       0xaf625c90, 0x2402ffff, 0x0e000034, 0xaf625404, 0x8fbf0018, 0x03e00008,
36252 +       0x27bd0020, 0x00000000, 0x00000000, 0x00000000, 0x27bdffe0, 0xafbf0018,
36253 +       0xafb10014, 0x0e000052, 0xafb00010, 0x24110001, 0x8f706820, 0x32020100,
36254 +       0x10400003, 0x00000000, 0x0e0000b2, 0x00000000, 0x8f706820, 0x32022000,
36255 +       0x10400004, 0x32020001, 0x0e0001e3, 0x24040001, 0x32020001, 0x10400003,
36256 +       0x00000000, 0x0e00009a, 0x00000000, 0x0a00003a, 0xaf715028, 0x8fbf0018,
36257 +       0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffe0, 0x3c040800,
36258 +       0x24841ae0, 0x00002821, 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010,
36259 +       0x0e000684, 0xafa00014, 0x3c040800, 0x248423e8, 0xa4800000, 0x3c010800,
36260 +       0xa0201ba8, 0x3c010800, 0xac201bac, 0x3c010800, 0xac201bb0, 0x3c010800,
36261 +       0xac201bb4, 0x3c010800, 0xac201bbc, 0x3c010800, 0xac201bc8, 0x3c010800,
36262 +       0xac201bcc, 0x8f624434, 0x3c010800, 0xac221b98, 0x8f624438, 0x3c010800,
36263 +       0xac221b9c, 0x8f624410, 0xac80f7a8, 0x3c010800, 0xac201b94, 0x3c010800,
36264 +       0xac2023f0, 0x3c010800, 0xac2023d8, 0x3c010800, 0xac2023dc, 0x3c010800,
36265 +       0xac202410, 0x3c010800, 0xac221ba0, 0x8f620068, 0x24030007, 0x00021702,
36266 +       0x10430005, 0x00000000, 0x8f620068, 0x00021702, 0x14400004, 0x24020001,
36267 +       0x3c010800, 0x0a00008e, 0xac20241c, 0xac820034, 0x3c040800, 0x24841aec,
36268 +       0x3c050800, 0x8ca5241c, 0x00003021, 0x00003821, 0xafa00010, 0x0e000684,
36269 +       0xafa00014, 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x27bdffe0, 0x3c040800,
36270 +       0x24841af8, 0x00002821, 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010,
36271 +       0x0e000684, 0xafa00014, 0x0e000052, 0x00000000, 0x0e0000ab, 0x00002021,
36272 +       0x8fbf0018, 0x03e00008, 0x27bd0020, 0x24020001, 0x8f636820, 0x00821004,
36273 +       0x00021027, 0x00621824, 0x03e00008, 0xaf636820, 0x27bdffd0, 0xafbf002c,
36274 +       0xafb60028, 0xafb50024, 0xafb40020, 0xafb3001c, 0xafb20018, 0xafb10014,
36275 +       0xafb00010, 0x8f665c5c, 0x3c030800, 0x24631bcc, 0x8c620000, 0x14460005,
36276 +       0x3c0200ff, 0x3c020800, 0x90421ba8, 0x14400115, 0x3c0200ff, 0x3442fff8,
36277 +       0x00c28824, 0xac660000, 0x00111902, 0x306300ff, 0x30c20003, 0x000211c0,
36278 +       0x00623825, 0x00e02821, 0x00061602, 0x3c030800, 0x90631ba8, 0x3044000f,
36279 +       0x1460002b, 0x00804021, 0x24020001, 0x3c010800, 0xa0221ba8, 0x00071100,
36280 +       0x00821025, 0x3c010800, 0xac201bac, 0x3c010800, 0xac201bb0, 0x3c010800,
36281 +       0xac201bb4, 0x3c010800, 0xac201bbc, 0x3c010800, 0xac201bc8, 0x3c010800,
36282 +       0xac201bc0, 0x3c010800, 0xac201bc4, 0x3c010800, 0xa42223e8, 0x9623000c,
36283 +       0x30628000, 0x10400008, 0x30627fff, 0x2442003e, 0x3c010800, 0xa4221ba6,
36284 +       0x24020001, 0x3c010800, 0x0a0000f9, 0xac222404, 0x24620036, 0x3c010800,
36285 +       0xa4221ba6, 0x3c010800, 0xac202404, 0x3c010800, 0xac202400, 0x3c010800,
36286 +       0x0a000101, 0xac202408, 0x9622000c, 0x3c010800, 0xa42223fc, 0x3c040800,
36287 +       0x24841bac, 0x8c820000, 0x00021100, 0x3c010800, 0x00220821, 0xac311bd8,
36288 +       0x8c820000, 0x00021100, 0x3c010800, 0x00220821, 0xac261bdc, 0x8c820000,
36289 +       0x24a30001, 0x306701ff, 0x00021100, 0x3c010800, 0x00220821, 0xac271be0,
36290 +       0x8c820000, 0x00021100, 0x3c010800, 0x00220821, 0xac281be4, 0x96230008,
36291 +       0x3c020800, 0x8c421bbc, 0x00432821, 0x3c010800, 0xac251bbc, 0x9622000a,
36292 +       0x30420004, 0x14400018, 0x00071100, 0x8f630c14, 0x3063000f, 0x2c620002,
36293 +       0x1440000b, 0x3c02c000, 0x8f630c14, 0x3c020800, 0x8c421b50, 0x3063000f,
36294 +       0x24420001, 0x3c010800, 0xac221b50, 0x2c620002, 0x1040fff7, 0x3c02c000,
36295 +       0x00c21825, 0xaf635c5c, 0x8f625c50, 0x30420002, 0x10400014, 0x00000000,
36296 +       0x0a000133, 0x00000000, 0x3c030800, 0x8c631b90, 0x3c040800, 0x94841ba4,
36297 +       0x01021025, 0x3c010800, 0xa42223ea, 0x24020001, 0x3c010800, 0xac221bc8,
36298 +       0x24630001, 0x0085202a, 0x3c010800, 0x10800003, 0xac231b90, 0x3c010800,
36299 +       0xa4251ba4, 0x3c060800, 0x24c61bac, 0x8cc20000, 0x24420001, 0xacc20000,
36300 +       0x28420080, 0x14400005, 0x00000000, 0x0e00065e, 0x24040002, 0x0a0001d9,
36301 +       0x00000000, 0x3c020800, 0x8c421bc8, 0x1040007f, 0x24020001, 0x3c040800,
36302 +       0x90841ba8, 0x14820077, 0x24020003, 0x3c150800, 0x96b51ba6, 0x3c050800,
36303 +       0x8ca51bbc, 0x32a3ffff, 0x00a3102a, 0x14400073, 0x00000000, 0x14a30003,
36304 +       0x00000000, 0x3c010800, 0xac242400, 0x10600061, 0x00009021, 0x24d60004,
36305 +       0x0060a021, 0x24d30014, 0x8ec20000, 0x00028100, 0x3c110800, 0x02308821,
36306 +       0x0e00062d, 0x8e311bd8, 0x00403021, 0x10c00059, 0x00000000, 0x9628000a,
36307 +       0x31020040, 0x10400004, 0x2407180c, 0x8e22000c, 0x2407188c, 0xacc20018,
36308 +       0x31021000, 0x10400004, 0x34e32000, 0x00081040, 0x3042c000, 0x00623825,
36309 +       0x3c030800, 0x00701821, 0x8c631be0, 0x3c020800, 0x00501021, 0x8c421be4,
36310 +       0x00031d00, 0x00021400, 0x00621825, 0xacc30014, 0x8ec30004, 0x96220008,
36311 +       0x00432023, 0x3242ffff, 0x3083ffff, 0x00431021, 0x0282102a, 0x14400002,
36312 +       0x02b22823, 0x00802821, 0x8e620000, 0x30a4ffff, 0x00441021, 0xae620000,
36313 +       0x8e220000, 0xacc20000, 0x8e220004, 0x8e63fff4, 0x00431021, 0xacc20004,
36314 +       0xa4c5000e, 0x8e62fff4, 0x00441021, 0xae62fff4, 0x96230008, 0x0043102a,
36315 +       0x14400005, 0x02459021, 0x8e62fff0, 0xae60fff4, 0x24420001, 0xae62fff0,
36316 +       0xacc00008, 0x3242ffff, 0x14540008, 0x24020305, 0x31020080, 0x54400001,
36317 +       0x34e70010, 0x24020905, 0xa4c2000c, 0x0a0001bc, 0x34e70020, 0xa4c2000c,
36318 +       0x3c020800, 0x8c422400, 0x10400003, 0x3c024b65, 0x0a0001c4, 0x34427654,
36319 +       0x3c02b49a, 0x344289ab, 0xacc2001c, 0x30e2ffff, 0xacc20010, 0x0e0005aa,
36320 +       0x00c02021, 0x3242ffff, 0x0054102b, 0x1440ffa4, 0x00000000, 0x24020002,
36321 +       0x3c010800, 0x0a0001d9, 0xa0221ba8, 0x8ec2083c, 0x24420001, 0x0a0001d9,
36322 +       0xaec2083c, 0x14820003, 0x00000000, 0x0e0004b9, 0x00000000, 0x8fbf002c,
36323 +       0x8fb60028, 0x8fb50024, 0x8fb40020, 0x8fb3001c, 0x8fb20018, 0x8fb10014,
36324 +       0x8fb00010, 0x03e00008, 0x27bd0030, 0x27bdffd0, 0xafbf0028, 0xafb30024,
36325 +       0xafb20020, 0xafb1001c, 0xafb00018, 0x8f725c9c, 0x3c0200ff, 0x3442fff8,
36326 +       0x3c060800, 0x24c61bc4, 0x02428824, 0x9623000e, 0x8cc20000, 0x00431021,
36327 +       0xacc20000, 0x8e220010, 0x30420020, 0x14400011, 0x00809821, 0x0e000643,
36328         0x02202021, 0x3c02c000, 0x02421825, 0xaf635c9c, 0x8f625c90, 0x30420002,
36329 -       0x10400061, 0x00000000, 0xaf635c9c, 0x8f625c90, 0x30420002, 0x1040005c,
36330 -       0x00000000, 0x0a000278, 0x00000000, 0x8e220008, 0x00021c02, 0x000321c0,
36331 -       0x3042ffff, 0x3c030800, 0x906316f8, 0x000229c0, 0x24020002, 0x14620003,
36332 -       0x3c034b65, 0x0a000290, 0x00008021, 0x8e22001c, 0x34637654, 0x10430002,
36333 -       0x24100002, 0x24100001, 0x0e000300, 0x02003021, 0x24020003, 0x3c010800,
36334 -       0xa02216f8, 0x24020002, 0x1202000a, 0x24020001, 0x3c030800, 0x8c631fd0,
36335 -       0x10620006, 0x00000000, 0x3c020800, 0x94421fb8, 0x00021400, 0x0a0002cd,
36336 -       0xae220014, 0x3c040800, 0x24841fba, 0x94820000, 0x00021400, 0xae220014,
36337 -       0x3c020800, 0x8c42171c, 0x3c03c000, 0x3c010800, 0xa02016f8, 0x00431025,
36338 -       0xaf625c5c, 0x8f625c50, 0x30420002, 0x10400009, 0x00000000, 0x2484f762,
36339 +       0x10400121, 0x00000000, 0xaf635c9c, 0x8f625c90, 0x30420002, 0x1040011c,
36340 +       0x00000000, 0x0a000200, 0x00000000, 0x8e240008, 0x8e230014, 0x00041402,
36341 +       0x000241c0, 0x00031502, 0x304201ff, 0x2442ffff, 0x3042007f, 0x00031942,
36342 +       0x30637800, 0x00021100, 0x24424000, 0x00625021, 0x9542000a, 0x3084ffff,
36343 +       0x30420008, 0x104000b3, 0x000429c0, 0x3c020800, 0x8c422410, 0x1440002d,
36344 +       0x25050008, 0x95020014, 0x3c010800, 0xa42223e0, 0x8d070010, 0x00071402,
36345 +       0x3c010800, 0xa42223e2, 0x3c010800, 0xa42723e4, 0x9502000e, 0x30e3ffff,
36346 +       0x00431023, 0x3c010800, 0xac222418, 0x8f626800, 0x3c030010, 0x00431024,
36347 +       0x10400005, 0x00000000, 0x9503001a, 0x9502001c, 0x0a000235, 0x00431021,
36348 +       0x9502001a, 0x3c010800, 0xac22240c, 0x3c02c000, 0x02421825, 0x3c010800,
36349 +       0xac282410, 0x3c010800, 0xac322414, 0xaf635c9c, 0x8f625c90, 0x30420002,
36350 +       0x104000df, 0x00000000, 0xaf635c9c, 0x8f625c90, 0x30420002, 0x104000da,
36351 +       0x00000000, 0x0a000242, 0x00000000, 0x9502000e, 0x3c030800, 0x946323e4,
36352 +       0x00434823, 0x3123ffff, 0x2c620008, 0x1040001c, 0x00000000, 0x95020014,
36353 +       0x24420028, 0x00a22821, 0x00031042, 0x1840000b, 0x00002021, 0x24c60848,
36354 +       0x00403821, 0x94a30000, 0x8cc20000, 0x24840001, 0x00431021, 0xacc20000,
36355 +       0x0087102a, 0x1440fff9, 0x24a50002, 0x31220001, 0x1040001f, 0x3c024000,
36356 +       0x3c040800, 0x2484240c, 0xa0a00001, 0x94a30000, 0x8c820000, 0x00431021,
36357 +       0x0a000281, 0xac820000, 0x8f626800, 0x3c030010, 0x00431024, 0x10400009,
36358 +       0x00000000, 0x9502001a, 0x3c030800, 0x8c63240c, 0x00431021, 0x3c010800,
36359 +       0xac22240c, 0x0a000282, 0x3c024000, 0x9502001a, 0x9504001c, 0x3c030800,
36360 +       0x8c63240c, 0x00441023, 0x00621821, 0x3c010800, 0xac23240c, 0x3c024000,
36361 +       0x02421825, 0xaf635c9c, 0x8f625c90, 0x30420002, 0x1440fffc, 0x00000000,
36362 +       0x9542000a, 0x30420010, 0x10400095, 0x00000000, 0x3c060800, 0x24c62410,
36363 +       0x3c020800, 0x944223e4, 0x8cc50000, 0x3c040800, 0x8c842418, 0x24420030,
36364 +       0x00a22821, 0x94a20004, 0x3c030800, 0x8c63240c, 0x00441023, 0x00621821,
36365 +       0x00603821, 0x00032402, 0x30e2ffff, 0x00823821, 0x00071402, 0x00e23821,
36366 +       0x00071027, 0x3c010800, 0xac23240c, 0xa4a20006, 0x3c030800, 0x8c632414,
36367 +       0x3c0200ff, 0x3442fff8, 0x00628824, 0x96220008, 0x24040001, 0x24034000,
36368 +       0x000241c0, 0x00e01021, 0xa502001a, 0xa500001c, 0xacc00000, 0x3c010800,
36369 +       0xac241b70, 0xaf635cb8, 0x8f625cb0, 0x30420002, 0x10400003, 0x00000000,
36370 +       0x3c010800, 0xac201b70, 0x8e220008, 0xaf625cb8, 0x8f625cb0, 0x30420002,
36371 +       0x10400003, 0x00000000, 0x3c010800, 0xac201b70, 0x3c020800, 0x8c421b70,
36372 +       0x1040ffec, 0x00000000, 0x3c040800, 0x0e000643, 0x8c842414, 0x0a000320,
36373 +       0x00000000, 0x3c030800, 0x90631ba8, 0x24020002, 0x14620003, 0x3c034b65,
36374 +       0x0a0002d7, 0x00008021, 0x8e22001c, 0x34637654, 0x10430002, 0x24100002,
36375 +       0x24100001, 0x01002021, 0x0e000346, 0x02003021, 0x24020003, 0x3c010800,
36376 +       0xa0221ba8, 0x24020002, 0x1202000a, 0x24020001, 0x3c030800, 0x8c632400,
36377 +       0x10620006, 0x00000000, 0x3c020800, 0x944223e8, 0x00021400, 0x0a000315,
36378 +       0xae220014, 0x3c040800, 0x248423ea, 0x94820000, 0x00021400, 0xae220014,
36379 +       0x3c020800, 0x8c421bcc, 0x3c03c000, 0x3c010800, 0xa0201ba8, 0x00431025,
36380 +       0xaf625c5c, 0x8f625c50, 0x30420002, 0x10400009, 0x00000000, 0x2484f7e2,
36381         0x8c820000, 0x00431025, 0xaf625c5c, 0x8f625c50, 0x30420002, 0x1440fffa,
36382 -       0x00000000, 0x3c020800, 0x244216e4, 0x8c430000, 0x24630001, 0xac430000,
36383 -       0x8f630c14, 0x3063000f, 0x2c620002, 0x1440000b, 0x00009821, 0x8f630c14,
36384 -       0x3c020800, 0x8c4216b4, 0x3063000f, 0x24420001, 0x3c010800, 0xac2216b4,
36385 -       0x2c620002, 0x1040fff7, 0x00009821, 0x3c024000, 0x02421825, 0xaf635c9c,
36386 +       0x00000000, 0x3c020800, 0x24421b94, 0x8c430000, 0x24630001, 0xac430000,
36387 +       0x8f630c14, 0x3063000f, 0x2c620002, 0x1440000c, 0x3c024000, 0x8f630c14,
36388 +       0x3c020800, 0x8c421b50, 0x3063000f, 0x24420001, 0x3c010800, 0xac221b50,
36389 +       0x2c620002, 0x1040fff7, 0x00000000, 0x3c024000, 0x02421825, 0xaf635c9c,
36390         0x8f625c90, 0x30420002, 0x1440fffc, 0x00000000, 0x12600003, 0x00000000,
36391 -       0x0e000450, 0x00000000, 0x8fbf0020, 0x8fb3001c, 0x8fb20018, 0x8fb10014,
36392 -       0x8fb00010, 0x03e00008, 0x27bd0028, 0x0a0002df, 0x00000000, 0x8f634450,
36393 -       0x3c040800, 0x248416e8, 0x8c820000, 0x00031c02, 0x0043102b, 0x14400007,
36394 -       0x3c038000, 0x8c840004, 0x8f624450, 0x00021c02, 0x0083102b, 0x1040fffc,
36395 -       0x3c038000, 0xaf634444, 0x8f624444, 0x00431024, 0x1440fffd, 0x00000000,
36396 -       0x8f624448, 0x03e00008, 0x3042ffff, 0x3c024000, 0x00822025, 0xaf645c38,
36397 -       0x8f625c30, 0x30420002, 0x1440fffc, 0x00000000, 0x03e00008, 0x00000000,
36398 -       0x27bdffe0, 0x00805021, 0x14c00017, 0x254c0008, 0x3c020800, 0x8c421fd4,
36399 -       0x1040000a, 0x2402003e, 0x3c010800, 0xa4221fb0, 0x24020016, 0x3c010800,
36400 -       0xa4221fb2, 0x2402002a, 0x3c010800, 0x0a00031a, 0xa4221fb4, 0x95420014,
36401 -       0x3c010800, 0xa4221fb0, 0x8d430010, 0x00031402, 0x3c010800, 0xa4221fb2,
36402 -       0x3c010800, 0xa4231fb4, 0x3c040800, 0x94841fb4, 0x3c030800, 0x94631fb2,
36403 -       0x958d0006, 0x3c020800, 0x94421fb0, 0x00832023, 0x01a27023, 0x3065ffff,
36404 -       0x24a20028, 0x01824021, 0x3082ffff, 0x14c0001a, 0x01025821, 0x9562000c,
36405 -       0x3042003f, 0x3c010800, 0xa4221fb6, 0x95620004, 0x95630006, 0x3c010800,
36406 -       0xac201fc4, 0x3c010800, 0xac201fc8, 0x00021400, 0x00431025, 0x3c010800,
36407 -       0xac221720, 0x95020004, 0x3c010800, 0xa4221724, 0x95030002, 0x01a51023,
36408 -       0x0043102a, 0x10400010, 0x24020001, 0x3c010800, 0x0a00034e, 0xac221fd8,
36409 -       0x3c030800, 0x8c631fc8, 0x3c020800, 0x94421724, 0x00431021, 0xa5020004,
36410 -       0x3c020800, 0x94421720, 0xa5620004, 0x3c020800, 0x8c421720, 0xa5620006,
36411 -       0x3c020800, 0x8c421fd0, 0x3c070800, 0x8ce71fc4, 0x3c050800, 0x144000c7,
36412 -       0x8ca51fc8, 0x3c020800, 0x94421724, 0x00451821, 0x3063ffff, 0x0062182b,
36413 -       0x24020002, 0x10c2000d, 0x00a32823, 0x3c020800, 0x94421fb6, 0x30420009,
36414 -       0x10400008, 0x00000000, 0x9562000c, 0x3042fff6, 0xa562000c, 0x3c020800,
36415 -       0x94421fb6, 0x30420009, 0x00e23823, 0x3c020800, 0x8c421fd8, 0x1040004b,
36416 -       0x24020002, 0x01003021, 0x3c020800, 0x94421fb2, 0x00003821, 0xa500000a,
36417 -       0x01a21023, 0xa5020002, 0x3082ffff, 0x00021042, 0x18400008, 0x00002821,
36418 -       0x00401821, 0x94c20000, 0x24e70001, 0x00a22821, 0x00e3102a, 0x1440fffb,
36419 -       0x24c60002, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402, 0x00a22821,
36420 -       0x00a04821, 0x00051027, 0xa502000a, 0x00002821, 0x2506000c, 0x00003821,
36421 -       0x94c20000, 0x24e70001, 0x00a22821, 0x2ce20004, 0x1440fffb, 0x24c60002,
36422 -       0x95020002, 0x00003821, 0x91030009, 0x00442023, 0x01603021, 0x3082ffff,
36423 -       0xa4c00010, 0x00621821, 0x00021042, 0x18400010, 0x00a32821, 0x00404021,
36424 -       0x94c20000, 0x24c60002, 0x00a22821, 0x30c2007f, 0x14400006, 0x24e70001,
36425 -       0x8d430000, 0x3c02007f, 0x3442ff80, 0x00625024, 0x25460008, 0x00e8102a,
36426 -       0x1440fff3, 0x00000000, 0x30820001, 0x10400005, 0x00051c02, 0xa0c00001,
36427 -       0x94c20000, 0x00a22821, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402,
36428 -       0x00a22821, 0x0a000415, 0x30a5ffff, 0x14c20063, 0x00000000, 0x3c090800,
36429 -       0x95291fb2, 0x95030002, 0x01a91023, 0x1062005d, 0x01003021, 0x00003821,
36430 -       0x00002821, 0x01a91023, 0xa5020002, 0x3082ffff, 0x00021042, 0x18400008,
36431 -       0xa500000a, 0x00401821, 0x94c20000, 0x24e70001, 0x00a22821, 0x00e3102a,
36432 -       0x1440fffb, 0x24c60002, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402,
36433 -       0x00a22821, 0x00a04821, 0x00051027, 0xa502000a, 0x00002821, 0x2506000c,
36434 -       0x00003821, 0x94c20000, 0x24e70001, 0x00a22821, 0x2ce20004, 0x1440fffb,
36435 -       0x24c60002, 0x95020002, 0x00003821, 0x91030009, 0x00442023, 0x01603021,
36436 -       0x3082ffff, 0xa4c00010, 0x3c040800, 0x94841fb4, 0x00621821, 0x00a32821,
36437 -       0x00051c02, 0x30a2ffff, 0x00622821, 0x00051c02, 0x3c020800, 0x94421fb0,
36438 -       0x00a34021, 0x00441023, 0x00021fc2, 0x00431021, 0x00021043, 0x18400010,
36439 -       0x00002821, 0x00402021, 0x94c20000, 0x24c60002, 0x00a22821, 0x30c2007f,
36440 -       0x14400006, 0x24e70001, 0x8d430000, 0x3c02007f, 0x3442ff80, 0x00625024,
36441 -       0x25460008, 0x00e4102a, 0x1440fff3, 0x00000000, 0x3c020800, 0x94421fcc,
36442 -       0x00a22821, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402, 0x00a22821,
36443 -       0x3102ffff, 0x00a22821, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402,
36444 -       0x00a22821, 0x00a02021, 0x00051027, 0xa5620010, 0xad800014, 0x0a000435,
36445 -       0xad800000, 0x8d830010, 0x00602021, 0x10a00007, 0x00034c02, 0x01252821,
36446 -       0x00051402, 0x30a3ffff, 0x00432821, 0x00051402, 0x00a24821, 0x00091027,
36447 -       0xa502000a, 0x3c030800, 0x94631fb4, 0x3082ffff, 0x01a21021, 0x00432823,
36448 -       0x00a72821, 0x00051c02, 0x30a2ffff, 0x00622821, 0x00051402, 0x00a22821,
36449 -       0x00a02021, 0x00051027, 0xa5620010, 0x3082ffff, 0x00091c00, 0x00431025,
36450 -       0xad820010, 0x3c020800, 0x8c421fd4, 0x10400002, 0x25a2fff2, 0xa5820034,
36451 -       0x3c020800, 0x8c421fc8, 0x3c030800, 0x8c631720, 0x24420001, 0x3c010800,
36452 -       0xac221fc8, 0x3c020800, 0x8c421fc4, 0x31c4ffff, 0x00641821, 0x3c010800,
36453 -       0xac231720, 0x00441021, 0x3c010800, 0xac221fc4, 0x03e00008, 0x27bd0020,
36454 -       0x27bdffc8, 0x3c040800, 0x248416f8, 0xafbf0034, 0xafbe0030, 0xafb7002c,
36455 -       0xafb60028, 0xafb50024, 0xafb40020, 0xafb3001c, 0xafb20018, 0xafb10014,
36456 -       0xafb00010, 0x90830000, 0x24020003, 0x146200f4, 0x00000000, 0x3c020800,
36457 -       0x8c421710, 0x3c030800, 0x8c63170c, 0x3c1e0800, 0x97de16f6, 0x0043102a,
36458 -       0x104000eb, 0x3c168000, 0x249708c4, 0x33d5ffff, 0x24920018, 0x3c020800,
36459 -       0x8c421718, 0x104000e4, 0x00000000, 0x3c140800, 0x96941fb0, 0x3282ffff,
36460 -       0x104000d6, 0x00008021, 0x00409821, 0x00008821, 0x8f634450, 0x3c020800,
36461 -       0x8c4216e8, 0x00031c02, 0x0043102b, 0x14400008, 0x00000000, 0x3c040800,
36462 -       0x8c8416ec, 0x8f624450, 0x00021c02, 0x0083102b, 0x1040fffc, 0x00000000,
36463 -       0xaf764444, 0x8f624444, 0x00561024, 0x10400006, 0x00000000, 0x3c038000,
36464 -       0x8f624444, 0x00431024, 0x1440fffd, 0x00000000, 0x8f624448, 0x3046ffff,
36465 -       0x10c0005f, 0x00000000, 0x3c090800, 0x01314821, 0x8d291728, 0x9528000a,
36466 -       0x31020040, 0x10400004, 0x2407180c, 0x8d22000c, 0x2407188c, 0xacc20018,
36467 -       0x31021000, 0x10400004, 0x34e32000, 0x00081040, 0x3042c000, 0x00623825,
36468 -       0x31020080, 0x54400001, 0x34e70010, 0x3c020800, 0x00511021, 0x8c421730,
36469 -       0x3c030800, 0x00711821, 0x8c631734, 0x00021500, 0x00031c00, 0x00431025,
36470 -       0xacc20014, 0x95240008, 0x3202ffff, 0x00821021, 0x0262102a, 0x14400002,
36471 -       0x02902823, 0x00802821, 0x8d220000, 0x02058021, 0xacc20000, 0x8d220004,
36472 -       0x00c02021, 0x26310010, 0xac820004, 0x30e2ffff, 0xac800008, 0xa485000e,
36473 -       0xac820010, 0x24020305, 0x0e000560, 0xa482000c, 0x3202ffff, 0x0053102b,
36474 -       0x1440ffaf, 0x3202ffff, 0x0a00054c, 0x00000000, 0x8e420000, 0x8e43fffc,
36475 -       0x0043102a, 0x10400084, 0x00000000, 0x8e45fff0, 0x8f644450, 0x3c030800,
36476 -       0x8c6316e8, 0x00051100, 0x3c090800, 0x01224821, 0x8d291728, 0x00041402,
36477 -       0x0062182b, 0x14600008, 0x00000000, 0x3c030800, 0x8c6316ec, 0x8f624450,
36478 -       0x00021402, 0x0062102b, 0x1040fffc, 0x00000000, 0xaf764444, 0x8f624444,
36479 -       0x00561024, 0x10400006, 0x00000000, 0x3c038000, 0x8f624444, 0x00431024,
36480 -       0x1440fffd, 0x00000000, 0x8f624448, 0x3046ffff, 0x14c00005, 0x00000000,
36481 -       0x8ee20000, 0x24420001, 0x0a000554, 0xaee20000, 0x9528000a, 0x31020040,
36482 -       0x10400004, 0x2407180c, 0x8d22000c, 0x2407188c, 0xacc20018, 0x31021000,
36483 -       0x10400004, 0x34e32000, 0x00081040, 0x3042c000, 0x00623825, 0x00051900,
36484 -       0x3c020800, 0x00431021, 0x8c421730, 0x3c010800, 0x00230821, 0x8c231734,
36485 -       0x00021500, 0x00031c00, 0x00431025, 0xacc20014, 0x3c030800, 0x8c631704,
36486 -       0x95220008, 0x00432023, 0x3202ffff, 0x3083ffff, 0x00431021, 0x02a2102a,
36487 -       0x14400002, 0x03d02823, 0x00802821, 0x8e420000, 0x30a4ffff, 0x00441021,
36488 -       0xae420000, 0xa4c5000e, 0x8d220000, 0xacc20000, 0x8d220004, 0x8e43fff4,
36489 -       0x00431021, 0xacc20004, 0x8e43fff4, 0x95220008, 0x00641821, 0x0062102a,
36490 -       0x14400006, 0x02058021, 0x8e42fff0, 0xae40fff4, 0x24420001, 0x0a000530,
36491 -       0xae42fff0, 0xae43fff4, 0xacc00008, 0x3202ffff, 0x10550003, 0x31020004,
36492 -       0x10400006, 0x24020305, 0x31020080, 0x54400001, 0x34e70010, 0x34e70020,
36493 -       0x24020905, 0xa4c2000c, 0x30e2ffff, 0xacc20010, 0x3c030800, 0x8c63170c,
36494 -       0x3c020800, 0x8c421710, 0x54620004, 0x3c02b49a, 0x3c024b65, 0x0a000548,
36495 -       0x34427654, 0x344289ab, 0xacc2001c, 0x0e000560, 0x00c02021, 0x3202ffff,
36496 -       0x0055102b, 0x1440ff7e, 0x00000000, 0x8e420000, 0x8e43fffc, 0x0043102a,
36497 -       0x1440ff1a, 0x00000000, 0x8fbf0034, 0x8fbe0030, 0x8fb7002c, 0x8fb60028,
36498 -       0x8fb50024, 0x8fb40020, 0x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010,
36499 -       0x03e00008, 0x27bd0038, 0x27bdffe8, 0xafbf0014, 0xafb00010, 0x8f624450,
36500 -       0x8f634410, 0x0a00056f, 0x00808021, 0x8f626820, 0x30422000, 0x10400003,
36501 -       0x00000000, 0x0e00025a, 0x00002021, 0x8f624450, 0x8f634410, 0x3042ffff,
36502 -       0x0043102b, 0x1440fff5, 0x00000000, 0x8f630c14, 0x3063000f, 0x2c620002,
36503 -       0x1440000b, 0x00000000, 0x8f630c14, 0x3c020800, 0x8c4216b4, 0x3063000f,
36504 -       0x24420001, 0x3c010800, 0xac2216b4, 0x2c620002, 0x1040fff7, 0x00000000,
36505 -       0xaf705c18, 0x8f625c10, 0x30420002, 0x10400009, 0x00000000, 0x8f626820,
36506 -       0x30422000, 0x1040fff8, 0x00000000, 0x0e00025a, 0x00002021, 0x0a000582,
36507 -       0x00000000, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x00000000,
36508 -       0x00000000
36509 +       0x0e0004b9, 0x00000000, 0x8fbf0028, 0x8fb30024, 0x8fb20020, 0x8fb1001c,
36510 +       0x8fb00018, 0x03e00008, 0x27bd0030, 0x8f634450, 0x3c040800, 0x24841b98,
36511 +       0x8c820000, 0x00031c02, 0x0043102b, 0x14400007, 0x3c038000, 0x8c840004,
36512 +       0x8f624450, 0x00021c02, 0x0083102b, 0x1040fffc, 0x3c038000, 0xaf634444,
36513 +       0x8f624444, 0x00431024, 0x1440fffd, 0x00000000, 0x8f624448, 0x03e00008,
36514 +       0x3042ffff, 0x3c024000, 0x00822025, 0xaf645c38, 0x8f625c30, 0x30420002,
36515 +       0x1440fffc, 0x00000000, 0x03e00008, 0x00000000, 0x27bdffe0, 0x00805821,
36516 +       0x14c00017, 0x256e0008, 0x3c020800, 0x8c422404, 0x1040000a, 0x2402003e,
36517 +       0x3c010800, 0xa42223e0, 0x24020016, 0x3c010800, 0xa42223e2, 0x2402002a,
36518 +       0x3c010800, 0x0a000360, 0xa42223e4, 0x95620014, 0x3c010800, 0xa42223e0,
36519 +       0x8d670010, 0x00071402, 0x3c010800, 0xa42223e2, 0x3c010800, 0xa42723e4,
36520 +       0x3c040800, 0x948423e4, 0x3c030800, 0x946323e2, 0x95cf0006, 0x3c020800,
36521 +       0x944223e0, 0x00832023, 0x01e2c023, 0x3065ffff, 0x24a20028, 0x01c24821,
36522 +       0x3082ffff, 0x14c0001a, 0x01226021, 0x9582000c, 0x3042003f, 0x3c010800,
36523 +       0xa42223e6, 0x95820004, 0x95830006, 0x3c010800, 0xac2023f4, 0x3c010800,
36524 +       0xac2023f8, 0x00021400, 0x00431025, 0x3c010800, 0xac221bd0, 0x95220004,
36525 +       0x3c010800, 0xa4221bd4, 0x95230002, 0x01e51023, 0x0043102a, 0x10400010,
36526 +       0x24020001, 0x3c010800, 0x0a000394, 0xac222408, 0x3c030800, 0x8c6323f8,
36527 +       0x3c020800, 0x94421bd4, 0x00431021, 0xa5220004, 0x3c020800, 0x94421bd0,
36528 +       0xa5820004, 0x3c020800, 0x8c421bd0, 0xa5820006, 0x3c020800, 0x8c422400,
36529 +       0x3c0d0800, 0x8dad23f4, 0x3c0a0800, 0x144000e5, 0x8d4a23f8, 0x3c020800,
36530 +       0x94421bd4, 0x004a1821, 0x3063ffff, 0x0062182b, 0x24020002, 0x10c2000d,
36531 +       0x01435023, 0x3c020800, 0x944223e6, 0x30420009, 0x10400008, 0x00000000,
36532 +       0x9582000c, 0x3042fff6, 0xa582000c, 0x3c020800, 0x944223e6, 0x30420009,
36533 +       0x01a26823, 0x3c020800, 0x8c422408, 0x1040004a, 0x01203821, 0x3c020800,
36534 +       0x944223e2, 0x00004021, 0xa520000a, 0x01e21023, 0xa5220002, 0x3082ffff,
36535 +       0x00021042, 0x18400008, 0x00003021, 0x00401821, 0x94e20000, 0x25080001,
36536 +       0x00c23021, 0x0103102a, 0x1440fffb, 0x24e70002, 0x00061c02, 0x30c2ffff,
36537 +       0x00623021, 0x00061402, 0x00c23021, 0x00c02821, 0x00061027, 0xa522000a,
36538 +       0x00003021, 0x2527000c, 0x00004021, 0x94e20000, 0x25080001, 0x00c23021,
36539 +       0x2d020004, 0x1440fffb, 0x24e70002, 0x95220002, 0x00004021, 0x91230009,
36540 +       0x00442023, 0x01803821, 0x3082ffff, 0xa4e00010, 0x00621821, 0x00021042,
36541 +       0x18400010, 0x00c33021, 0x00404821, 0x94e20000, 0x24e70002, 0x00c23021,
36542 +       0x30e2007f, 0x14400006, 0x25080001, 0x8d630000, 0x3c02007f, 0x3442ff80,
36543 +       0x00625824, 0x25670008, 0x0109102a, 0x1440fff3, 0x00000000, 0x30820001,
36544 +       0x10400005, 0x00061c02, 0xa0e00001, 0x94e20000, 0x00c23021, 0x00061c02,
36545 +       0x30c2ffff, 0x00623021, 0x00061402, 0x00c23021, 0x0a000479, 0x30c6ffff,
36546 +       0x24020002, 0x14c20081, 0x00000000, 0x3c020800, 0x8c42241c, 0x14400007,
36547 +       0x00000000, 0x3c020800, 0x944223e2, 0x95230002, 0x01e21023, 0x10620077,
36548 +       0x00000000, 0x3c020800, 0x944223e2, 0x01e21023, 0xa5220002, 0x3c020800,
36549 +       0x8c42241c, 0x1040001a, 0x31e3ffff, 0x8dc70010, 0x3c020800, 0x94421ba6,
36550 +       0x00e04021, 0x00072c02, 0x00aa2021, 0x00431023, 0x00823823, 0x00072402,
36551 +       0x30e2ffff, 0x00823821, 0x00071027, 0xa522000a, 0x3102ffff, 0x3c040800,
36552 +       0x948423e4, 0x00453023, 0x00e02821, 0x00641823, 0x006d1821, 0x00c33021,
36553 +       0x00061c02, 0x30c2ffff, 0x0a000479, 0x00623021, 0x01203821, 0x00004021,
36554 +       0x3082ffff, 0x00021042, 0x18400008, 0x00003021, 0x00401821, 0x94e20000,
36555 +       0x25080001, 0x00c23021, 0x0103102a, 0x1440fffb, 0x24e70002, 0x00061c02,
36556 +       0x30c2ffff, 0x00623021, 0x00061402, 0x00c23021, 0x00c02821, 0x00061027,
36557 +       0xa522000a, 0x00003021, 0x2527000c, 0x00004021, 0x94e20000, 0x25080001,
36558 +       0x00c23021, 0x2d020004, 0x1440fffb, 0x24e70002, 0x95220002, 0x00004021,
36559 +       0x91230009, 0x00442023, 0x01803821, 0x3082ffff, 0xa4e00010, 0x3c040800,
36560 +       0x948423e4, 0x00621821, 0x00c33021, 0x00061c02, 0x30c2ffff, 0x00623021,
36561 +       0x00061c02, 0x3c020800, 0x944223e0, 0x00c34821, 0x00441023, 0x00021fc2,
36562 +       0x00431021, 0x00021043, 0x18400010, 0x00003021, 0x00402021, 0x94e20000,
36563 +       0x24e70002, 0x00c23021, 0x30e2007f, 0x14400006, 0x25080001, 0x8d630000,
36564 +       0x3c02007f, 0x3442ff80, 0x00625824, 0x25670008, 0x0104102a, 0x1440fff3,
36565 +       0x00000000, 0x3c020800, 0x944223fc, 0x00c23021, 0x3122ffff, 0x00c23021,
36566 +       0x00061c02, 0x30c2ffff, 0x00623021, 0x00061402, 0x00c23021, 0x00c04021,
36567 +       0x00061027, 0xa5820010, 0xadc00014, 0x0a000499, 0xadc00000, 0x8dc70010,
36568 +       0x00e04021, 0x11400007, 0x00072c02, 0x00aa3021, 0x00061402, 0x30c3ffff,
36569 +       0x00433021, 0x00061402, 0x00c22821, 0x00051027, 0xa522000a, 0x3c030800,
36570 +       0x946323e4, 0x3102ffff, 0x01e21021, 0x00433023, 0x00cd3021, 0x00061c02,
36571 +       0x30c2ffff, 0x00623021, 0x00061402, 0x00c23021, 0x00c04021, 0x00061027,
36572 +       0xa5820010, 0x3102ffff, 0x00051c00, 0x00431025, 0xadc20010, 0x3c020800,
36573 +       0x8c422404, 0x10400002, 0x25e2fff2, 0xa5c20034, 0x3c020800, 0x8c4223f8,
36574 +       0x3c040800, 0x8c8423f4, 0x24420001, 0x3c010800, 0xac2223f8, 0x3c020800,
36575 +       0x8c421bd0, 0x3303ffff, 0x00832021, 0x3c010800, 0xac2423f4, 0x00431821,
36576 +       0x0062102b, 0x10400003, 0x2482ffff, 0x3c010800, 0xac2223f4, 0x3c010800,
36577 +       0xac231bd0, 0x03e00008, 0x27bd0020, 0x27bdffb8, 0x3c050800, 0x24a51ba8,
36578 +       0xafbf0044, 0xafbe0040, 0xafb7003c, 0xafb60038, 0xafb50034, 0xafb40030,
36579 +       0xafb3002c, 0xafb20028, 0xafb10024, 0xafb00020, 0x90a30000, 0x24020003,
36580 +       0x146200d5, 0x00000000, 0x3c090800, 0x95291ba6, 0x3c020800, 0x944223e0,
36581 +       0x3c030800, 0x8c631bc0, 0x3c040800, 0x8c841bbc, 0x01221023, 0x0064182a,
36582 +       0xa7a9001e, 0x106000c8, 0xa7a20016, 0x24be0020, 0x97b6001e, 0x24b30018,
36583 +       0x24b70014, 0x8fc20000, 0x14400008, 0x00000000, 0x8fc2fff8, 0x97a30016,
36584 +       0x8fc4fff4, 0x00431021, 0x0082202a, 0x148000ba, 0x00000000, 0x97d50818,
36585 +       0x32a2ffff, 0x104000ad, 0x00009021, 0x0040a021, 0x00008821, 0x0e00062d,
36586 +       0x00000000, 0x00403021, 0x14c00007, 0x00000000, 0x3c020800, 0x8c4223ec,
36587 +       0x24420001, 0x3c010800, 0x0a00059e, 0xac2223ec, 0x3c100800, 0x02118021,
36588 +       0x8e101bd8, 0x9608000a, 0x31020040, 0x10400004, 0x2407180c, 0x8e02000c,
36589 +       0x2407188c, 0xacc20018, 0x31021000, 0x10400004, 0x34e32000, 0x00081040,
36590 +       0x3042c000, 0x00623825, 0x31020080, 0x54400001, 0x34e70010, 0x3c020800,
36591 +       0x00511021, 0x8c421be0, 0x3c030800, 0x00711821, 0x8c631be4, 0x00021500,
36592 +       0x00031c00, 0x00431025, 0xacc20014, 0x96040008, 0x3242ffff, 0x00821021,
36593 +       0x0282102a, 0x14400002, 0x02b22823, 0x00802821, 0x8e020000, 0x02459021,
36594 +       0xacc20000, 0x8e020004, 0x00c02021, 0x26310010, 0xac820004, 0x30e2ffff,
36595 +       0xac800008, 0xa485000e, 0xac820010, 0x24020305, 0x0e0005aa, 0xa482000c,
36596 +       0x3242ffff, 0x0054102b, 0x1440ffc0, 0x3242ffff, 0x0a000596, 0x00000000,
36597 +       0x8e620000, 0x8e63fffc, 0x0043102a, 0x1040006c, 0x00000000, 0x8e62fff0,
36598 +       0x00028900, 0x3c100800, 0x02118021, 0x0e00062d, 0x8e101bd8, 0x00403021,
36599 +       0x14c00005, 0x00000000, 0x8e62082c, 0x24420001, 0x0a00059e, 0xae62082c,
36600 +       0x9608000a, 0x31020040, 0x10400004, 0x2407180c, 0x8e02000c, 0x2407188c,
36601 +       0xacc20018, 0x31021000, 0x10400004, 0x34e32000, 0x00081040, 0x3042c000,
36602 +       0x00623825, 0x3c020800, 0x00511021, 0x8c421be0, 0x3c030800, 0x00711821,
36603 +       0x8c631be4, 0x00021500, 0x00031c00, 0x00431025, 0xacc20014, 0x8e63fff4,
36604 +       0x96020008, 0x00432023, 0x3242ffff, 0x3083ffff, 0x00431021, 0x02c2102a,
36605 +       0x10400003, 0x00802821, 0x97a9001e, 0x01322823, 0x8e620000, 0x30a4ffff,
36606 +       0x00441021, 0xae620000, 0xa4c5000e, 0x8e020000, 0xacc20000, 0x8e020004,
36607 +       0x8e63fff4, 0x00431021, 0xacc20004, 0x8e63fff4, 0x96020008, 0x00641821,
36608 +       0x0062102a, 0x14400006, 0x02459021, 0x8e62fff0, 0xae60fff4, 0x24420001,
36609 +       0x0a000579, 0xae62fff0, 0xae63fff4, 0xacc00008, 0x3242ffff, 0x10560003,
36610 +       0x31020004, 0x10400006, 0x24020305, 0x31020080, 0x54400001, 0x34e70010,
36611 +       0x34e70020, 0x24020905, 0xa4c2000c, 0x8ee30000, 0x8ee20004, 0x14620007,
36612 +       0x3c02b49a, 0x8ee20860, 0x54400001, 0x34e70400, 0x3c024b65, 0x0a000590,
36613 +       0x34427654, 0x344289ab, 0xacc2001c, 0x30e2ffff, 0xacc20010, 0x0e0005aa,
36614 +       0x00c02021, 0x3242ffff, 0x0056102b, 0x1440ff96, 0x00000000, 0x8e620000,
36615 +       0x8e63fffc, 0x0043102a, 0x1440ff3e, 0x00000000, 0x8fbf0044, 0x8fbe0040,
36616 +       0x8fb7003c, 0x8fb60038, 0x8fb50034, 0x8fb40030, 0x8fb3002c, 0x8fb20028,
36617 +       0x8fb10024, 0x8fb00020, 0x03e00008, 0x27bd0048, 0x27bdffe8, 0xafbf0014,
36618 +       0xafb00010, 0x8f624450, 0x8f634410, 0x0a0005b9, 0x00808021, 0x8f626820,
36619 +       0x30422000, 0x10400003, 0x00000000, 0x0e0001e3, 0x00002021, 0x8f624450,
36620 +       0x8f634410, 0x3042ffff, 0x0043102b, 0x1440fff5, 0x00000000, 0x8f630c14,
36621 +       0x3063000f, 0x2c620002, 0x1440000b, 0x00000000, 0x8f630c14, 0x3c020800,
36622 +       0x8c421b50, 0x3063000f, 0x24420001, 0x3c010800, 0xac221b50, 0x2c620002,
36623 +       0x1040fff7, 0x00000000, 0xaf705c18, 0x8f625c10, 0x30420002, 0x10400009,
36624 +       0x00000000, 0x8f626820, 0x30422000, 0x1040fff8, 0x00000000, 0x0e0001e3,
36625 +       0x00002021, 0x0a0005cc, 0x00000000, 0x8fbf0014, 0x8fb00010, 0x03e00008,
36626 +       0x27bd0018, 0x00000000, 0x00000000, 0x00000000, 0x27bdffe8, 0x3c1bc000,
36627 +       0xafbf0014, 0xafb00010, 0xaf60680c, 0x8f626804, 0x34420082, 0xaf626804,
36628 +       0x8f634000, 0x24020b50, 0x3c010800, 0xac221b64, 0x24020b78, 0x3c010800,
36629 +       0xac221b74, 0x34630002, 0xaf634000, 0x0e00060d, 0x00808021, 0x3c010800,
36630 +       0xa0221b78, 0x304200ff, 0x24030002, 0x14430005, 0x00000000, 0x3c020800,
36631 +       0x8c421b64, 0x0a000600, 0xac5000c0, 0x3c020800, 0x8c421b64, 0xac5000bc,
36632 +       0x8f624434, 0x8f634438, 0x8f644410, 0x3c010800, 0xac221b6c, 0x3c010800,
36633 +       0xac231b7c, 0x3c010800, 0xac241b68, 0x8fbf0014, 0x8fb00010, 0x03e00008,
36634 +       0x27bd0018, 0x3c040800, 0x8c870000, 0x3c03aa55, 0x3463aa55, 0x3c06c003,
36635 +       0xac830000, 0x8cc20000, 0x14430007, 0x24050002, 0x3c0355aa, 0x346355aa,
36636 +       0xac830000, 0x8cc20000, 0x50430001, 0x24050001, 0x3c020800, 0xac470000,
36637 +       0x03e00008, 0x00a01021, 0x27bdfff8, 0x18800009, 0x00002821, 0x8f63680c,
36638 +       0x8f62680c, 0x1043fffe, 0x00000000, 0x24a50001, 0x00a4102a, 0x1440fff9,
36639 +       0x00000000, 0x03e00008, 0x27bd0008, 0x8f634450, 0x3c020800, 0x8c421b6c,
36640 +       0x00031c02, 0x0043102b, 0x14400008, 0x3c038000, 0x3c040800, 0x8c841b7c,
36641 +       0x8f624450, 0x00021c02, 0x0083102b, 0x1040fffc, 0x3c038000, 0xaf634444,
36642 +       0x8f624444, 0x00431024, 0x1440fffd, 0x00000000, 0x8f624448, 0x03e00008,
36643 +       0x3042ffff, 0x3082ffff, 0x2442e000, 0x2c422001, 0x14400003, 0x3c024000,
36644 +       0x0a000650, 0x2402ffff, 0x00822025, 0xaf645c38, 0x8f625c30, 0x30420002,
36645 +       0x1440fffc, 0x00001021, 0x03e00008, 0x00000000, 0x8f624450, 0x3c030800,
36646 +       0x8c631b68, 0x0a000659, 0x3042ffff, 0x8f624450, 0x3042ffff, 0x0043102b,
36647 +       0x1440fffc, 0x00000000, 0x03e00008, 0x00000000, 0x27bdffe0, 0x00802821,
36648 +       0x3c040800, 0x24841b10, 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010,
36649 +       0x0e000684, 0xafa00014, 0x0a000668, 0x00000000, 0x8fbf0018, 0x03e00008,
36650 +       0x27bd0020, 0x00000000, 0x00000000, 0x00000000, 0x3c020800, 0x34423000,
36651 +       0x3c030800, 0x34633000, 0x3c040800, 0x348437ff, 0x3c010800, 0xac221b84,
36652 +       0x24020040, 0x3c010800, 0xac221b88, 0x3c010800, 0xac201b80, 0xac600000,
36653 +       0x24630004, 0x0083102b, 0x5040fffd, 0xac600000, 0x03e00008, 0x00000000,
36654 +       0x00804821, 0x8faa0010, 0x3c020800, 0x8c421b80, 0x3c040800, 0x8c841b88,
36655 +       0x8fab0014, 0x24430001, 0x0044102b, 0x3c010800, 0xac231b80, 0x14400003,
36656 +       0x00004021, 0x3c010800, 0xac201b80, 0x3c020800, 0x8c421b80, 0x3c030800,
36657 +       0x8c631b84, 0x91240000, 0x00021140, 0x00431021, 0x00481021, 0x25080001,
36658 +       0xa0440000, 0x29020008, 0x1440fff4, 0x25290001, 0x3c020800, 0x8c421b80,
36659 +       0x3c030800, 0x8c631b84, 0x8f64680c, 0x00021140, 0x00431021, 0xac440008,
36660 +       0xac45000c, 0xac460010, 0xac470014, 0xac4a0018, 0x03e00008, 0xac4b001c,
36661 +       0x00000000, 0x00000000,
36662  };
36663  
36664  u32 tg3TsoFwRodata[] = {
36665 -       0x4d61696e, 0x43707542, 0x00000000, 0x00000000, 0x74637073, 0x6567496e,
36666 -       0x00000000, 0x53774576, 0x656e7430, 0x00000000, 0x00000000, 0x00000000,
36667 -       0x00000000
36668 +       0x4d61696e, 0x43707542, 0x00000000, 0x4d61696e, 0x43707541,
36669 +       0x00000000, 0x00000000, 0x00000000, 0x73746b6f, 0x66666c64,
36670 +       0x496e0000, 0x73746b6f, 0x66662a2a, 0x00000000, 0x53774576,
36671 +       0x656e7430, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
36672 +       0x66617461, 0x6c457272, 0x00000000, 0x00000000, 0x00000000
36673  };
36674  
36675  #if 0 /* All zeros, don't eat up space with it. */
36676 @@ -3785,63 +4178,274 @@
36677  };
36678  #endif
36679  
36680 +/* 5705 needs a special version of the TSO firmware.  */
36681 +#define TG3_TSO5_FW_RELEASE_MAJOR      0x1
36682 +#define TG3_TSO5_FW_RELASE_MINOR       0x1
36683 +#define TG3_TSO5_FW_RELEASE_FIX                0x0
36684 +#define TG3_TSO5_FW_START_ADDR         0x00010000
36685 +#define TG3_TSO5_FW_TEXT_ADDR          0x00010000
36686 +#define TG3_TSO5_FW_TEXT_LEN           0xeb0
36687 +#define TG3_TSO5_FW_RODATA_ADDR                0x00010eb0
36688 +#define TG3_TSO5_FW_RODATA_LEN         0x50
36689 +#define TG3_TSO5_FW_DATA_ADDR          0x00010f20
36690 +#define TG3_TSO5_FW_DATA_LEN           0x20
36691 +#define TG3_TSO5_FW_SBSS_ADDR          0x00010f40
36692 +#define TG3_TSO5_FW_SBSS_LEN           0x28
36693 +#define TG3_TSO5_FW_BSS_ADDR           0x00010f70
36694 +#define TG3_TSO5_FW_BSS_LEN            0x88
36695 +
36696 +static u32 tg3Tso5FwText[] = {
36697 +       0x0c004003, 0x00000000, 0x00010f30, 0x00000000, 0x10000003, 0x00000000,
36698 +       0x0000000d, 0x0000000d, 0x3c1d0001, 0x37bde000, 0x03a0f021, 0x3c100001,
36699 +       0x26100000, 0x0c004010, 0x00000000, 0x0000000d, 0x27bdffe0, 0x3c04fefe,
36700 +       0xafbf0018, 0x0c0042f0, 0x34840002, 0x0c00436c, 0x00000000, 0x3c030001,
36701 +       0x90630f54, 0x24020002, 0x3c040001, 0x24840ebc, 0x14620003, 0x24050001,
36702 +       0x3c040001, 0x24840eb0, 0x24060001, 0x00003821, 0xafa00010, 0x0c004380,
36703 +       0xafa00014, 0x0c00402c, 0x00000000, 0x8fbf0018, 0x03e00008, 0x27bd0020,
36704 +       0x00000000, 0x00000000, 0x27bdffe0, 0xafbf001c, 0xafb20018, 0xafb10014,
36705 +       0x0c0042d3, 0xafb00010, 0x3c128000, 0x24110001, 0x8f706810, 0x32020400,
36706 +       0x10400007, 0x00000000, 0x8f641008, 0x00921024, 0x14400003, 0x00000000,
36707 +       0x0c004064, 0x00000000, 0x3c020001, 0x90420f76, 0x10510003, 0x32020200,
36708 +       0x1040fff1, 0x00000000, 0x0c0041b4, 0x00000000, 0x08004034, 0x00000000,
36709 +       0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020,
36710 +       0x27bdffe0, 0x3c040001, 0x24840ed0, 0x00002821, 0x00003021, 0x00003821,
36711 +       0xafbf0018, 0xafa00010, 0x0c004380, 0xafa00014, 0x0000d021, 0x24020130,
36712 +       0xaf625000, 0x3c010001, 0xa4200f70, 0x3c010001, 0xa0200f77, 0x8fbf0018,
36713 +       0x03e00008, 0x27bd0020, 0x00000000, 0x00000000, 0x3c030001, 0x24630f80,
36714 +       0x90620000, 0x27bdfff0, 0x14400003, 0x0080c021, 0x08004073, 0x00004821,
36715 +       0x3c022000, 0x03021024, 0x10400003, 0x24090002, 0x08004073, 0xa0600000,
36716 +       0x24090001, 0x00181040, 0x30431f80, 0x346f8008, 0x1520004b, 0x25eb0028,
36717 +       0x3c040001, 0x00832021, 0x8c848010, 0x3c050001, 0x24a50f9a, 0x00041402,
36718 +       0xa0a20000, 0x3c010001, 0xa0240f9b, 0x3c020001, 0x00431021, 0x94428014,
36719 +       0x3c010001, 0xa0220f9c, 0x3c0c0001, 0x01836021, 0x8d8c8018, 0x304200ff,
36720 +       0x24420008, 0x000220c3, 0x24020001, 0x3c010001, 0xa0220f80, 0x0124102b,
36721 +       0x1040000c, 0x00003821, 0x24a6000e, 0x01602821, 0x8ca20000, 0x8ca30004,
36722 +       0x24a50008, 0x24e70001, 0xacc20000, 0xacc30004, 0x00e4102b, 0x1440fff8,
36723 +       0x24c60008, 0x00003821, 0x3c080001, 0x25080f9b, 0x91060000, 0x3c020001,
36724 +       0x90420f9c, 0x2503000d, 0x00c32821, 0x00461023, 0x00021fc2, 0x00431021,
36725 +       0x00021043, 0x1840000c, 0x00002021, 0x91020001, 0x00461023, 0x00021fc2,
36726 +       0x00431021, 0x00021843, 0x94a20000, 0x24e70001, 0x00822021, 0x00e3102a,
36727 +       0x1440fffb, 0x24a50002, 0x00041c02, 0x3082ffff, 0x00622021, 0x00041402,
36728 +       0x00822021, 0x3c02ffff, 0x01821024, 0x3083ffff, 0x00431025, 0x3c010001,
36729 +       0x080040fa, 0xac220fa0, 0x3c050001, 0x24a50f9c, 0x90a20000, 0x3c0c0001,
36730 +       0x01836021, 0x8d8c8018, 0x000220c2, 0x1080000e, 0x00003821, 0x01603021,
36731 +       0x24a5000c, 0x8ca20000, 0x8ca30004, 0x24a50008, 0x24e70001, 0xacc20000,
36732 +       0xacc30004, 0x00e4102b, 0x1440fff8, 0x24c60008, 0x3c050001, 0x24a50f9c,
36733 +       0x90a20000, 0x30430007, 0x24020004, 0x10620011, 0x28620005, 0x10400005,
36734 +       0x24020002, 0x10620008, 0x000710c0, 0x080040fa, 0x00000000, 0x24020006,
36735 +       0x1062000e, 0x000710c0, 0x080040fa, 0x00000000, 0x00a21821, 0x9463000c,
36736 +       0x004b1021, 0x080040fa, 0xa4430000, 0x000710c0, 0x00a21821, 0x8c63000c,
36737 +       0x004b1021, 0x080040fa, 0xac430000, 0x00a21821, 0x8c63000c, 0x004b2021,
36738 +       0x00a21021, 0xac830000, 0x94420010, 0xa4820004, 0x95e70006, 0x3c020001,
36739 +       0x90420f9c, 0x3c030001, 0x90630f9a, 0x00e2c823, 0x3c020001, 0x90420f9b,
36740 +       0x24630028, 0x01e34021, 0x24420028, 0x15200012, 0x01e23021, 0x94c2000c,
36741 +       0x3c010001, 0xa4220f98, 0x94c20004, 0x94c30006, 0x3c010001, 0xa4200f96,
36742 +       0x3c010001, 0xa4200f92, 0x00021400, 0x00431025, 0x3c010001, 0xac220f8c,
36743 +       0x95020004, 0x3c010001, 0x08004124, 0xa4220f90, 0x3c020001, 0x94420f90,
36744 +       0x3c030001, 0x94630f92, 0x00431021, 0xa5020004, 0x3c020001, 0x94420f8c,
36745 +       0xa4c20004, 0x3c020001, 0x8c420f8c, 0xa4c20006, 0x3c040001, 0x94840f92,
36746 +       0x3c020001, 0x94420f90, 0x3c0a0001, 0x954a0f96, 0x00441821, 0x3063ffff,
36747 +       0x0062182a, 0x24020002, 0x1122000b, 0x00832023, 0x3c030001, 0x94630f98,
36748 +       0x30620009, 0x10400006, 0x3062fff6, 0xa4c2000c, 0x3c020001, 0x94420f98,
36749 +       0x30420009, 0x01425023, 0x24020001, 0x1122001b, 0x29220002, 0x50400005,
36750 +       0x24020002, 0x11200007, 0x31a2ffff, 0x08004197, 0x00000000, 0x1122001d,
36751 +       0x24020016, 0x08004197, 0x31a2ffff, 0x3c0e0001, 0x95ce0fa0, 0x10800005,
36752 +       0x01806821, 0x01c42021, 0x00041c02, 0x3082ffff, 0x00627021, 0x000e1027,
36753 +       0xa502000a, 0x3c030001, 0x90630f9b, 0x31a2ffff, 0x00e21021, 0x0800418d,
36754 +       0x00432023, 0x3c020001, 0x94420fa0, 0x00442021, 0x00041c02, 0x3082ffff,
36755 +       0x00622021, 0x00807021, 0x00041027, 0x08004185, 0xa502000a, 0x3c050001,
36756 +       0x24a50f9a, 0x90a30000, 0x14620002, 0x24e2fff2, 0xa5e20034, 0x90a20000,
36757 +       0x00e21023, 0xa5020002, 0x3c030001, 0x94630fa0, 0x3c020001, 0x94420f7a,
36758 +       0x30e5ffff, 0x00641821, 0x00451023, 0x00622023, 0x00041c02, 0x3082ffff,
36759 +       0x00622021, 0x00041027, 0xa502000a, 0x3c030001, 0x90630f9c, 0x24620001,
36760 +       0x14a20005, 0x00807021, 0x01631021, 0x90420000, 0x08004185, 0x00026200,
36761 +       0x24620002, 0x14a20003, 0x306200fe, 0x004b1021, 0x944c0000, 0x3c020001,
36762 +       0x94420fa2, 0x3183ffff, 0x3c040001, 0x90840f9b, 0x00431021, 0x00e21021,
36763 +       0x00442023, 0x008a2021, 0x00041c02, 0x3082ffff, 0x00622021, 0x00041402,
36764 +       0x00822021, 0x00806821, 0x00041027, 0xa4c20010, 0x31a2ffff, 0x000e1c00,
36765 +       0x00431025, 0x3c040001, 0x24840f92, 0xade20010, 0x94820000, 0x3c050001,
36766 +       0x94a50f96, 0x3c030001, 0x8c630f8c, 0x24420001, 0x00b92821, 0xa4820000,
36767 +       0x3322ffff, 0x00622021, 0x0083182b, 0x3c010001, 0xa4250f96, 0x10600003,
36768 +       0x24a2ffff, 0x3c010001, 0xa4220f96, 0x3c024000, 0x03021025, 0x3c010001,
36769 +       0xac240f8c, 0xaf621008, 0x03e00008, 0x27bd0010, 0x3c030001, 0x90630f76,
36770 +       0x27bdffe8, 0x24020001, 0xafbf0014, 0x10620026, 0xafb00010, 0x8f620cf4,
36771 +       0x2442ffff, 0x3042007f, 0x00021100, 0x8c434000, 0x3c010001, 0xac230f84,
36772 +       0x8c434008, 0x24444000, 0x8c5c4004, 0x30620040, 0x14400002, 0x24020088,
36773 +       0x24020008, 0x3c010001, 0xa4220f88, 0x30620004, 0x10400005, 0x24020001,
36774 +       0x3c010001, 0xa0220f77, 0x080041d5, 0x00031402, 0x3c010001, 0xa0200f77,
36775 +       0x00031402, 0x3c010001, 0xa4220f74, 0x9483000c, 0x24020001, 0x3c010001,
36776 +       0xa4200f70, 0x3c010001, 0xa0220f76, 0x3c010001, 0xa4230f82, 0x24020001,
36777 +       0x1342001e, 0x00000000, 0x13400005, 0x24020003, 0x13420067, 0x00000000,
36778 +       0x080042cf, 0x00000000, 0x3c020001, 0x94420f82, 0x241a0001, 0x3c010001,
36779 +       0xa4200f7e, 0x3c010001, 0xa4200f72, 0x304407ff, 0x00021bc2, 0x00031823,
36780 +       0x3063003e, 0x34630036, 0x00021242, 0x3042003c, 0x00621821, 0x3c010001,
36781 +       0xa4240f78, 0x00832021, 0x24630030, 0x3c010001, 0xa4240f7a, 0x3c010001,
36782 +       0xa4230f7c, 0x3c060001, 0x24c60f72, 0x94c50000, 0x94c30002, 0x3c040001,
36783 +       0x94840f7a, 0x00651021, 0x0044102a, 0x10400013, 0x3c108000, 0x00a31021,
36784 +       0xa4c20000, 0x3c02a000, 0xaf620cf4, 0x3c010001, 0xa0200f76, 0x8f641008,
36785 +       0x00901024, 0x14400003, 0x00000000, 0x0c004064, 0x00000000, 0x8f620cf4,
36786 +       0x00501024, 0x104000b7, 0x00000000, 0x0800420f, 0x00000000, 0x3c030001,
36787 +       0x94630f70, 0x00851023, 0xa4c40000, 0x00621821, 0x3042ffff, 0x3c010001,
36788 +       0xa4230f70, 0xaf620ce8, 0x3c020001, 0x94420f88, 0x34420024, 0xaf620cec,
36789 +       0x94c30002, 0x3c020001, 0x94420f70, 0x14620012, 0x3c028000, 0x3c108000,
36790 +       0x3c02a000, 0xaf620cf4, 0x3c010001, 0xa0200f76, 0x8f641008, 0x00901024,
36791 +       0x14400003, 0x00000000, 0x0c004064, 0x00000000, 0x8f620cf4, 0x00501024,
36792 +       0x1440fff7, 0x00000000, 0x080042cf, 0x241a0003, 0xaf620cf4, 0x3c108000,
36793 +       0x8f641008, 0x00901024, 0x14400003, 0x00000000, 0x0c004064, 0x00000000,
36794 +       0x8f620cf4, 0x00501024, 0x1440fff7, 0x00000000, 0x080042cf, 0x241a0003,
36795 +       0x3c070001, 0x24e70f70, 0x94e20000, 0x03821021, 0xaf620ce0, 0x3c020001,
36796 +       0x8c420f84, 0xaf620ce4, 0x3c050001, 0x94a50f74, 0x94e30000, 0x3c040001,
36797 +       0x94840f78, 0x3c020001, 0x94420f7e, 0x00a32823, 0x00822023, 0x30a6ffff,
36798 +       0x3083ffff, 0x00c3102b, 0x14400043, 0x00000000, 0x3c020001, 0x94420f7c,
36799 +       0x00021400, 0x00621025, 0xaf620ce8, 0x94e20000, 0x3c030001, 0x94630f74,
36800 +       0x00441021, 0xa4e20000, 0x3042ffff, 0x14430021, 0x3c020008, 0x3c020001,
36801 +       0x90420f77, 0x10400006, 0x3c03000c, 0x3c020001, 0x94420f88, 0x34630624,
36802 +       0x0800427c, 0x0000d021, 0x3c020001, 0x94420f88, 0x3c030008, 0x34630624,
36803 +       0x00431025, 0xaf620cec, 0x3c108000, 0x3c02a000, 0xaf620cf4, 0x3c010001,
36804 +       0xa0200f76, 0x8f641008, 0x00901024, 0x14400003, 0x00000000, 0x0c004064,
36805 +       0x00000000, 0x8f620cf4, 0x00501024, 0x10400015, 0x00000000, 0x08004283,
36806 +       0x00000000, 0x3c030001, 0x94630f88, 0x34420624, 0x3c108000, 0x00621825,
36807 +       0x3c028000, 0xaf630cec, 0xaf620cf4, 0x8f641008, 0x00901024, 0x14400003,
36808 +       0x00000000, 0x0c004064, 0x00000000, 0x8f620cf4, 0x00501024, 0x1440fff7,
36809 +       0x00000000, 0x3c010001, 0x080042cf, 0xa4200f7e, 0x3c020001, 0x94420f7c,
36810 +       0x00021400, 0x00c21025, 0xaf620ce8, 0x3c020001, 0x90420f77, 0x10400009,
36811 +       0x3c03000c, 0x3c020001, 0x94420f88, 0x34630624, 0x0000d021, 0x00431025,
36812 +       0xaf620cec, 0x080042c1, 0x3c108000, 0x3c020001, 0x94420f88, 0x3c030008,
36813 +       0x34630604, 0x00431025, 0xaf620cec, 0x3c020001, 0x94420f7e, 0x00451021,
36814 +       0x3c010001, 0xa4220f7e, 0x3c108000, 0x3c02a000, 0xaf620cf4, 0x3c010001,
36815 +       0xa0200f76, 0x8f641008, 0x00901024, 0x14400003, 0x00000000, 0x0c004064,
36816 +       0x00000000, 0x8f620cf4, 0x00501024, 0x1440fff7, 0x00000000, 0x8fbf0014,
36817 +       0x8fb00010, 0x03e00008, 0x27bd0018, 0x27bdffe0, 0x3c040001, 0x24840ee0,
36818 +       0x00002821, 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010, 0x0c004380,
36819 +       0xafa00014, 0x0000d021, 0x24020130, 0xaf625000, 0x3c010001, 0xa4200f70,
36820 +       0x3c010001, 0xa0200f77, 0x8f636804, 0x3c020001, 0x3442e000, 0x00621824,
36821 +       0x3c020001, 0x14620003, 0x00000000, 0x080042eb, 0x00000000, 0x8fbf0018,
36822 +       0x03e00008, 0x27bd0020, 0x27bdffe8, 0x3c1bc000, 0xafbf0014, 0xafb00010,
36823 +       0xaf60680c, 0x8f626804, 0x34420082, 0xaf626804, 0x8f634000, 0x24020b50,
36824 +       0x3c010001, 0xac220f40, 0x24020b78, 0x3c010001, 0xac220f50, 0x34630002,
36825 +       0xaf634000, 0x0c00431d, 0x00808021, 0x3c010001, 0xa0220f54, 0x304200ff,
36826 +       0x24030002, 0x14430005, 0x00000000, 0x3c020001, 0x8c420f40, 0x08004310,
36827 +       0xac5000c0, 0x3c020001, 0x8c420f40, 0xac5000bc, 0x8f624434, 0x8f634438,
36828 +       0x8f644410, 0x3c010001, 0xac220f48, 0x3c010001, 0xac230f58, 0x3c010001,
36829 +       0xac240f44, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x03e00008,
36830 +       0x24020001, 0x27bdfff8, 0x18800009, 0x00002821, 0x8f63680c, 0x8f62680c,
36831 +       0x1043fffe, 0x00000000, 0x24a50001, 0x00a4102a, 0x1440fff9, 0x00000000,
36832 +       0x03e00008, 0x27bd0008, 0x8f634450, 0x3c020001, 0x8c420f48, 0x00031c02,
36833 +       0x0043102b, 0x14400008, 0x3c038000, 0x3c040001, 0x8c840f58, 0x8f624450,
36834 +       0x00021c02, 0x0083102b, 0x1040fffc, 0x3c038000, 0xaf634444, 0x8f624444,
36835 +       0x00431024, 0x1440fffd, 0x00000000, 0x8f624448, 0x03e00008, 0x3042ffff,
36836 +       0x3082ffff, 0x2442e000, 0x2c422001, 0x14400003, 0x3c024000, 0x0800434f,
36837 +       0x2402ffff, 0x00822025, 0xaf645c38, 0x8f625c30, 0x30420002, 0x1440fffc,
36838 +       0x00001021, 0x03e00008, 0x00000000, 0x8f624450, 0x3c030001, 0x8c630f44,
36839 +       0x08004358, 0x3042ffff, 0x8f624450, 0x3042ffff, 0x0043102b, 0x1440fffc,
36840 +       0x00000000, 0x03e00008, 0x00000000, 0x27bdffe0, 0x00802821, 0x3c040001,
36841 +       0x24840ef0, 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010, 0x0c004380,
36842 +       0xafa00014, 0x08004367, 0x00000000, 0x8fbf0018, 0x03e00008, 0x27bd0020,
36843 +       0x3c020001, 0x3442d600, 0x3c030001, 0x3463d600, 0x3c040001, 0x3484ddff,
36844 +       0x3c010001, 0xac220f60, 0x24020040, 0x3c010001, 0xac220f64, 0x3c010001,
36845 +       0xac200f5c, 0xac600000, 0x24630004, 0x0083102b, 0x5040fffd, 0xac600000,
36846 +       0x03e00008, 0x00000000, 0x00804821, 0x8faa0010, 0x3c020001, 0x8c420f5c,
36847 +       0x3c040001, 0x8c840f64, 0x8fab0014, 0x24430001, 0x0044102b, 0x3c010001,
36848 +       0xac230f5c, 0x14400003, 0x00004021, 0x3c010001, 0xac200f5c, 0x3c020001,
36849 +       0x8c420f5c, 0x3c030001, 0x8c630f60, 0x91240000, 0x00021140, 0x00431021,
36850 +       0x00481021, 0x25080001, 0xa0440000, 0x29020008, 0x1440fff4, 0x25290001,
36851 +       0x3c020001, 0x8c420f5c, 0x3c030001, 0x8c630f60, 0x8f64680c, 0x00021140,
36852 +       0x00431021, 0xac440008, 0xac45000c, 0xac460010, 0xac470014, 0xac4a0018,
36853 +       0x03e00008, 0xac4b001c, 0x00000000, 0x00000000,
36854 +};
36855 +
36856 +u32 tg3Tso5FwRodata[] = {
36857 +       0x4d61696e, 0x43707542, 0x00000000, 0x4d61696e, 0x43707541, 0x00000000,
36858 +       0x00000000, 0x00000000, 0x73746b6f, 0x66666c64, 0x00000000, 0x00000000,
36859 +       0x73746b6f, 0x66666c64, 0x00000000, 0x00000000, 0x66617461, 0x6c457272,
36860 +       0x00000000, 0x00000000, 0x00000000
36861 +};
36862 +
36863 +u32 tg3Tso5FwData[] = {
36864 +       0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x73746b6f, 
36865 +       0x66666c64, 0x5f76312e, 0x312e3000, 0x00000000
36866 +};
36867 +
36868  /* tp->lock is held. */
36869  static int tg3_load_tso_firmware(struct tg3 *tp)
36870  {
36871         struct fw_info info;
36872 +       unsigned long cpu_base, cpu_scratch_base, cpu_scratch_size;
36873         int err, i;
36874  
36875 -       info.text_base = TG3_TSO_FW_TEXT_ADDR;
36876 -       info.text_len = TG3_TSO_FW_TEXT_LEN;
36877 -       info.text_data = &tg3TsoFwText[0];
36878 -       info.rodata_base = TG3_TSO_FW_RODATA_ADDR;
36879 -       info.rodata_len = TG3_TSO_FW_RODATA_LEN;
36880 -       info.rodata_data = &tg3TsoFwRodata[0];
36881 -       info.data_base = TG3_TSO_FW_DATA_ADDR;
36882 -       info.data_len = TG3_TSO_FW_DATA_LEN;
36883 -       info.data_data = NULL;
36884 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
36885 +               info.text_base = TG3_TSO5_FW_TEXT_ADDR;
36886 +               info.text_len = TG3_TSO5_FW_TEXT_LEN;
36887 +               info.text_data = &tg3Tso5FwText[0];
36888 +               info.rodata_base = TG3_TSO5_FW_RODATA_ADDR;
36889 +               info.rodata_len = TG3_TSO5_FW_RODATA_LEN;
36890 +               info.rodata_data = &tg3Tso5FwRodata[0];
36891 +               info.data_base = TG3_TSO5_FW_DATA_ADDR;
36892 +               info.data_len = TG3_TSO5_FW_DATA_LEN;
36893 +               info.data_data = &tg3Tso5FwData[0];
36894 +               cpu_base = RX_CPU_BASE;
36895 +               cpu_scratch_base = NIC_SRAM_MBUF_POOL_BASE5705;
36896 +               cpu_scratch_size = (info.text_len +
36897 +                                   info.rodata_len +
36898 +                                   info.data_len +
36899 +                                   TG3_TSO5_FW_SBSS_LEN +
36900 +                                   TG3_TSO5_FW_BSS_LEN);
36901 +       } else {
36902 +               info.text_base = TG3_TSO_FW_TEXT_ADDR;
36903 +               info.text_len = TG3_TSO_FW_TEXT_LEN;
36904 +               info.text_data = &tg3TsoFwText[0];
36905 +               info.rodata_base = TG3_TSO_FW_RODATA_ADDR;
36906 +               info.rodata_len = TG3_TSO_FW_RODATA_LEN;
36907 +               info.rodata_data = &tg3TsoFwRodata[0];
36908 +               info.data_base = TG3_TSO_FW_DATA_ADDR;
36909 +               info.data_len = TG3_TSO_FW_DATA_LEN;
36910 +               info.data_data = NULL;
36911 +               cpu_base = TX_CPU_BASE;
36912 +               cpu_scratch_base = TX_CPU_SCRATCH_BASE;
36913 +               cpu_scratch_size = TX_CPU_SCRATCH_SIZE;
36914 +       }
36915  
36916 -       err = tg3_load_firmware_cpu(tp, TX_CPU_BASE,
36917 -                                   TX_CPU_SCRATCH_BASE, TX_CPU_SCRATCH_SIZE,
36918 +       err = tg3_load_firmware_cpu(tp, cpu_base,
36919 +                                   cpu_scratch_base, cpu_scratch_size,
36920                                     &info);
36921         if (err)
36922                 return err;
36923  
36924 -       /* Now startup only the TX cpu. */
36925 -       tw32(TX_CPU_BASE + CPU_STATE, 0xffffffff);
36926 -       tw32(TX_CPU_BASE + CPU_PC,    TG3_TSO_FW_TEXT_ADDR);
36927 +       /* Now startup the cpu. */
36928 +       tw32(cpu_base + CPU_STATE, 0xffffffff);
36929 +       tw32(cpu_base + CPU_PC,    info.text_base);
36930  
36931         /* Flush posted writes. */
36932 -       tr32(TX_CPU_BASE + CPU_PC);
36933 +       tr32(cpu_base + CPU_PC);
36934         for (i = 0; i < 5; i++) {
36935 -               if (tr32(TX_CPU_BASE + CPU_PC) == TG3_TSO_FW_TEXT_ADDR)
36936 +               if (tr32(cpu_base + CPU_PC) == info.text_base)
36937                         break;
36938 -               tw32(TX_CPU_BASE + CPU_STATE, 0xffffffff);
36939 -               tw32(TX_CPU_BASE + CPU_MODE,  CPU_MODE_HALT);
36940 -               tw32(TX_CPU_BASE + CPU_PC,    TG3_TSO_FW_TEXT_ADDR);
36941 +               tw32(cpu_base + CPU_STATE, 0xffffffff);
36942 +               tw32(cpu_base + CPU_MODE,  CPU_MODE_HALT);
36943 +               tw32(cpu_base + CPU_PC,    info.text_base);
36944  
36945                 /* Flush posted writes. */
36946 -               tr32(TX_CPU_BASE + CPU_PC);
36947 +               tr32(cpu_base + CPU_PC);
36948  
36949                 udelay(1000);
36950         }
36951         if (i >= 5) {
36952                 printk(KERN_ERR PFX "tg3_load_tso_firmware fails for %s "
36953 -                      "to set TX CPU PC, is %08x should be %08x\n",
36954 -                      tp->dev->name, tr32(TX_CPU_BASE + CPU_PC),
36955 -                      TG3_TSO_FW_TEXT_ADDR);
36956 +                      "to set CPU PC, is %08x should be %08x\n",
36957 +                      tp->dev->name, tr32(cpu_base + CPU_PC),
36958 +                      info.text_base);
36959                 return -ENODEV;
36960         }
36961 -       tw32(TX_CPU_BASE + CPU_STATE, 0xffffffff);
36962 -       tw32(TX_CPU_BASE + CPU_MODE,  0x00000000);
36963 +       tw32(cpu_base + CPU_STATE, 0xffffffff);
36964 +       tw32(cpu_base + CPU_MODE,  0x00000000);
36965  
36966         /* Flush posted writes. */
36967 -       tr32(TX_CPU_BASE + CPU_MODE);
36968 +       tr32(cpu_base + CPU_MODE);
36969  
36970         return 0;
36971  }
36972  
36973 -#endif /* TG3_DO_TSO != 0 */
36974 +#endif /* TG3_TSO_SUPPORT != 0 */
36975  
36976  /* tp->lock is held. */
36977  static void __tg3_set_mac_addr(struct tg3 *tp)
36978 @@ -3860,6 +4464,15 @@
36979                 tw32(MAC_ADDR_0_LOW + (i * 8), addr_low);
36980         }
36981  
36982 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700 &&
36983 +           GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701 &&
36984 +           GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
36985 +               for (i = 0; i < 12; i++) {
36986 +                       tw32(MAC_EXTADDR_0_HIGH + (i * 8), addr_high);
36987 +                       tw32(MAC_EXTADDR_0_LOW + (i * 8), addr_low);
36988 +               }
36989 +       }
36990 +
36991         addr_high = (tp->dev->dev_addr[0] +
36992                      tp->dev->dev_addr[1] +
36993                      tp->dev->dev_addr[2] +
36994 @@ -3893,23 +4506,19 @@
36995                            u32 nic_addr)
36996  {
36997         tg3_write_mem(tp,
36998 -                     (bdinfo_addr +
36999 -                      TG3_BDINFO_HOST_ADDR +
37000 -                      TG3_64BIT_REG_HIGH),
37001 +                     (bdinfo_addr + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_HIGH),
37002                       ((u64) mapping >> 32));
37003         tg3_write_mem(tp,
37004 -                     (bdinfo_addr +
37005 -                      TG3_BDINFO_HOST_ADDR +
37006 -                      TG3_64BIT_REG_LOW),
37007 +                     (bdinfo_addr + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW),
37008                       ((u64) mapping & 0xffffffff));
37009         tg3_write_mem(tp,
37010 -                     (bdinfo_addr +
37011 -                      TG3_BDINFO_MAXLEN_FLAGS),
37012 +                     (bdinfo_addr + TG3_BDINFO_MAXLEN_FLAGS),
37013                        maxlen_flags);
37014 -       tg3_write_mem(tp,
37015 -                     (bdinfo_addr +
37016 -                      TG3_BDINFO_NIC_ADDR),
37017 -                     nic_addr);
37018 +
37019 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705)
37020 +               tg3_write_mem(tp,
37021 +                             (bdinfo_addr + TG3_BDINFO_NIC_ADDR),
37022 +                             nic_addr);
37023  }
37024  
37025  static void __tg3_set_rx_mode(struct net_device *);
37026 @@ -3917,8 +4526,8 @@
37027  /* tp->lock is held. */
37028  static int tg3_reset_hw(struct tg3 *tp)
37029  {
37030 -       u32 val;
37031 -       int i, err;
37032 +       u32 val, rdmac_mode;
37033 +       int i, err, limit;
37034  
37035         tg3_disable_ints(tp);
37036  
37037 @@ -3970,9 +4579,8 @@
37038          * B3 tigon3 silicon.  This bit has no effect on any
37039          * other revision.
37040          */
37041 -       val = tr32(TG3PCI_CLOCK_CTRL);
37042 -       val |= CLOCK_CTRL_DELAY_PCI_GRANT;
37043 -       tw32(TG3PCI_CLOCK_CTRL, val);
37044 +       tp->pci_clock_ctrl |= CLOCK_CTRL_DELAY_PCI_GRANT;
37045 +       tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl);
37046         tr32(TG3PCI_CLOCK_CTRL);
37047  
37048         if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0 &&
37049 @@ -3990,11 +4598,13 @@
37050         tg3_init_rings(tp);
37051  
37052         /* Clear statistics/status block in chip, and status block in ram. */
37053 -       for (i = NIC_SRAM_STATS_BLK;
37054 -            i < NIC_SRAM_STATUS_BLK + TG3_HW_STATUS_SIZE;
37055 -            i += sizeof(u32)) {
37056 -               tg3_write_mem(tp, i, 0);
37057 -               udelay(40);
37058 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
37059 +               for (i = NIC_SRAM_STATS_BLK;
37060 +                    i < NIC_SRAM_STATUS_BLK + TG3_HW_STATUS_SIZE;
37061 +                    i += sizeof(u32)) {
37062 +                       tg3_write_mem(tp, i, 0);
37063 +                       udelay(40);
37064 +               }
37065         }
37066         memset(tp->hw_status, 0, TG3_HW_STATUS_SIZE);
37067  
37068 @@ -4025,13 +4635,31 @@
37069              (65 << GRC_MISC_CFG_PRESCALAR_SHIFT));
37070  
37071         /* Initialize MBUF/DESC pool. */
37072 -       tw32(BUFMGR_MB_POOL_ADDR, NIC_SRAM_MBUF_POOL_BASE);
37073 -       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
37074 -               tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE64);
37075 -       else
37076 -               tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE96);
37077 -       tw32(BUFMGR_DMA_DESC_POOL_ADDR, NIC_SRAM_DMA_DESC_POOL_BASE);
37078 -       tw32(BUFMGR_DMA_DESC_POOL_SIZE, NIC_SRAM_DMA_DESC_POOL_SIZE);
37079 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
37080 +               tw32(BUFMGR_MB_POOL_ADDR, NIC_SRAM_MBUF_POOL_BASE);
37081 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
37082 +                       tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE64);
37083 +               else
37084 +                       tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE96);
37085 +               tw32(BUFMGR_DMA_DESC_POOL_ADDR, NIC_SRAM_DMA_DESC_POOL_BASE);
37086 +               tw32(BUFMGR_DMA_DESC_POOL_SIZE, NIC_SRAM_DMA_DESC_POOL_SIZE);
37087 +       }
37088 +#if TG3_TSO_SUPPORT != 0
37089 +       else if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) {
37090 +               int fw_len;
37091 +
37092 +               fw_len = (TG3_TSO5_FW_TEXT_LEN +
37093 +                         TG3_TSO5_FW_RODATA_LEN +
37094 +                         TG3_TSO5_FW_DATA_LEN +
37095 +                         TG3_TSO5_FW_SBSS_LEN +
37096 +                         TG3_TSO5_FW_BSS_LEN);
37097 +               fw_len = (fw_len + (0x80 - 1)) & ~(0x80 - 1);
37098 +               tw32(BUFMGR_MB_POOL_ADDR,
37099 +                    NIC_SRAM_MBUF_POOL_BASE5705 + fw_len);
37100 +               tw32(BUFMGR_MB_POOL_SIZE,
37101 +                    NIC_SRAM_MBUF_POOL_SIZE5705 - fw_len - 0xa00);
37102 +       }
37103 +#endif
37104  
37105         if (!(tp->tg3_flags & TG3_FLAG_JUMBO_ENABLE)) {
37106                 tw32(BUFMGR_MB_RDMA_LOW_WATER,
37107 @@ -4078,6 +4706,9 @@
37108                 return -ENODEV;
37109         }
37110  
37111 +       /* Setup replenish threshold. */
37112 +       tw32(RCVBDI_STD_THRESH, tp->rx_pending / 8);
37113 +
37114         /* Initialize TG3_BDINFO's at:
37115          *  RCVDBDI_STD_BD:     standard eth size rx ring
37116          *  RCVDBDI_JUMBO_BD:   jumbo frame rx ring
37117 @@ -4099,35 +4730,50 @@
37118              ((u64) tp->rx_std_mapping >> 32));
37119         tw32(RCVDBDI_STD_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW,
37120              ((u64) tp->rx_std_mapping & 0xffffffff));
37121 -       tw32(RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS,
37122 -            RX_STD_MAX_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT);
37123         tw32(RCVDBDI_STD_BD + TG3_BDINFO_NIC_ADDR,
37124              NIC_SRAM_RX_BUFFER_DESC);
37125  
37126 -       tw32(RCVDBDI_MINI_BD + TG3_BDINFO_MAXLEN_FLAGS,
37127 -            BDINFO_FLAGS_DISABLED);
37128 -
37129 -       if (tp->tg3_flags & TG3_FLAG_JUMBO_ENABLE) {
37130 -               tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_HIGH,
37131 -                    ((u64) tp->rx_jumbo_mapping >> 32));
37132 -               tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW,
37133 -                    ((u64) tp->rx_jumbo_mapping & 0xffffffff));
37134 -               tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_MAXLEN_FLAGS,
37135 -                    RX_JUMBO_MAX_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT);
37136 -               tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_NIC_ADDR,
37137 -                    NIC_SRAM_RX_JUMBO_BUFFER_DESC);
37138 +       /* Don't even try to program the JUMBO/MINI buffer descriptor
37139 +        * configs on 5705.
37140 +        */
37141 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
37142 +               tw32(RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS,
37143 +                    RX_STD_MAX_SIZE_5705 << BDINFO_FLAGS_MAXLEN_SHIFT);
37144         } else {
37145 -               tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_MAXLEN_FLAGS,
37146 +               tw32(RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS,
37147 +                    RX_STD_MAX_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT);
37148 +
37149 +               tw32(RCVDBDI_MINI_BD + TG3_BDINFO_MAXLEN_FLAGS,
37150                      BDINFO_FLAGS_DISABLED);
37151 -       }
37152  
37153 -       /* Setup replenish thresholds. */
37154 -       tw32(RCVBDI_STD_THRESH, tp->rx_pending / 8);
37155 -       tw32(RCVBDI_JUMBO_THRESH, tp->rx_jumbo_pending / 8);
37156 +               /* Setup replenish threshold. */
37157 +               tw32(RCVBDI_JUMBO_THRESH, tp->rx_jumbo_pending / 8);
37158  
37159 -       /* Clear out send RCB ring in SRAM. */
37160 -       for (i = NIC_SRAM_SEND_RCB; i < NIC_SRAM_RCV_RET_RCB; i += TG3_BDINFO_SIZE)
37161 -               tg3_write_mem(tp, i + TG3_BDINFO_MAXLEN_FLAGS, BDINFO_FLAGS_DISABLED);
37162 +               if (tp->tg3_flags & TG3_FLAG_JUMBO_ENABLE) {
37163 +                       tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_HIGH,
37164 +                            ((u64) tp->rx_jumbo_mapping >> 32));
37165 +                       tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW,
37166 +                            ((u64) tp->rx_jumbo_mapping & 0xffffffff));
37167 +                       tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_MAXLEN_FLAGS,
37168 +                            RX_JUMBO_MAX_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT);
37169 +                       tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_NIC_ADDR,
37170 +                            NIC_SRAM_RX_JUMBO_BUFFER_DESC);
37171 +               } else {
37172 +                       tw32(RCVDBDI_JUMBO_BD + TG3_BDINFO_MAXLEN_FLAGS,
37173 +                            BDINFO_FLAGS_DISABLED);
37174 +               }
37175 +
37176 +       }
37177 +
37178 +       /* There is only one send ring on 5705, no need to explicitly
37179 +        * disable the others.
37180 +        */
37181 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
37182 +               /* Clear out send RCB ring in SRAM. */
37183 +               for (i = NIC_SRAM_SEND_RCB; i < NIC_SRAM_RCV_RET_RCB; i += TG3_BDINFO_SIZE)
37184 +                       tg3_write_mem(tp, i + TG3_BDINFO_MAXLEN_FLAGS,
37185 +                                     BDINFO_FLAGS_DISABLED);
37186 +       }
37187  
37188         tp->tx_prod = 0;
37189         tp->tx_cons = 0;
37190 @@ -4149,9 +4795,15 @@
37191                                NIC_SRAM_TX_BUFFER_DESC);
37192         }
37193  
37194 -       for (i = NIC_SRAM_RCV_RET_RCB; i < NIC_SRAM_STATS_BLK; i += TG3_BDINFO_SIZE) {
37195 -               tg3_write_mem(tp, i + TG3_BDINFO_MAXLEN_FLAGS,
37196 -                             BDINFO_FLAGS_DISABLED);
37197 +       /* There is only one receive return ring on 5705, no need to explicitly
37198 +        * disable the others.
37199 +        */
37200 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
37201 +               for (i = NIC_SRAM_RCV_RET_RCB; i < NIC_SRAM_STATS_BLK;
37202 +                    i += TG3_BDINFO_SIZE) {
37203 +                       tg3_write_mem(tp, i + TG3_BDINFO_MAXLEN_FLAGS,
37204 +                                     BDINFO_FLAGS_DISABLED);
37205 +               }
37206         }
37207  
37208         tp->rx_rcb_ptr = 0;
37209 @@ -4161,7 +4813,7 @@
37210  
37211         tg3_set_bdinfo(tp, NIC_SRAM_RCV_RET_RCB,
37212                        tp->rx_rcb_mapping,
37213 -                      (TG3_RX_RCB_RING_SIZE <<
37214 +                      (TG3_RX_RCB_RING_SIZE(tp) <<
37215                         BDINFO_FLAGS_MAXLEN_SHIFT),
37216                        0);
37217  
37218 @@ -4198,8 +4850,36 @@
37219         tw32(MAC_RCV_RULE_CFG, RCV_RULE_CFG_DEFAULT_CLASS);
37220         tw32(RCVLPC_CONFIG, 0x0181);
37221  
37222 +       /* Calculate RDMAC_MODE setting early, we need it to determine
37223 +        * the RCVLPC_STATE_ENABLE mask.
37224 +        */
37225 +       rdmac_mode = (RDMAC_MODE_ENABLE | RDMAC_MODE_TGTABORT_ENAB |
37226 +                     RDMAC_MODE_MSTABORT_ENAB | RDMAC_MODE_PARITYERR_ENAB |
37227 +                     RDMAC_MODE_ADDROFLOW_ENAB | RDMAC_MODE_FIFOOFLOW_ENAB |
37228 +                     RDMAC_MODE_FIFOURUN_ENAB | RDMAC_MODE_FIFOOREAD_ENAB |
37229 +                     RDMAC_MODE_LNGREAD_ENAB);
37230 +       if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
37231 +               rdmac_mode |= RDMAC_MODE_SPLIT_ENABLE;
37232 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
37233 +               if (tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) {
37234 +                       if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) {
37235 +                               rdmac_mode |= RDMAC_MODE_FIFO_SIZE_128;
37236 +                       } else if (!(tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH) &&
37237 +                                  !(tp->tg3_flags2 & TG3_FLG2_IS_5788)) {
37238 +                               rdmac_mode |= RDMAC_MODE_FIFO_LONG_BURST;
37239 +                       }
37240 +               }
37241 +       }
37242 +
37243         /* Receive/send statistics. */
37244 -       tw32(RCVLPC_STATS_ENABLE, 0xffffff);
37245 +       if ((rdmac_mode & RDMAC_MODE_FIFO_SIZE_128) &&
37246 +           (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE)) {
37247 +               val = tr32(RCVLPC_STATS_ENABLE);
37248 +               val &= ~RCVLPC_STATSENAB_LNGBRST_RFIX;
37249 +               tw32(RCVLPC_STATS_ENABLE, val);
37250 +       } else {
37251 +               tw32(RCVLPC_STATS_ENABLE, 0xffffff);
37252 +       }
37253         tw32(RCVLPC_STATSCTRL, RCVLPC_STATSCTRL_ENABLE);
37254         tw32(SNDDATAI_STATSENAB, 0xffffff);
37255         tw32(SNDDATAI_STATSCTRL,
37256 @@ -4215,33 +4895,43 @@
37257         }
37258  
37259         tw32(HOSTCC_RXCOL_TICKS, 0);
37260 -       tw32(HOSTCC_RXMAX_FRAMES, 1);
37261 -       tw32(HOSTCC_RXCOAL_TICK_INT, 0);
37262 -       tw32(HOSTCC_RXCOAL_MAXF_INT, 1);
37263         tw32(HOSTCC_TXCOL_TICKS, LOW_TXCOL_TICKS);
37264 +       tw32(HOSTCC_RXMAX_FRAMES, 1);
37265         tw32(HOSTCC_TXMAX_FRAMES, LOW_RXMAX_FRAMES);
37266 -       tw32(HOSTCC_TXCOAL_TICK_INT, 0);
37267 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705)
37268 +               tw32(HOSTCC_RXCOAL_TICK_INT, 0);
37269 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705)
37270 +               tw32(HOSTCC_TXCOAL_TICK_INT, 0);
37271 +       tw32(HOSTCC_RXCOAL_MAXF_INT, 1);
37272         tw32(HOSTCC_TXCOAL_MAXF_INT, 0);
37273 -       tw32(HOSTCC_STAT_COAL_TICKS,
37274 -            DEFAULT_STAT_COAL_TICKS);
37275  
37276 -       /* Status/statistics block address. */
37277 -       tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH,
37278 -            ((u64) tp->stats_mapping >> 32));
37279 -       tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,
37280 -            ((u64) tp->stats_mapping & 0xffffffff));
37281 +       /* set status block DMA address */
37282         tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH,
37283              ((u64) tp->status_mapping >> 32));
37284         tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,
37285              ((u64) tp->status_mapping & 0xffffffff));
37286 -       tw32(HOSTCC_STATS_BLK_NIC_ADDR, NIC_SRAM_STATS_BLK);
37287 -       tw32(HOSTCC_STATUS_BLK_NIC_ADDR, NIC_SRAM_STATUS_BLK);
37288 +
37289 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
37290 +               /* Status/statistics block address.  See tg3_timer,
37291 +                * the tg3_periodic_fetch_stats call there, and
37292 +                * tg3_get_stats to see how this works for 5705 chips.
37293 +                */
37294 +               tw32(HOSTCC_STAT_COAL_TICKS,
37295 +                    DEFAULT_STAT_COAL_TICKS);
37296 +               tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH,
37297 +                    ((u64) tp->stats_mapping >> 32));
37298 +               tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,
37299 +                    ((u64) tp->stats_mapping & 0xffffffff));
37300 +               tw32(HOSTCC_STATS_BLK_NIC_ADDR, NIC_SRAM_STATS_BLK);
37301 +               tw32(HOSTCC_STATUS_BLK_NIC_ADDR, NIC_SRAM_STATUS_BLK);
37302 +       }
37303  
37304         tw32(HOSTCC_MODE, HOSTCC_MODE_ENABLE | tp->coalesce_mode);
37305  
37306         tw32(RCVCC_MODE, RCVCC_MODE_ENABLE | RCVCC_MODE_ATTN_ENABLE);
37307         tw32(RCVLPC_MODE, RCVLPC_MODE_ENABLE);
37308 -       tw32(RCVLSC_MODE, RCVLSC_MODE_ENABLE | RCVLSC_MODE_ATTN_ENABLE);
37309 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705)
37310 +               tw32(RCVLSC_MODE, RCVLSC_MODE_ENABLE | RCVLSC_MODE_ATTN_ENABLE);
37311  
37312         tp->mac_mode = MAC_MODE_TXSTAT_ENABLE | MAC_MODE_RXSTAT_ENABLE |
37313                 MAC_MODE_TDE_ENABLE | MAC_MODE_RDE_ENABLE | MAC_MODE_FHDE_ENABLE;
37314 @@ -4260,42 +4950,47 @@
37315         tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0);
37316         tr32(MAILBOX_INTERRUPT_0);
37317  
37318 -       tw32(DMAC_MODE, DMAC_MODE_ENABLE);
37319 -       tr32(DMAC_MODE);
37320 -       udelay(40);
37321 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
37322 +               tw32(DMAC_MODE, DMAC_MODE_ENABLE);
37323 +               tr32(DMAC_MODE);
37324 +               udelay(40);
37325 +       }
37326  
37327 -       tw32(WDMAC_MODE, (WDMAC_MODE_ENABLE | WDMAC_MODE_TGTABORT_ENAB |
37328 -                         WDMAC_MODE_MSTABORT_ENAB | WDMAC_MODE_PARITYERR_ENAB |
37329 -                         WDMAC_MODE_ADDROFLOW_ENAB | WDMAC_MODE_FIFOOFLOW_ENAB |
37330 -                         WDMAC_MODE_FIFOURUN_ENAB | WDMAC_MODE_FIFOOREAD_ENAB |
37331 -                         WDMAC_MODE_LNGREAD_ENAB));
37332 +       val = (WDMAC_MODE_ENABLE | WDMAC_MODE_TGTABORT_ENAB |
37333 +              WDMAC_MODE_MSTABORT_ENAB | WDMAC_MODE_PARITYERR_ENAB |
37334 +              WDMAC_MODE_ADDROFLOW_ENAB | WDMAC_MODE_FIFOOFLOW_ENAB |
37335 +              WDMAC_MODE_FIFOURUN_ENAB | WDMAC_MODE_FIFOOREAD_ENAB |
37336 +              WDMAC_MODE_LNGREAD_ENAB);
37337 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
37338 +           (tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH) != 0 &&
37339 +           !(tp->tg3_flags2 & TG3_FLG2_IS_5788))
37340 +               val |= WDMAC_MODE_RX_ACCEL;
37341 +       tw32(WDMAC_MODE, val);
37342         tr32(WDMAC_MODE);
37343         udelay(40);
37344  
37345 -       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 &&
37346 -           (tp->tg3_flags & TG3_FLAG_PCIX_MODE)) {
37347 +       if ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0) {
37348                 val = tr32(TG3PCI_X_CAPS);
37349 -               val &= ~(PCIX_CAPS_SPLIT_MASK | PCIX_CAPS_BURST_MASK);
37350 -               val |= (PCIX_CAPS_MAX_BURST_5704 << PCIX_CAPS_BURST_SHIFT);
37351 -               if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
37352 -                       val |= (tp->split_mode_max_reqs <<
37353 -                               PCIX_CAPS_SPLIT_SHIFT);
37354 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) {
37355 +                       val &= ~PCIX_CAPS_BURST_MASK;
37356 +                       val |= (PCIX_CAPS_MAX_BURST_CPIOB << PCIX_CAPS_BURST_SHIFT);
37357 +               } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
37358 +                       val &= ~(PCIX_CAPS_SPLIT_MASK | PCIX_CAPS_BURST_MASK);
37359 +                       val |= (PCIX_CAPS_MAX_BURST_CPIOB << PCIX_CAPS_BURST_SHIFT);
37360 +                       if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
37361 +                               val |= (tp->split_mode_max_reqs <<
37362 +                                       PCIX_CAPS_SPLIT_SHIFT);
37363 +               }
37364                 tw32(TG3PCI_X_CAPS, val);
37365         }
37366  
37367 -       val = (RDMAC_MODE_ENABLE | RDMAC_MODE_TGTABORT_ENAB |
37368 -              RDMAC_MODE_MSTABORT_ENAB | RDMAC_MODE_PARITYERR_ENAB |
37369 -              RDMAC_MODE_ADDROFLOW_ENAB | RDMAC_MODE_FIFOOFLOW_ENAB |
37370 -              RDMAC_MODE_FIFOURUN_ENAB | RDMAC_MODE_FIFOOREAD_ENAB |
37371 -              RDMAC_MODE_LNGREAD_ENAB);
37372 -       if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
37373 -               val |= RDMAC_MODE_SPLIT_ENABLE;
37374 -       tw32(RDMAC_MODE, val);
37375 +       tw32(RDMAC_MODE, rdmac_mode);
37376         tr32(RDMAC_MODE);
37377         udelay(40);
37378  
37379         tw32(RCVDCC_MODE, RCVDCC_MODE_ENABLE | RCVDCC_MODE_ATTN_ENABLE);
37380 -       tw32(MBFREE_MODE, MBFREE_MODE_ENABLE);
37381 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705)
37382 +               tw32(MBFREE_MODE, MBFREE_MODE_ENABLE);
37383         tw32(SNDDATAC_MODE, SNDDATAC_MODE_ENABLE);
37384         tw32(SNDBDC_MODE, SNDBDC_MODE_ENABLE | SNDBDC_MODE_ATTN_ENABLE);
37385         tw32(RCVBDI_MODE, RCVBDI_MODE_ENABLE | RCVBDI_MODE_RCB_ATTN_ENAB);
37386 @@ -4310,8 +5005,8 @@
37387                         return err;
37388         }
37389  
37390 -#if TG3_DO_TSO != 0
37391 -       if (tp->dev->features & NETIF_F_TSO) {
37392 +#if TG3_TSO_SUPPORT != 0
37393 +       if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) {
37394                 err = tg3_load_tso_firmware(tp);
37395                 if (err)
37396                         return err;
37397 @@ -4342,9 +5037,11 @@
37398  
37399         tw32(MAC_LED_CTRL, 0);
37400         tw32(MAC_MI_STAT, MAC_MI_STAT_LNKSTAT_ATTN_ENAB);
37401 -       tw32(MAC_RX_MODE, RX_MODE_RESET);
37402 -       tr32(MAC_RX_MODE);
37403 -       udelay(10);
37404 +       if (tp->phy_id == PHY_ID_SERDES) {
37405 +               tw32(MAC_RX_MODE, RX_MODE_RESET);
37406 +               tr32(MAC_RX_MODE);
37407 +               udelay(10);
37408 +       }
37409         tw32(MAC_RX_MODE, tp->rx_mode);
37410         tr32(MAC_RX_MODE);
37411         udelay(10);
37412 @@ -4378,22 +5075,48 @@
37413         tw32(MAC_RCV_VALUE_0, 0xffffffff & RCV_RULE_DISABLE_MASK);
37414         tw32(MAC_RCV_RULE_1,  0x86000004 & RCV_RULE_DISABLE_MASK);
37415         tw32(MAC_RCV_VALUE_1, 0xffffffff & RCV_RULE_DISABLE_MASK);
37416 -#if 0
37417 -       tw32(MAC_RCV_RULE_2,  0); tw32(MAC_RCV_VALUE_2,  0);
37418 -       tw32(MAC_RCV_RULE_3,  0); tw32(MAC_RCV_VALUE_3,  0);
37419 -#endif
37420 -       tw32(MAC_RCV_RULE_4,  0); tw32(MAC_RCV_VALUE_4,  0);
37421 -       tw32(MAC_RCV_RULE_5,  0); tw32(MAC_RCV_VALUE_5,  0);
37422 -       tw32(MAC_RCV_RULE_6,  0); tw32(MAC_RCV_VALUE_6,  0);
37423 -       tw32(MAC_RCV_RULE_7,  0); tw32(MAC_RCV_VALUE_7,  0);
37424 -       tw32(MAC_RCV_RULE_8,  0); tw32(MAC_RCV_VALUE_8,  0);
37425 -       tw32(MAC_RCV_RULE_9,  0); tw32(MAC_RCV_VALUE_9,  0);
37426 -       tw32(MAC_RCV_RULE_10,  0); tw32(MAC_RCV_VALUE_10,  0);
37427 -       tw32(MAC_RCV_RULE_11,  0); tw32(MAC_RCV_VALUE_11,  0);
37428 -       tw32(MAC_RCV_RULE_12,  0); tw32(MAC_RCV_VALUE_12,  0);
37429 -       tw32(MAC_RCV_RULE_13,  0); tw32(MAC_RCV_VALUE_13,  0);
37430 -       tw32(MAC_RCV_RULE_14,  0); tw32(MAC_RCV_VALUE_14,  0);
37431 -       tw32(MAC_RCV_RULE_15,  0); tw32(MAC_RCV_VALUE_15,  0);
37432 +
37433 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
37434 +               limit = 8;
37435 +       else
37436 +               limit = 16;
37437 +       if (tp->tg3_flags & TG3_FLAG_ENABLE_ASF)
37438 +               limit -= 4;
37439 +       switch (limit) {
37440 +       case 16:
37441 +               tw32(MAC_RCV_RULE_15,  0); tw32(MAC_RCV_VALUE_15,  0);
37442 +       case 15:
37443 +               tw32(MAC_RCV_RULE_14,  0); tw32(MAC_RCV_VALUE_14,  0);
37444 +       case 14:
37445 +               tw32(MAC_RCV_RULE_13,  0); tw32(MAC_RCV_VALUE_13,  0);
37446 +       case 13:
37447 +               tw32(MAC_RCV_RULE_12,  0); tw32(MAC_RCV_VALUE_12,  0);
37448 +       case 12:
37449 +               tw32(MAC_RCV_RULE_11,  0); tw32(MAC_RCV_VALUE_11,  0);
37450 +       case 11:
37451 +               tw32(MAC_RCV_RULE_10,  0); tw32(MAC_RCV_VALUE_10,  0);
37452 +       case 10:
37453 +               tw32(MAC_RCV_RULE_9,  0); tw32(MAC_RCV_VALUE_9,  0);
37454 +       case 9:
37455 +               tw32(MAC_RCV_RULE_8,  0); tw32(MAC_RCV_VALUE_8,  0);
37456 +       case 8:
37457 +               tw32(MAC_RCV_RULE_7,  0); tw32(MAC_RCV_VALUE_7,  0);
37458 +       case 7:
37459 +               tw32(MAC_RCV_RULE_6,  0); tw32(MAC_RCV_VALUE_6,  0);
37460 +       case 6:
37461 +               tw32(MAC_RCV_RULE_5,  0); tw32(MAC_RCV_VALUE_5,  0);
37462 +       case 5:
37463 +               tw32(MAC_RCV_RULE_4,  0); tw32(MAC_RCV_VALUE_4,  0);
37464 +       case 4:
37465 +               /* tw32(MAC_RCV_RULE_3,  0); tw32(MAC_RCV_VALUE_3,  0); */
37466 +       case 3:
37467 +               /* tw32(MAC_RCV_RULE_2,  0); tw32(MAC_RCV_VALUE_2,  0); */
37468 +       case 2:
37469 +       case 1:
37470 +
37471 +       default:
37472 +               break;
37473 +       };
37474  
37475         if (tp->tg3_flags & TG3_FLAG_INIT_COMPLETE)
37476                 tg3_enable_ints(tp);
37477 @@ -4423,6 +5146,50 @@
37478         return err;
37479  }
37480  
37481 +#define TG3_STAT_ADD32(PSTAT, REG) \
37482 +do {   u32 __val = tr32(REG); \
37483 +       (PSTAT)->low += __val; \
37484 +       if ((PSTAT)->low < __val) \
37485 +               (PSTAT)->high += 1; \
37486 +} while (0)
37487 +
37488 +static void tg3_periodic_fetch_stats(struct tg3 *tp)
37489 +{
37490 +       struct tg3_hw_stats *sp = tp->hw_stats;
37491 +
37492 +       if (!netif_carrier_ok(tp->dev))
37493 +               return;
37494 +
37495 +       TG3_STAT_ADD32(&sp->tx_octets, MAC_TX_STATS_OCTETS);
37496 +       TG3_STAT_ADD32(&sp->tx_collisions, MAC_TX_STATS_COLLISIONS);
37497 +       TG3_STAT_ADD32(&sp->tx_xon_sent, MAC_TX_STATS_XON_SENT);
37498 +       TG3_STAT_ADD32(&sp->tx_xoff_sent, MAC_TX_STATS_XOFF_SENT);
37499 +       TG3_STAT_ADD32(&sp->tx_mac_errors, MAC_TX_STATS_MAC_ERRORS);
37500 +       TG3_STAT_ADD32(&sp->tx_single_collisions, MAC_TX_STATS_SINGLE_COLLISIONS);
37501 +       TG3_STAT_ADD32(&sp->tx_mult_collisions, MAC_TX_STATS_MULT_COLLISIONS);
37502 +       TG3_STAT_ADD32(&sp->tx_deferred, MAC_TX_STATS_DEFERRED);
37503 +       TG3_STAT_ADD32(&sp->tx_excessive_collisions, MAC_TX_STATS_EXCESSIVE_COL);
37504 +       TG3_STAT_ADD32(&sp->tx_late_collisions, MAC_TX_STATS_LATE_COL);
37505 +       TG3_STAT_ADD32(&sp->tx_ucast_packets, MAC_TX_STATS_UCAST);
37506 +       TG3_STAT_ADD32(&sp->tx_mcast_packets, MAC_TX_STATS_MCAST);
37507 +       TG3_STAT_ADD32(&sp->tx_bcast_packets, MAC_TX_STATS_BCAST);
37508 +
37509 +       TG3_STAT_ADD32(&sp->rx_octets, MAC_RX_STATS_OCTETS);
37510 +       TG3_STAT_ADD32(&sp->rx_fragments, MAC_RX_STATS_FRAGMENTS);
37511 +       TG3_STAT_ADD32(&sp->rx_ucast_packets, MAC_RX_STATS_UCAST);
37512 +       TG3_STAT_ADD32(&sp->rx_mcast_packets, MAC_RX_STATS_MCAST);
37513 +       TG3_STAT_ADD32(&sp->rx_bcast_packets, MAC_RX_STATS_BCAST);
37514 +       TG3_STAT_ADD32(&sp->rx_fcs_errors, MAC_RX_STATS_FCS_ERRORS);
37515 +       TG3_STAT_ADD32(&sp->rx_align_errors, MAC_RX_STATS_ALIGN_ERRORS);
37516 +       TG3_STAT_ADD32(&sp->rx_xon_pause_rcvd, MAC_RX_STATS_XON_PAUSE_RECVD);
37517 +       TG3_STAT_ADD32(&sp->rx_xoff_pause_rcvd, MAC_RX_STATS_XOFF_PAUSE_RECVD);
37518 +       TG3_STAT_ADD32(&sp->rx_mac_ctrl_rcvd, MAC_RX_STATS_MAC_CTRL_RECVD);
37519 +       TG3_STAT_ADD32(&sp->rx_xoff_entered, MAC_RX_STATS_XOFF_ENTERED);
37520 +       TG3_STAT_ADD32(&sp->rx_frame_too_long_errors, MAC_RX_STATS_FRAME_TOO_LONG);
37521 +       TG3_STAT_ADD32(&sp->rx_jabbers, MAC_RX_STATS_JABBERS);
37522 +       TG3_STAT_ADD32(&sp->rx_undersize_packets, MAC_RX_STATS_UNDERSIZE);
37523 +}
37524 +
37525  static void tg3_timer(unsigned long __opaque)
37526  {
37527         struct tg3 *tp = (struct tg3 *) __opaque;
37528 @@ -4451,6 +5218,9 @@
37529                 return;
37530         }
37531  
37532 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
37533 +               tg3_periodic_fetch_stats(tp);
37534 +
37535         /* This part only runs once per second. */
37536         if (!--tp->timer_counter) {
37537                 if (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) {
37538 @@ -4908,7 +5678,9 @@
37539                 get_stat64(&hw_stats->rx_bcast_packets);
37540                 
37541         stats->tx_packets = old_stats->tx_packets +
37542 -               get_stat64(&hw_stats->COS_out_packets[0]);
37543 +               get_stat64(&hw_stats->tx_ucast_packets) +
37544 +               get_stat64(&hw_stats->tx_mcast_packets) +
37545 +               get_stat64(&hw_stats->tx_bcast_packets);
37546  
37547         stats->rx_bytes = old_stats->rx_bytes +
37548                 get_stat64(&hw_stats->rx_octets);
37549 @@ -5232,6 +6004,20 @@
37550         tp->msg_enable = value;
37551  }
37552    
37553 +#if TG3_TSO_SUPPORT != 0
37554 +static int tg3_set_tso(struct net_device *dev, u32 value)
37555 +{
37556 +       struct tg3 *tp = dev->priv;
37557 +
37558 +       if (!(tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE)) {
37559 +               if (value)
37560 +                       return -EINVAL;
37561 +               return 0;
37562 +       }
37563 +       return ethtool_op_set_tso(dev, value);
37564 +}
37565 +#endif
37566 +  
37567  static int tg3_nway_reset(struct net_device *dev)
37568  {
37569         struct tg3 *tp = dev->priv;
37570 @@ -5279,11 +6065,14 @@
37571         spin_lock(&tp->tx_lock);
37572    
37573         tp->rx_pending = ering->rx_pending;
37574 +
37575 +       if ((tp->tg3_flags2 & TG3_FLG2_MAX_RXPEND_64) &&
37576 +           tp->rx_pending > 64)
37577 +               tp->rx_pending = 64;
37578         tp->rx_jumbo_pending = ering->rx_jumbo_pending;
37579         tp->tx_pending = ering->tx_pending;
37580  
37581         tg3_halt(tp);
37582 -       tg3_init_rings(tp);
37583         tg3_init_hw(tp);
37584         netif_wake_queue(tp->dev);
37585         spin_unlock(&tp->tx_lock);
37586 @@ -5322,7 +6111,6 @@
37587         else
37588                 tp->tg3_flags &= ~TG3_FLAG_PAUSE_TX;
37589         tg3_halt(tp);
37590 -       tg3_init_rings(tp);
37591         tg3_init_hw(tp);
37592         spin_unlock(&tp->tx_lock);
37593         spin_unlock_irq(&tp->lock);
37594 @@ -5467,6 +6255,10 @@
37595         .set_tx_csum            = tg3_set_tx_csum,
37596         .get_sg                 = ethtool_op_get_sg,
37597         .set_sg                 = ethtool_op_set_sg,
37598 +#if TG3_TSO_SUPPORT != 0
37599 +       .get_tso                = ethtool_op_get_tso,
37600 +       .set_tso                = tg3_set_tso,
37601 +#endif
37602  };
37603  
37604  /* Chips other than 5700/5701 use the NVRAM for fetching info. */
37605 @@ -5669,6 +6461,7 @@
37606                 u32 nic_cfg;
37607  
37608                 tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg);
37609 +               tp->nic_sram_data_cfg = nic_cfg;
37610  
37611                 eeprom_signature_found = 1;
37612  
37613 @@ -5702,8 +6495,10 @@
37614                         eeprom_led_mode = led_mode_auto;
37615                         break;
37616                 };
37617 -               if ((tp->pci_chip_rev_id == CHIPREV_ID_5703_A1 ||
37618 -                    tp->pci_chip_rev_id == CHIPREV_ID_5703_A2) &&
37619 +
37620 +               if (((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) ||
37621 +                    (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
37622 +                    (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)) &&
37623                     (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP))
37624                         tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
37625  
37626 @@ -5785,9 +6580,7 @@
37627         }
37628  
37629         /* Enable Ethernet@WireSpeed */
37630 -       tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x7007);
37631 -       tg3_readphy(tp, MII_TG3_AUX_CTRL, &val);
37632 -       tg3_writephy(tp, MII_TG3_AUX_CTRL, (val | (1 << 15) | (1 << 4)));
37633 +       tg3_phy_set_wirespeed(tp);
37634  
37635         if (!err && ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401)) {
37636                 err = tg3_init_5401phy_dsp(tp);
37637 @@ -5927,7 +6720,7 @@
37638                 tp->tg3_flags2 |= TG3_FLG2_SUN_5704;
37639  #endif
37640  
37641 -       /* If we have an AMD 762 or Intel ICH/ICH0 chipset, write
37642 +       /* If we have an AMD 762 or Intel ICH/ICH0/ICH2 chipset, write
37643          * reordering to the mailbox registers done by the host
37644          * controller can cause major troubles.  We read back from
37645          * every mailbox register write to force the writes to be
37646 @@ -5937,6 +6730,10 @@
37647                             PCI_DEVICE_ID_INTEL_82801AA_8, NULL) ||
37648             pci_find_device(PCI_VENDOR_ID_INTEL,
37649                             PCI_DEVICE_ID_INTEL_82801AB_8, NULL) ||
37650 +           pci_find_device(PCI_VENDOR_ID_INTEL,
37651 +                           PCI_DEVICE_ID_INTEL_82801BA_11, NULL) ||
37652 +           pci_find_device(PCI_VENDOR_ID_INTEL,
37653 +                           PCI_DEVICE_ID_INTEL_82801BA_6, NULL) ||
37654             pci_find_device(PCI_VENDOR_ID_AMD,
37655                             PCI_DEVICE_ID_AMD_FE_GATE_700C, NULL))
37656                 tp->tg3_flags |= TG3_FLAG_MBOX_WRITE_REORDER;
37657 @@ -6085,7 +6882,15 @@
37658                 tp->tg3_flags |= TG3_FLAG_WOL_SPEED_100MB;
37659         }
37660  
37661 +       /* A few boards don't want Ethernet@WireSpeed phy feature */
37662 +       if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700) ||
37663 +           ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) &&
37664 +            (tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) &&
37665 +            (tp->pci_chip_rev_id != CHIPREV_ID_5705_A1)))
37666 +               tp->tg3_flags2 |= TG3_FLG2_NO_ETH_WIRE_SPEED;
37667 +
37668         /* Only 5701 and later support tagged irq status mode.
37669 +        * Also, 5788 chips cannot use tagged irq status.
37670          *
37671          * However, since we are using NAPI avoid tagged irq status
37672          * because the interrupt condition is more difficult to
37673 @@ -6142,7 +6947,8 @@
37674         /* Determine if TX descriptors will reside in
37675          * main memory or in the chip SRAM.
37676          */
37677 -       if (tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG)
37678 +       if ((tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) != 0 ||
37679 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
37680                 tp->tg3_flags |= TG3_FLAG_HOST_TXDS;
37681  
37682         grc_misc_cfg = tr32(GRC_MISC_CFG);
37683 @@ -6154,8 +6960,18 @@
37684                 tp->split_mode_max_reqs = SPLIT_MODE_5704_MAX_REQ;
37685         }
37686  
37687 -       /* this one is limited to 10/100 only */
37688 -       if (grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5702FE)
37689 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
37690 +           (grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788 ||
37691 +            grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788M))
37692 +               tp->tg3_flags2 |= TG3_FLG2_IS_5788;
37693 +
37694 +       /* these are limited to 10/100 only */
37695 +       if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 &&
37696 +            (grc_misc_cfg == 0x8000 || grc_misc_cfg == 0x4000)) ||
37697 +           (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
37698 +            tp->pdev->vendor == PCI_VENDOR_ID_BROADCOM &&
37699 +            (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5901 ||
37700 +             tp->pdev->device == PCI_DEVICE_ID_TIGON3_5901_2)))
37701                 tp->tg3_flags |= TG3_FLAG_10_100_ONLY;
37702  
37703         err = tg3_phy_probe(tp);
37704 @@ -6414,8 +7230,6 @@
37705                 goto out_nofree;
37706         }
37707  
37708 -       tw32(TG3PCI_CLOCK_CTRL, 0);
37709 -
37710         if ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) == 0) {
37711                 tp->dma_rwctrl =
37712                         (0x7 << DMA_RWCTRL_PCI_WRITE_CMD_SHIFT) |
37713 @@ -6423,7 +7237,9 @@
37714                         (0x7 << DMA_RWCTRL_WRITE_WATER_SHIFT) |
37715                         (0x7 << DMA_RWCTRL_READ_WATER_SHIFT) |
37716                         (0x0f << DMA_RWCTRL_MIN_DMA_SHIFT);
37717 -               /* XXX 5705 note: set MIN_DMA to zero here */
37718 +               if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
37719 +                       tp->dma_rwctrl &= ~(DMA_RWCTRL_MIN_DMA
37720 +                                           << DMA_RWCTRL_MIN_DMA_SHIFT);
37721         } else {
37722                 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
37723                         tp->dma_rwctrl =
37724 @@ -6524,8 +7340,15 @@
37725                 tp->dma_rwctrl |= DMA_RWCTRL_USE_MEM_READ_MULT;
37726         }
37727  
37728 +       tp->dma_rwctrl |= DMA_RWCTRL_ASSERT_ALL_BE;
37729 +
37730         tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl);
37731  
37732 +#if 0
37733 +       /* Unneeded, already done by tg3_get_invariants.  */
37734 +       tg3_switch_clocks(tp);
37735 +#endif
37736 +
37737         ret = 0;
37738         if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700 &&
37739             GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701)
37740 @@ -6630,12 +7453,35 @@
37741         case PHY_ID_BCM5701:    return "5701";
37742         case PHY_ID_BCM5703:    return "5703";
37743         case PHY_ID_BCM5704:    return "5704";
37744 +       case PHY_ID_BCM5705:    return "5705";
37745         case PHY_ID_BCM8002:    return "8002";
37746         case PHY_ID_SERDES:     return "serdes";
37747         default:                return "unknown";
37748         };
37749  }
37750  
37751 +static struct pci_dev * __devinit tg3_find_5704_peer(struct tg3 *tp)
37752 +{
37753 +       struct pci_dev *peer = NULL;
37754 +       unsigned int func;
37755 +
37756 +       for (func = 0; func < 7; func++) {
37757 +               unsigned int devfn = tp->pdev->devfn;
37758 +
37759 +               devfn &= ~7;
37760 +               devfn |= func;
37761 +
37762 +               if (devfn == tp->pdev->devfn)
37763 +                       continue;
37764 +               peer = pci_find_slot(tp->pdev->bus->number, devfn);
37765 +               if (peer)
37766 +                       break;
37767 +       }
37768 +       if (!peer || peer == tp->pdev)
37769 +               BUG();
37770 +       return peer;
37771 +}
37772 +
37773  static int __devinit tg3_init_one(struct pci_dev *pdev,
37774                                   const struct pci_device_id *ent)
37775  {
37776 @@ -6688,7 +7534,7 @@
37777                         goto err_out_free_res;
37778                 }
37779         } else {
37780 -               err = pci_set_dma_mask(pdev, (u64) 0xffffffff);
37781 +               err = pci_set_dma_mask(pdev, 0xffffffffULL);
37782                 if (err) {
37783                         printk(KERN_ERR PFX "No usable DMA configuration, "
37784                                "aborting.\n");
37785 @@ -6794,6 +7640,44 @@
37786                 goto err_out_iounmap;
37787         }
37788  
37789 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
37790 +               tp->bufmgr_config.mbuf_read_dma_low_water =
37791 +                       DEFAULT_MB_RDMA_LOW_WATER_5705;
37792 +               tp->bufmgr_config.mbuf_mac_rx_low_water =
37793 +                       DEFAULT_MB_MACRX_LOW_WATER_5705;
37794 +               tp->bufmgr_config.mbuf_high_water =
37795 +                       DEFAULT_MB_HIGH_WATER_5705;
37796 +       }
37797 +
37798 +#if TG3_TSO_SUPPORT != 0
37799 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
37800 +           GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 ||
37801 +           tp->pci_chip_rev_id == CHIPREV_ID_5705_A0 ||
37802 +           (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0 ||
37803 +           (tp->tg3_flags2 & TG3_FLG2_IS_5788)) {
37804 +               tp->tg3_flags2 &= ~TG3_FLG2_TSO_CAPABLE;
37805 +       } else {
37806 +               tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE;
37807 +       }
37808 +
37809 +       /* TSO is off by default, user can enable using ethtool.  */
37810 +#if 0
37811 +       if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE)
37812 +               dev->features |= NETIF_F_TSO;
37813 +#endif
37814 +
37815 +#endif
37816 +
37817 +       if (tp->pci_chip_rev_id == CHIPREV_ID_5705_A1 &&
37818 +           !(tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) &&
37819 +           !(tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH)) {
37820 +               tp->tg3_flags2 |= TG3_FLG2_MAX_RXPEND_64;
37821 +               tp->rx_pending = 64;
37822 +       }
37823 +
37824 +       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
37825 +               tp->pdev_peer = tg3_find_5704_peer(tp);
37826 +
37827         err = tg3_get_device_address(tp);
37828         if (err) {
37829                 printk(KERN_ERR PFX "Could not obtain valid ethernet address, "
37830 @@ -6816,16 +7700,8 @@
37831         } else
37832                 tp->tg3_flags &= ~TG3_FLAG_RX_CHECKSUMS;
37833  
37834 -#if TG3_DO_TSO != 0
37835 -       if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
37836 -           (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 &&
37837 -            tp->pci_chip_rev_id <= CHIPREV_ID_5701_B2)) {
37838 -               /* Not TSO capable. */
37839 -               dev->features &= ~NETIF_F_TSO;
37840 -       } else {
37841 -               dev->features |= NETIF_F_TSO;
37842 -       }
37843 -#endif
37844 +       if (tp->tg3_flags2 & TG3_FLG2_IS_5788)
37845 +               dev->features &= ~NETIF_F_HIGHDMA;
37846  
37847         err = register_netdev(dev);
37848         if (err) {
37849 diff -Nru a/drivers/net/tg3.h b/drivers/net/tg3.h
37850 --- a/drivers/net/tg3.h Sat Aug  2 18:24:21 2003
37851 +++ b/drivers/net/tg3.h Sat Aug 23 21:07:46 2003
37852 @@ -24,6 +24,7 @@
37853  #define RX_COPY_THRESHOLD              256
37854  
37855  #define RX_STD_MAX_SIZE                        1536
37856 +#define RX_STD_MAX_SIZE_5705           512
37857  #define RX_JUMBO_MAX_SIZE              0xdeadbeef /* XXX */
37858  
37859  /* First 256 bytes are a mirror of PCI config space. */
37860 @@ -59,7 +60,7 @@
37861  #define  PCIX_CAPS_SPLIT_SHIFT          20
37862  #define  PCIX_CAPS_BURST_MASK           0x000c0000
37863  #define  PCIX_CAPS_BURST_SHIFT          18
37864 -#define  PCIX_CAPS_MAX_BURST_5704       2
37865 +#define  PCIX_CAPS_MAX_BURST_CPIOB      2
37866  #define TG3PCI_PM_CAP_PTR              0x00000041
37867  #define TG3PCI_X_COMMAND               0x00000042
37868  #define TG3PCI_X_STATUS                        0x00000044
37869 @@ -115,11 +116,14 @@
37870  #define  CHIPREV_ID_5704_A0             0x2000
37871  #define  CHIPREV_ID_5704_A1             0x2001
37872  #define  CHIPREV_ID_5704_A2             0x2002
37873 +#define  CHIPREV_ID_5705_A0             0x3000
37874 +#define  CHIPREV_ID_5705_A1             0x3001
37875  #define  GET_ASIC_REV(CHIP_REV_ID)     ((CHIP_REV_ID) >> 12)
37876  #define   ASIC_REV_5700                         0x07
37877  #define   ASIC_REV_5701                         0x00
37878  #define   ASIC_REV_5703                         0x01
37879  #define   ASIC_REV_5704                         0x02
37880 +#define   ASIC_REV_5705                         0x03
37881  #define  GET_CHIP_REV(CHIP_REV_ID)     ((CHIP_REV_ID) >> 8)
37882  #define   CHIPREV_5700_AX               0x70
37883  #define   CHIPREV_5700_BX               0x71
37884 @@ -180,6 +184,9 @@
37885  #define  CLOCK_CTRL_ALTCLK              0x00001000
37886  #define  CLOCK_CTRL_PWRDOWN_PLL133      0x00008000
37887  #define  CLOCK_CTRL_44MHZ_CORE          0x00040000
37888 +#define  CLOCK_CTRL_625_CORE            0x00100000
37889 +#define  CLOCK_CTRL_FORCE_CLKRUN        0x00200000
37890 +#define  CLOCK_CTRL_CLKRUN_OENABLE      0x00400000
37891  #define  CLOCK_CTRL_DELAY_PCI_GRANT     0x80000000
37892  #define TG3PCI_REG_BASE_ADDR           0x00000078
37893  #define TG3PCI_MEM_WIN_BASE_ADDR       0x0000007c
37894 @@ -457,17 +464,89 @@
37895  #define MAC_RCV_RULE_CFG               0x00000500
37896  #define  RCV_RULE_CFG_DEFAULT_CLASS    0x00000008
37897  #define MAC_LOW_WMARK_MAX_RX_FRAME     0x00000504
37898 -/* 0x504 --> 0x590 unused */
37899 +/* 0x508 --> 0x520 unused */
37900 +#define MAC_HASHREGU_0                 0x00000520
37901 +#define MAC_HASHREGU_1                 0x00000524
37902 +#define MAC_HASHREGU_2                 0x00000528
37903 +#define MAC_HASHREGU_3                 0x0000052c
37904 +#define MAC_EXTADDR_0_HIGH             0x00000530
37905 +#define MAC_EXTADDR_0_LOW              0x00000534
37906 +#define MAC_EXTADDR_1_HIGH             0x00000538
37907 +#define MAC_EXTADDR_1_LOW              0x0000053c
37908 +#define MAC_EXTADDR_2_HIGH             0x00000540
37909 +#define MAC_EXTADDR_2_LOW              0x00000544
37910 +#define MAC_EXTADDR_3_HIGH             0x00000548
37911 +#define MAC_EXTADDR_3_LOW              0x0000054c
37912 +#define MAC_EXTADDR_4_HIGH             0x00000550
37913 +#define MAC_EXTADDR_4_LOW              0x00000554
37914 +#define MAC_EXTADDR_5_HIGH             0x00000558
37915 +#define MAC_EXTADDR_5_LOW              0x0000055c
37916 +#define MAC_EXTADDR_6_HIGH             0x00000560
37917 +#define MAC_EXTADDR_6_LOW              0x00000564
37918 +#define MAC_EXTADDR_7_HIGH             0x00000568
37919 +#define MAC_EXTADDR_7_LOW              0x0000056c
37920 +#define MAC_EXTADDR_8_HIGH             0x00000570
37921 +#define MAC_EXTADDR_8_LOW              0x00000574
37922 +#define MAC_EXTADDR_9_HIGH             0x00000578
37923 +#define MAC_EXTADDR_9_LOW              0x0000057c
37924 +#define MAC_EXTADDR_10_HIGH            0x00000580
37925 +#define MAC_EXTADDR_10_LOW             0x00000584
37926 +#define MAC_EXTADDR_11_HIGH            0x00000588
37927 +#define MAC_EXTADDR_11_LOW             0x0000058c
37928  #define MAC_SERDES_CFG                 0x00000590
37929  #define MAC_SERDES_STAT                        0x00000594
37930  /* 0x598 --> 0x600 unused */
37931  #define MAC_TX_MAC_STATE_BASE          0x00000600 /* 16 bytes */
37932  #define MAC_RX_MAC_STATE_BASE          0x00000610 /* 20 bytes */
37933  /* 0x624 --> 0x800 unused */
37934 -#define MAC_RX_STATS_BASE              0x00000800 /* 26 32-bit words */
37935 -/* 0x868 --> 0x880 unused */
37936 -#define MAC_TX_STATS_BASE              0x00000880 /* 28 32-bit words */
37937 -/* 0x8f0 --> 0xc00 unused */
37938 +#define MAC_TX_STATS_OCTETS            0x00000800
37939 +#define MAC_TX_STATS_RESV1             0x00000804
37940 +#define MAC_TX_STATS_COLLISIONS                0x00000808
37941 +#define MAC_TX_STATS_XON_SENT          0x0000080c
37942 +#define MAC_TX_STATS_XOFF_SENT         0x00000810
37943 +#define MAC_TX_STATS_RESV2             0x00000814
37944 +#define MAC_TX_STATS_MAC_ERRORS                0x00000818
37945 +#define MAC_TX_STATS_SINGLE_COLLISIONS 0x0000081c
37946 +#define MAC_TX_STATS_MULT_COLLISIONS   0x00000820
37947 +#define MAC_TX_STATS_DEFERRED          0x00000824
37948 +#define MAC_TX_STATS_RESV3             0x00000828
37949 +#define MAC_TX_STATS_EXCESSIVE_COL     0x0000082c
37950 +#define MAC_TX_STATS_LATE_COL          0x00000830
37951 +#define MAC_TX_STATS_RESV4_1           0x00000834
37952 +#define MAC_TX_STATS_RESV4_2           0x00000838
37953 +#define MAC_TX_STATS_RESV4_3           0x0000083c
37954 +#define MAC_TX_STATS_RESV4_4           0x00000840
37955 +#define MAC_TX_STATS_RESV4_5           0x00000844
37956 +#define MAC_TX_STATS_RESV4_6           0x00000848
37957 +#define MAC_TX_STATS_RESV4_7           0x0000084c
37958 +#define MAC_TX_STATS_RESV4_8           0x00000850
37959 +#define MAC_TX_STATS_RESV4_9           0x00000854
37960 +#define MAC_TX_STATS_RESV4_10          0x00000858
37961 +#define MAC_TX_STATS_RESV4_11          0x0000085c
37962 +#define MAC_TX_STATS_RESV4_12          0x00000860
37963 +#define MAC_TX_STATS_RESV4_13          0x00000864
37964 +#define MAC_TX_STATS_RESV4_14          0x00000868
37965 +#define MAC_TX_STATS_UCAST             0x0000086c
37966 +#define MAC_TX_STATS_MCAST             0x00000870
37967 +#define MAC_TX_STATS_BCAST             0x00000874
37968 +#define MAC_TX_STATS_RESV5_1           0x00000878
37969 +#define MAC_TX_STATS_RESV5_2           0x0000087c
37970 +#define MAC_RX_STATS_OCTETS            0x00000880
37971 +#define MAC_RX_STATS_RESV1             0x00000884
37972 +#define MAC_RX_STATS_FRAGMENTS         0x00000888
37973 +#define MAC_RX_STATS_UCAST             0x0000088c
37974 +#define MAC_RX_STATS_MCAST             0x00000890
37975 +#define MAC_RX_STATS_BCAST             0x00000894
37976 +#define MAC_RX_STATS_FCS_ERRORS                0x00000898
37977 +#define MAC_RX_STATS_ALIGN_ERRORS      0x0000089c
37978 +#define MAC_RX_STATS_XON_PAUSE_RECVD   0x000008a0
37979 +#define MAC_RX_STATS_XOFF_PAUSE_RECVD  0x000008a4
37980 +#define MAC_RX_STATS_MAC_CTRL_RECVD    0x000008a8
37981 +#define MAC_RX_STATS_XOFF_ENTERED      0x000008ac
37982 +#define MAC_RX_STATS_FRAME_TOO_LONG    0x000008b0
37983 +#define MAC_RX_STATS_JABBERS           0x000008b4
37984 +#define MAC_RX_STATS_UNDERSIZE         0x000008b8
37985 +/* 0x8bc --> 0xc00 unused */
37986  
37987  /* Send data initiator control registers */
37988  #define SNDDATAI_MODE                  0x00000c00
37989 @@ -599,6 +678,7 @@
37990  #define  RCVLPC_STATSCTRL_ENABLE        0x00000001
37991  #define  RCVLPC_STATSCTRL_FASTUPD       0x00000002
37992  #define RCVLPC_STATS_ENABLE            0x00002018
37993 +#define  RCVLPC_STATSENAB_LNGBRST_RFIX  0x00400000
37994  #define RCVLPC_STATS_INCMASK           0x0000201c
37995  /* 0x2020 --> 0x2100 unused */
37996  #define RCVLPC_SELLST_BASE             0x00002100 /* 16 16-byte entries */
37997 @@ -812,13 +892,16 @@
37998  #define BUFMGR_MB_POOL_ADDR            0x00004408
37999  #define BUFMGR_MB_POOL_SIZE            0x0000440c
38000  #define BUFMGR_MB_RDMA_LOW_WATER       0x00004410
38001 -#define  DEFAULT_MB_RDMA_LOW_WATER      0x00000040
38002 +#define  DEFAULT_MB_RDMA_LOW_WATER      0x00000050
38003 +#define  DEFAULT_MB_RDMA_LOW_WATER_5705         0x00000000
38004  #define  DEFAULT_MB_RDMA_LOW_WATER_JUMBO 0x00000130
38005  #define BUFMGR_MB_MACRX_LOW_WATER      0x00004414
38006  #define  DEFAULT_MB_MACRX_LOW_WATER      0x00000020
38007 +#define  DEFAULT_MB_MACRX_LOW_WATER_5705  0x00000010
38008  #define  DEFAULT_MB_MACRX_LOW_WATER_JUMBO 0x00000098
38009  #define BUFMGR_MB_HIGH_WATER           0x00004418
38010  #define  DEFAULT_MB_HIGH_WATER          0x00000060
38011 +#define  DEFAULT_MB_HIGH_WATER_5705     0x00000060
38012  #define  DEFAULT_MB_HIGH_WATER_JUMBO    0x0000017c
38013  #define BUFMGR_RX_MB_ALLOC_REQ         0x0000441c
38014  #define  BUFMGR_MB_ALLOC_BIT            0x10000000
38015 @@ -854,6 +937,8 @@
38016  #define  RDMAC_MODE_LNGREAD_ENAB        0x00000200
38017  #define  RDMAC_MODE_SPLIT_ENABLE        0x00000800
38018  #define  RDMAC_MODE_SPLIT_RESET                 0x00001000
38019 +#define  RDMAC_MODE_FIFO_SIZE_128       0x00020000
38020 +#define  RDMAC_MODE_FIFO_LONG_BURST     0x00030000
38021  #define RDMAC_STATUS                   0x00004804
38022  #define  RDMAC_STATUS_TGTABORT          0x00000004
38023  #define  RDMAC_STATUS_MSTABORT          0x00000008
38024 @@ -877,6 +962,7 @@
38025  #define  WDMAC_MODE_FIFOURUN_ENAB       0x00000080
38026  #define  WDMAC_MODE_FIFOOREAD_ENAB      0x00000100
38027  #define  WDMAC_MODE_LNGREAD_ENAB        0x00000200
38028 +#define  WDMAC_MODE_RX_ACCEL            0x00000400
38029  #define WDMAC_STATUS                   0x00004c04
38030  #define  WDMAC_STATUS_TGTABORT          0x00000004
38031  #define  WDMAC_STATUS_MSTABORT          0x00000008
38032 @@ -1140,7 +1226,10 @@
38033  #define  GRC_MISC_CFG_BOARD_ID_5704    0x00000000
38034  #define  GRC_MISC_CFG_BOARD_ID_5704CIOBE 0x00004000
38035  #define  GRC_MISC_CFG_BOARD_ID_5704_A2 0x00008000
38036 +#define  GRC_MISC_CFG_BOARD_ID_5788    0x00010000
38037 +#define  GRC_MISC_CFG_BOARD_ID_5788M   0x00018000
38038  #define  GRC_MISC_CFG_BOARD_ID_AC91002A1 0x00018000
38039 +#define  GRC_MISC_CFG_KEEP_GPHY_POWER  0x04000000
38040  #define GRC_LOCAL_CTRL                 0x00006808
38041  #define  GRC_LCLCTRL_INT_ACTIVE                0x00000001
38042  #define  GRC_LCLCTRL_CLEARINT          0x00000002
38043 @@ -1275,6 +1364,7 @@
38044  #define  NIC_SRAM_DATA_CFG_WOL_ENABLE           0x00000040
38045  #define  NIC_SRAM_DATA_CFG_ASF_ENABLE           0x00000080
38046  #define  NIC_SRAM_DATA_CFG_EEPROM_WP            0x00000100
38047 +#define  NIC_SRAM_DATA_CFG_MINI_PCI             0x00001000
38048  #define  NIC_SRAM_DATA_CFG_FIBER_WOL            0x00004000
38049  
38050  #define NIC_SRAM_DATA_PHY_ID           0x00000b74
38051 @@ -1312,6 +1402,8 @@
38052  #define NIC_SRAM_MBUF_POOL_BASE                0x00008000
38053  #define  NIC_SRAM_MBUF_POOL_SIZE96      0x00018000
38054  #define  NIC_SRAM_MBUF_POOL_SIZE64      0x00010000
38055 +#define  NIC_SRAM_MBUF_POOL_BASE5705   0x00010000
38056 +#define  NIC_SRAM_MBUF_POOL_SIZE5705   0x0000e000
38057  
38058  /* Currently this is fixed. */
38059  #define PHY_ADDR               0x01
38060 @@ -1824,6 +1916,10 @@
38061         u32                             tg3_flags2;
38062  #define TG3_FLG2_RESTART_TIMER         0x00000001
38063  #define TG3_FLG2_SUN_5704              0x00000002
38064 +#define TG3_FLG2_NO_ETH_WIRE_SPEED     0x00000004
38065 +#define TG3_FLG2_IS_5788               0x00000008
38066 +#define TG3_FLG2_MAX_RXPEND_64         0x00000010
38067 +#define TG3_FLG2_TSO_CAPABLE           0x00000020
38068  
38069         u32                             split_mode_max_reqs;
38070  #define SPLIT_MODE_5704_MAX_REQ                3
38071 @@ -1868,6 +1964,7 @@
38072  #define PHY_ID_BCM5701                 0x60008110
38073  #define PHY_ID_BCM5703                 0x60008160
38074  #define PHY_ID_BCM5704                 0x60008190
38075 +#define PHY_ID_BCM5705                 0x600081a0
38076  #define PHY_ID_BCM8002                 0x60010140
38077  #define PHY_ID_SERDES                  0xfeedbee0
38078  #define PHY_ID_INVALID                 0xffffffff
38079 @@ -1880,6 +1977,9 @@
38080         enum phy_led_mode               led_mode;
38081  
38082         char                            board_part_number[24];
38083 +       u32                             nic_sram_data_cfg;
38084 +       u32                             pci_clock_ctrl;
38085 +       struct pci_dev                  *pdev_peer;
38086  
38087         /* This macro assumes the passed PHY ID is already masked
38088          * with PHY_ID_MASK.
38089 @@ -1888,6 +1988,7 @@
38090         ((X) == PHY_ID_BCM5400 || (X) == PHY_ID_BCM5401 || \
38091          (X) == PHY_ID_BCM5411 || (X) == PHY_ID_BCM5701 || \
38092          (X) == PHY_ID_BCM5703 || (X) == PHY_ID_BCM5704 || \
38093 +        (X) == PHY_ID_BCM5705 || \
38094          (X) == PHY_ID_BCM8002 || (X) == PHY_ID_SERDES)
38095  
38096         struct tg3_hw_stats             *hw_stats;
38097 diff -Nru a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c
38098 --- a/drivers/net/tokenring/lanstreamer.c       Tue Aug 19 20:54:17 2003
38099 +++ b/drivers/net/tokenring/lanstreamer.c       Mon Sep  1 08:30:59 2003
38100 @@ -228,7 +228,6 @@
38101         int rc = 0;
38102         static int card_no=-1;
38103         u16 pcr;
38104 -       u8 cls = 0;
38105  
38106  #if STREAMER_DEBUG
38107         printk("lanstreamer::streamer_init_one, entry pdev %p\n",pdev);
38108 @@ -254,14 +253,16 @@
38109  #endif
38110  #endif
38111  
38112 -       if (pci_set_dma_mask(pdev, 0xFFFFFFFF)) {
38113 +       rc = pci_set_dma_mask(pdev, 0xFFFFFFFFULL);
38114 +       if (rc) {
38115                 printk(KERN_ERR "%s: No suitable PCI mapping available.\n",
38116                                 dev->name);
38117                 rc = -ENODEV;
38118                 goto err_out;
38119         }
38120  
38121 -       if (pci_enable_device(pdev)) {
38122 +       rc = pci_enable_device(pdev);
38123 +       if (rc) {
38124                 printk(KERN_ERR "lanstreamer: unable to enable pci device\n");
38125                 rc=-EIO;
38126                 goto err_out;
38127 @@ -269,6 +270,12 @@
38128  
38129         pci_set_master(pdev);
38130  
38131 +       rc = pci_set_mwi(pdev);
38132 +       if (rc) {
38133 +               printk(KERN_ERR "lanstreamer: unable to enable MWI on pci device\n");
38134 +               goto err_out_disable;
38135 +       }
38136 +
38137         pio_start = pci_resource_start(pdev, 0);
38138         pio_end = pci_resource_end(pdev, 0);
38139         pio_flags = pci_resource_flags(pdev, 0);
38140 @@ -290,7 +297,7 @@
38141                 printk(KERN_ERR "lanstreamer: unable to get pci io addr %lx\n",
38142                         pio_start);
38143                 rc= -EBUSY;
38144 -               goto err_out;
38145 +               goto err_out_mwi;
38146         }
38147  
38148         if (!request_mem_region(mmio_start, mmio_len, "lanstreamer")) {
38149 @@ -341,26 +348,9 @@
38150  
38151         spin_lock_init(&streamer_priv->streamer_lock);
38152  
38153 -       pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &cls);
38154 -       cls <<= 2;
38155 -       if (cls != SMP_CACHE_BYTES) {
38156 -               printk(KERN_INFO "  PCI cache line size set incorrectly "
38157 -                               "(%i bytes) by BIOS/FW, ", cls);
38158 -               if (cls > SMP_CACHE_BYTES)
38159 -                       printk("expecting %i\n", SMP_CACHE_BYTES);
38160 -               else {
38161 -                       printk("correcting to %i\n", SMP_CACHE_BYTES);
38162 -                       pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE,
38163 -                                                       SMP_CACHE_BYTES >> 2);
38164 -               }
38165 -       }
38166 -
38167         pci_read_config_word (pdev, PCI_COMMAND, &pcr);
38168 -
38169 -       pcr |= (PCI_COMMAND_INVALIDATE | PCI_COMMAND_SERR);
38170 -
38171 +       pcr |= PCI_COMMAND_SERR;
38172         pci_write_config_word (pdev, PCI_COMMAND, pcr);
38173 -       pci_read_config_word (pdev, PCI_COMMAND, &pcr);
38174  
38175         printk("%s \n", version);
38176         printk("%s: %s. I/O at %hx, MMIO at %p, using irq %d\n",dev->name,
38177 @@ -383,8 +373,12 @@
38178         release_mem_region(mmio_start, mmio_len);
38179  err_out_free_pio:
38180         release_region(pio_start, pio_len);
38181 +err_out_mwi:
38182 +       pci_clear_mwi(pdev);
38183 +err_out_disable:
38184 +       pci_disable_device(pdev);
38185  err_out:
38186 -       kfree(dev);
38187 +       free_netdev(dev);
38188  #if STREAMER_DEBUG
38189         printk("lanstreamer: Exit error %x\n",rc);
38190  #endif
38191 @@ -430,9 +424,11 @@
38192  #endif
38193  
38194         unregister_netdev(dev);
38195 -       /* shouldn't we do iounmap here? */
38196 -       release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev,0));
38197 +       iounmap(streamer_priv->streamer_mmio);
38198         release_mem_region(pci_resource_start(pdev, 1), pci_resource_len(pdev,1));
38199 +       release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev,0));
38200 +       pci_clear_mwi(pdev);
38201 +       pci_disable_device(pdev);
38202         free_netdev(dev);
38203         pci_set_drvdata(pdev, NULL);
38204  }
38205 diff -Nru a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
38206 --- a/drivers/net/tulip/de2104x.c       Tue Aug 19 20:53:17 2003
38207 +++ b/drivers/net/tulip/de2104x.c       Mon Sep  1 08:05:06 2003
38208 @@ -1,6 +1,6 @@
38209  /* de2104x.c: A Linux PCI Ethernet driver for Intel/Digital 21040/1 chips. */
38210  /*
38211 -       Copyright 2001 Jeff Garzik <jgarzik@pobox.com>
38212 +       Copyright 2001,2003 Jeff Garzik <jgarzik@pobox.com>
38213  
38214         Copyright 1994, 1995 Digital Equipment Corporation.         [de4x5.c]
38215         Written/copyright 1994-2001 by Donald Becker.               [tulip.c]
38216 @@ -28,8 +28,8 @@
38217   */
38218  
38219  #define DRV_NAME               "de2104x"
38220 -#define DRV_VERSION            "0.5.4"
38221 -#define DRV_RELDATE            "Jan 1, 2002"
38222 +#define DRV_VERSION            "0.6"
38223 +#define DRV_RELDATE            "Sep 1, 2003"
38224  
38225  #include <linux/config.h>
38226  #include <linux/module.h>
38227 @@ -1464,7 +1464,7 @@
38228         netif_wake_queue(dev);
38229  }
38230  
38231 -static int de_get_regs(struct de_private *de, u8 *buf)
38232 +static void __de_get_regs(struct de_private *de, u8 *buf)
38233  {
38234         int i;
38235         u32 *rbuf = (u32 *)buf;
38236 @@ -1475,11 +1475,9 @@
38237  
38238         /* handle self-clearing RxMissed counter, CSR8 */
38239         de_rx_missed(de, rbuf[8]);
38240 -
38241 -       return 0;
38242  }
38243  
38244 -static int de_ethtool_gset(struct de_private *de, struct ethtool_cmd *ecmd)
38245 +static int __de_get_settings(struct de_private *de, struct ethtool_cmd *ecmd)
38246  {
38247         ecmd->supported = de->media_supported;
38248         ecmd->transceiver = XCVR_INTERNAL;
38249 @@ -1516,7 +1514,7 @@
38250         return 0;
38251  }
38252  
38253 -static int de_ethtool_sset(struct de_private *de, struct ethtool_cmd *ecmd)
38254 +static int __de_set_settings(struct de_private *de, struct ethtool_cmd *ecmd)
38255  {
38256         u32 new_media;
38257         unsigned int media_lock;
38258 @@ -1584,169 +1582,121 @@
38259         return 0;
38260  }
38261  
38262 -static int de_ethtool_ioctl (struct de_private *de, void *useraddr)
38263 +static void de_get_drvinfo (struct net_device *dev,struct ethtool_drvinfo *info)
38264  {
38265 -       u32 ethcmd;
38266 +       struct de_private *de = dev->priv;
38267  
38268 -       /* dev_ioctl() in ../../net/core/dev.c has already checked
38269 -          capable(CAP_NET_ADMIN), so don't bother with that here.  */
38270 +       strcpy (info->driver, DRV_NAME);
38271 +       strcpy (info->version, DRV_VERSION);
38272 +       strcpy (info->bus_info, pci_name(de->pdev));
38273 +       info->eedump_len = DE_EEPROM_SIZE;
38274 +}
38275  
38276 -       if (get_user(ethcmd, (u32 *)useraddr))
38277 -               return -EFAULT;
38278 -
38279 -       switch (ethcmd) {
38280 -
38281 -       case ETHTOOL_GDRVINFO: {
38282 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
38283 -               strcpy (info.driver, DRV_NAME);
38284 -               strcpy (info.version, DRV_VERSION);
38285 -               strcpy (info.bus_info, pci_name(de->pdev));
38286 -               info.eedump_len = DE_EEPROM_SIZE;
38287 -               info.regdump_len = DE_REGS_SIZE;
38288 -               if (copy_to_user (useraddr, &info, sizeof (info)))
38289 -                       return -EFAULT;
38290 -               return 0;
38291 -       }
38292 -
38293 -       /* get settings */
38294 -       case ETHTOOL_GSET: {
38295 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
38296 -               spin_lock_irq(&de->lock);
38297 -               de_ethtool_gset(de, &ecmd);
38298 -               spin_unlock_irq(&de->lock);
38299 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
38300 -                       return -EFAULT;
38301 -               return 0;
38302 -       }
38303 -       /* set settings */
38304 -       case ETHTOOL_SSET: {
38305 -               struct ethtool_cmd ecmd;
38306 -               int r;
38307 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
38308 -                       return -EFAULT;
38309 -               spin_lock_irq(&de->lock);
38310 -               r = de_ethtool_sset(de, &ecmd);
38311 -               spin_unlock_irq(&de->lock);
38312 -               return r;
38313 -       }
38314 +static int de_get_regs_len(struct net_device *dev)
38315 +{
38316 +       return DE_REGS_SIZE;
38317 +}
38318  
38319 -       /* restart autonegotiation */
38320 -       case ETHTOOL_NWAY_RST: {
38321 -               u32 status;
38322 +static int de_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
38323 +{
38324 +       struct de_private *de = dev->priv;
38325 +       int rc;
38326  
38327 -               if (de->media_type != DE_MEDIA_TP_AUTO)
38328 -                       return -EINVAL;
38329 -               if (netif_carrier_ok(de->dev))
38330 -                       de_link_down(de);
38331 +       spin_lock_irq(&de->lock);
38332 +       rc = __de_get_settings(de, ecmd);
38333 +       spin_unlock_irq(&de->lock);
38334  
38335 -               status = dr32(SIAStatus);
38336 -               dw32(SIAStatus, (status & ~NWayState) | NWayRestart);
38337 -               if (netif_msg_link(de))
38338 -                       printk(KERN_INFO "%s: link nway restart, status %x,%x\n",
38339 -                              de->dev->name, status, dr32(SIAStatus));
38340 -               return 0;
38341 -       }
38342 -
38343 -       /* get link status */
38344 -       case ETHTOOL_GLINK: {
38345 -               struct ethtool_value edata = {ETHTOOL_GLINK};
38346 -               edata.data = (netif_carrier_ok(de->dev)) ? 1 : 0;
38347 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
38348 -                       return -EFAULT;
38349 -               return 0;
38350 -       }
38351 -
38352 -       /* get message-level */
38353 -       case ETHTOOL_GMSGLVL: {
38354 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
38355 -               edata.data = de->msg_enable;
38356 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
38357 -                       return -EFAULT;
38358 -               return 0;
38359 -       }
38360 -       /* set message-level */
38361 -       case ETHTOOL_SMSGLVL: {
38362 -               struct ethtool_value edata;
38363 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
38364 -                       return -EFAULT;
38365 -               de->msg_enable = edata.data;
38366 -               return 0;
38367 -       }
38368 -
38369 -       /* get registers */
38370 -       case ETHTOOL_GREGS: {
38371 -               struct ethtool_regs regs;
38372 -               u8 regbuf[DE_REGS_SIZE];
38373 -               int r;
38374 +       return rc;
38375 +}
38376  
38377 -               if (copy_from_user(&regs, useraddr, sizeof(regs)))
38378 -                       return -EFAULT;
38379 -               
38380 -               if (regs.len > DE_REGS_SIZE) {
38381 -                       regs.len = DE_REGS_SIZE;
38382 -               }
38383 -               regs.version = (DE_REGS_VER << 2) | de->de21040;
38384 -               if (copy_to_user(useraddr, &regs, sizeof(regs)))
38385 -                       return -EFAULT;
38386 +static int de_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
38387 +{
38388 +       struct de_private *de = dev->priv;
38389 +       int rc;
38390  
38391 -               useraddr += offsetof(struct ethtool_regs, data);
38392 +       spin_lock_irq(&de->lock);
38393 +       rc = __de_set_settings(de, ecmd);
38394 +       spin_unlock_irq(&de->lock);
38395  
38396 -               spin_lock_irq(&de->lock);
38397 -               r = de_get_regs(de, regbuf);
38398 -               spin_unlock_irq(&de->lock);
38399 +       return rc;
38400 +}
38401  
38402 -               if (r)
38403 -                       return r;
38404 -               if (copy_to_user(useraddr, regbuf, regs.len))
38405 -                       return -EFAULT;
38406 -               return 0;
38407 -       }
38408 +static u32 de_get_msglevel(struct net_device *dev)
38409 +{
38410 +       struct de_private *de = dev->priv;
38411  
38412 -       /* get SROM dump */
38413 -       case ETHTOOL_GEEPROM: {
38414 -               struct ethtool_eeprom eeprom;
38415 +       return de->msg_enable;
38416 +}
38417  
38418 -               if (!de->ee_data)
38419 -                       break;
38420 -               if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
38421 -                       return -EFAULT;
38422 -               if ((eeprom.offset != 0) || (eeprom.magic != 0) ||
38423 -                   (eeprom.len != DE_EEPROM_SIZE))
38424 -                       return -EINVAL;
38425 +static void de_set_msglevel(struct net_device *dev, u32 msglvl)
38426 +{
38427 +       struct de_private *de = dev->priv;
38428  
38429 -               useraddr += offsetof(struct ethtool_regs, data);
38430 -               if (copy_to_user(useraddr, de->ee_data, DE_EEPROM_SIZE))
38431 -                       return -EFAULT;
38432 -       }
38433 +       de->msg_enable = msglvl;
38434 +}
38435  
38436 -       default:
38437 -               break;
38438 -       }
38439 +static int de_get_eeprom(struct net_device *dev,
38440 +                        struct ethtool_eeprom *eeprom, u8 *data)
38441 +{
38442 +       struct de_private *de = dev->priv;
38443  
38444 -       return -EOPNOTSUPP;
38445 -}
38446 +       if (!de->ee_data)
38447 +               return -EOPNOTSUPP;
38448 +       if ((eeprom->offset != 0) || (eeprom->magic != 0) ||
38449 +           (eeprom->len != DE_EEPROM_SIZE))
38450 +               return -EINVAL;
38451 +       memcpy(data, de->ee_data, eeprom->len);
38452  
38453 +       return 0;
38454 +}
38455  
38456 -static int de_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
38457 +static int de_nway_reset(struct net_device *dev)
38458  {
38459         struct de_private *de = dev->priv;
38460 -       int rc = 0;
38461 +       u32 status;
38462  
38463 -       if (!netif_running(dev))
38464 +       if (de->media_type != DE_MEDIA_TP_AUTO)
38465                 return -EINVAL;
38466 -               
38467 -       switch (cmd) {
38468 -       case SIOCETHTOOL:
38469 -               return de_ethtool_ioctl(de, (void *) rq->ifr_data);
38470 +       if (netif_carrier_ok(de->dev))
38471 +               de_link_down(de);
38472  
38473 -       default:
38474 -               rc = -EOPNOTSUPP;
38475 -               break;
38476 -       }
38477 +       status = dr32(SIAStatus);
38478 +       dw32(SIAStatus, (status & ~NWayState) | NWayRestart);
38479 +       if (netif_msg_link(de))
38480 +               printk(KERN_INFO "%s: link nway restart, status %x,%x\n",
38481 +                      de->dev->name, status, dr32(SIAStatus));
38482 +       return 0;
38483 +}
38484  
38485 -       return rc;
38486 +static void de_get_regs(struct net_device *dev, struct ethtool_regs *regs,
38487 +                       void *data)
38488 +{
38489 +       struct de_private *de = dev->priv;
38490 +
38491 +       if (regs->len > DE_REGS_SIZE)
38492 +               regs->len = DE_REGS_SIZE;
38493 +       regs->version = (DE_REGS_VER << 2) | de->de21040;
38494 +
38495 +       spin_lock_irq(&de->lock);
38496 +       __de_get_regs(de, data);
38497 +       spin_unlock_irq(&de->lock);
38498  }
38499  
38500 +static struct ethtool_ops de_ethtool_ops = {
38501 +       .get_link               = ethtool_op_get_link,
38502 +       .get_tx_csum            = ethtool_op_get_tx_csum,
38503 +       .get_sg                 = ethtool_op_get_sg,
38504 +       .get_drvinfo            = de_get_drvinfo,
38505 +       .get_regs_len           = de_get_regs_len,
38506 +       .get_settings           = de_get_settings,
38507 +       .set_settings           = de_set_settings,
38508 +       .get_msglevel           = de_get_msglevel,
38509 +       .set_msglevel           = de_set_msglevel,
38510 +       .get_eeprom             = de_get_eeprom,
38511 +       .nway_reset             = de_nway_reset,
38512 +       .get_regs               = de_get_regs,
38513 +};
38514 +
38515  static void __init de21040_get_mac_address (struct de_private *de)
38516  {
38517         unsigned i;
38518 @@ -2011,7 +1961,7 @@
38519         dev->set_multicast_list = de_set_rx_mode;
38520         dev->hard_start_xmit = de_start_xmit;
38521         dev->get_stats = de_get_stats;
38522 -       dev->do_ioctl = de_ioctl;
38523 +       dev->ethtool_ops = &de_ethtool_ops;
38524         dev->tx_timeout = de_tx_timeout;
38525         dev->watchdog_timeo = TX_TIMEOUT;
38526  
38527 diff -Nru a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
38528 --- a/drivers/net/tulip/dmfe.c  Tue Aug 19 20:53:17 2003
38529 +++ b/drivers/net/tulip/dmfe.c  Tue Aug 26 13:42:22 2003
38530 @@ -296,7 +296,7 @@
38531  static int dmfe_stop(struct DEVICE *);
38532  static struct net_device_stats * dmfe_get_stats(struct DEVICE *);
38533  static void dmfe_set_filter_mode(struct DEVICE *);
38534 -static int dmfe_do_ioctl(struct DEVICE *, struct ifreq *, int);
38535 +static struct ethtool_ops netdev_ethtool_ops;
38536  static u16 read_srom_word(long ,int);
38537  static irqreturn_t dmfe_interrupt(int , void *, struct pt_regs *);
38538  static void dmfe_descriptor_init(struct dmfe_board_info *, unsigned long);
38539 @@ -417,7 +417,7 @@
38540         dev->stop = &dmfe_stop;
38541         dev->get_stats = &dmfe_get_stats;
38542         dev->set_multicast_list = &dmfe_set_filter_mode;
38543 -       dev->do_ioctl = &dmfe_do_ioctl;
38544 +       dev->ethtool_ops = &netdev_ethtool_ops;
38545         spin_lock_init(&db->lock);
38546  
38547         pci_read_config_dword(pdev, 0x50, &pci_pmr);
38548 @@ -1000,55 +1000,23 @@
38549         spin_unlock_irqrestore(&db->lock, flags);
38550  }
38551  
38552 -
38553 -/*
38554 - *     Process the ethtool ioctl command
38555 - */
38556 -
38557 -static int dmfe_ethtool_ioctl(struct net_device *dev, void *useraddr)
38558 +static void netdev_get_drvinfo(struct net_device *dev,
38559 +                              struct ethtool_drvinfo *info)
38560  {
38561 -       struct dmfe_board_info *db = dev->priv;
38562 -       struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
38563 -       u32 ethcmd;
38564 -
38565 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
38566 -               return -EFAULT;
38567 -
38568 -        switch (ethcmd) {
38569 -        case ETHTOOL_GDRVINFO:
38570 -               strcpy(info.driver, DRV_NAME);
38571 -               strcpy(info.version, DRV_VERSION);
38572 -               if (db->pdev)
38573 -                       strcpy(info.bus_info, pci_name(db->pdev));
38574 -               else
38575 -                       sprintf(info.bus_info, "EISA 0x%lx %d",
38576 -                               dev->base_addr, dev->irq);
38577 -               if (copy_to_user(useraddr, &info, sizeof(info)))
38578 -                       return -EFAULT;
38579 -               return 0;
38580 -        }
38581 -
38582 -       return -EOPNOTSUPP;
38583 -}
38584 +       struct dmfe_board_info *np = dev->priv;
38585  
38586 -
38587 -/*
38588 - *     Process the upper socket ioctl command
38589 - */
38590 -
38591 -static int dmfe_do_ioctl(struct DEVICE *dev, struct ifreq *ifr, int cmd)
38592 -{
38593 -       int retval = -EOPNOTSUPP;
38594 -       DMFE_DBUG(0, "dmfe_do_ioctl()", 0);
38595 -
38596 -       switch(cmd) {
38597 -       case SIOCETHTOOL:
38598 -               return dmfe_ethtool_ioctl(dev, (void*)ifr->ifr_data);
38599 -       }
38600 -
38601 -       return retval;
38602 +       strcpy(info->driver, DRV_NAME);
38603 +       strcpy(info->version, DRV_VERSION);
38604 +       if (np->pdev)
38605 +               strcpy(info->bus_info, pci_name(np->pdev));
38606 +       else
38607 +               sprintf(info->bus_info, "EISA 0x%lx %d",
38608 +                       dev->base_addr, dev->irq);
38609  }
38610  
38611 +static struct ethtool_ops netdev_ethtool_ops = {
38612 +       .get_drvinfo            = netdev_get_drvinfo,
38613 +};
38614  
38615  /*
38616   *     A periodic timer routine
38617 diff -Nru a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
38618 --- a/drivers/net/tulip/winbond-840.c   Tue Aug 19 20:53:17 2003
38619 +++ b/drivers/net/tulip/winbond-840.c   Mon Sep  1 14:05:11 2003
38620 @@ -392,6 +392,7 @@
38621  static void set_rx_mode(struct net_device *dev);
38622  static struct net_device_stats *get_stats(struct net_device *dev);
38623  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
38624 +static struct ethtool_ops netdev_ethtool_ops;
38625  static int  netdev_close(struct net_device *dev);
38626  
38627  \f
38628 @@ -482,6 +483,7 @@
38629         dev->get_stats = &get_stats;
38630         dev->set_multicast_list = &set_rx_mode;
38631         dev->do_ioctl = &netdev_ioctl;
38632 +       dev->ethtool_ops = &netdev_ethtool_ops;
38633         dev->tx_timeout = &tx_timeout;
38634         dev->watchdog_timeo = TX_TIMEOUT;
38635  
38636 @@ -1452,88 +1454,79 @@
38637         spin_unlock_irq(&np->lock);
38638  }
38639  
38640 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
38641 +static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
38642  {
38643         struct netdev_private *np = dev->priv;
38644 -       u32 ethcmd;
38645 -               
38646 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
38647 -               return -EFAULT;
38648 -
38649 -        switch (ethcmd) {
38650 -        case ETHTOOL_GDRVINFO: {
38651 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
38652 -               strcpy(info.driver, DRV_NAME);
38653 -               strcpy(info.version, DRV_VERSION);
38654 -               strcpy(info.bus_info, pci_name(np->pci_dev));
38655 -               if (copy_to_user(useraddr, &info, sizeof(info)))
38656 -                       return -EFAULT;
38657 -               return 0;
38658 -       }
38659 -
38660 -       /* get settings */
38661 -       case ETHTOOL_GSET: {
38662 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
38663 -               spin_lock_irq(&np->lock);
38664 -               mii_ethtool_gset(&np->mii_if, &ecmd);
38665 -               spin_unlock_irq(&np->lock);
38666 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
38667 -                       return -EFAULT;
38668 -               return 0;
38669 -       }
38670 -       /* set settings */
38671 -       case ETHTOOL_SSET: {
38672 -               int r;
38673 -               struct ethtool_cmd ecmd;
38674 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
38675 -                       return -EFAULT;
38676 -               spin_lock_irq(&np->lock);
38677 -               r = mii_ethtool_sset(&np->mii_if, &ecmd);
38678 -               spin_unlock_irq(&np->lock);
38679 -               return r;
38680 -       }
38681 -       /* restart autonegotiation */
38682 -       case ETHTOOL_NWAY_RST: {
38683 -               return mii_nway_restart(&np->mii_if);
38684 -       }
38685 -       /* get link status */
38686 -       case ETHTOOL_GLINK: {
38687 -               struct ethtool_value edata = {ETHTOOL_GLINK};
38688 -               edata.data = mii_link_ok(&np->mii_if);
38689 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
38690 -                       return -EFAULT;
38691 -               return 0;
38692 -       }
38693 -
38694 -       /* get message-level */
38695 -       case ETHTOOL_GMSGLVL: {
38696 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
38697 -               edata.data = debug;
38698 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
38699 -                       return -EFAULT;
38700 -               return 0;
38701 -       }
38702 -       /* set message-level */
38703 -       case ETHTOOL_SMSGLVL: {
38704 -               struct ethtool_value edata;
38705 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
38706 -                       return -EFAULT;
38707 -               debug = edata.data;
38708 -               return 0;
38709 -       }
38710 -        }
38711 -       
38712 -       return -EOPNOTSUPP;
38713 +
38714 +       strcpy (info->driver, DRV_NAME);
38715 +       strcpy (info->version, DRV_VERSION);
38716 +       strcpy (info->bus_info, pci_name(np->pci_dev));
38717 +}
38718 +
38719 +static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
38720 +{
38721 +       struct netdev_private *np = dev->priv;
38722 +       int rc;
38723 +
38724 +       spin_lock_irq(&np->lock);
38725 +       rc = mii_ethtool_gset(&np->mii_if, cmd);
38726 +       spin_unlock_irq(&np->lock);
38727 +
38728 +       return rc;
38729  }
38730  
38731 +static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
38732 +{
38733 +       struct netdev_private *np = dev->priv;
38734 +       int rc;
38735 +
38736 +       spin_lock_irq(&np->lock);
38737 +       rc = mii_ethtool_sset(&np->mii_if, cmd);
38738 +       spin_unlock_irq(&np->lock);
38739 +
38740 +       return rc;
38741 +}
38742 +
38743 +static int netdev_nway_reset(struct net_device *dev)
38744 +{
38745 +       struct netdev_private *np = dev->priv;
38746 +       return mii_nway_restart(&np->mii_if);
38747 +}
38748 +
38749 +static u32 netdev_get_link(struct net_device *dev)
38750 +{
38751 +       struct netdev_private *np = dev->priv;
38752 +       return mii_link_ok(&np->mii_if);
38753 +}
38754 +
38755 +static u32 netdev_get_msglevel(struct net_device *dev)
38756 +{
38757 +       return debug;
38758 +}
38759 +
38760 +static void netdev_set_msglevel(struct net_device *dev, u32 value)
38761 +{
38762 +       debug = value;
38763 +}
38764 +
38765 +static struct ethtool_ops netdev_ethtool_ops = {
38766 +       .get_drvinfo            = netdev_get_drvinfo,
38767 +       .get_settings           = netdev_get_settings,
38768 +       .set_settings           = netdev_set_settings,
38769 +       .nway_reset             = netdev_nway_reset,
38770 +       .get_link               = netdev_get_link,
38771 +       .get_msglevel           = netdev_get_msglevel,
38772 +       .set_msglevel           = netdev_set_msglevel,
38773 +       .get_sg                 = ethtool_op_get_sg,
38774 +       .get_tx_csum            = ethtool_op_get_tx_csum,
38775 +};
38776 +
38777  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
38778  {
38779         struct mii_ioctl_data *data = (struct mii_ioctl_data *)&rq->ifr_data;
38780         struct netdev_private *np = dev->priv;
38781  
38782         switch(cmd) {
38783 -       case SIOCETHTOOL:
38784 -               return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
38785         case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
38786                 data->phy_id = ((struct netdev_private *)dev->priv)->phys[0] & 0x1f;
38787                 /* Fall Through */
38788 diff -Nru a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c
38789 --- a/drivers/net/tulip/xircom_cb.c     Tue Aug 19 20:53:17 2003
38790 +++ b/drivers/net/tulip/xircom_cb.c     Tue Aug 26 14:52:05 2003
38791 @@ -175,37 +175,19 @@
38792  }
38793  #endif
38794  
38795 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
38796 +static void netdev_get_drvinfo(struct net_device *dev,
38797 +                              struct ethtool_drvinfo *info)
38798  {
38799 -       u32 ethcmd;
38800 -               
38801 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
38802 -               return -EFAULT;
38803 -       
38804 -       switch (ethcmd) {
38805 -       case ETHTOOL_GDRVINFO: {
38806 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
38807 -               strncpy(info.driver, "xircom_cb", sizeof(info.driver)-1);
38808 -               if (copy_to_user(useraddr, &info, sizeof(info)))
38809 -                       return -EFAULT;
38810 -               return 0;
38811 -       }
38812 -       }
38813 -       
38814 -       return -EOPNOTSUPP;
38815 -}
38816 +       struct xircom_private *private = dev->priv;
38817  
38818 -static int private_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
38819 -{
38820 -
38821 -       switch(cmd) {
38822 -       case SIOCETHTOOL:
38823 -              return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
38824 -       default:
38825 -               return -EOPNOTSUPP;
38826 -       }
38827 +       strcpy(info->driver, "xircom_cb");
38828 +       strcpy(info->bus_info, pci_name(private->pdev));
38829  }
38830  
38831 +static struct ethtool_ops netdev_ethtool_ops = {
38832 +       .get_drvinfo            = netdev_get_drvinfo,
38833 +};
38834 +
38835  /* xircom_probe is the code that gets called on device insertion.
38836     it sets up the hardware and registers the device to the networklayer.
38837     
38838 @@ -287,7 +269,7 @@
38839         dev->stop = &xircom_close;
38840         dev->get_stats = &xircom_get_stats;
38841         dev->priv = private;
38842 -       dev->do_ioctl = &private_ioctl;
38843 +       SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
38844         pci_set_drvdata(pdev, dev);
38845  
38846         
38847 diff -Nru a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
38848 --- a/drivers/net/via-rhine.c   Tue Aug 19 20:53:17 2003
38849 +++ b/drivers/net/via-rhine.c   Mon Sep  1 14:05:11 2003
38850 @@ -547,6 +547,7 @@
38851  static void via_rhine_set_rx_mode(struct net_device *dev);
38852  static struct net_device_stats *via_rhine_get_stats(struct net_device *dev);
38853  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
38854 +static struct ethtool_ops netdev_ethtool_ops;
38855  static int  via_rhine_close(struct net_device *dev);
38856  
38857  static inline u32 get_intr_status(struct net_device *dev)
38858 @@ -780,6 +781,7 @@
38859         dev->get_stats = via_rhine_get_stats;
38860         dev->set_multicast_list = via_rhine_set_rx_mode;
38861         dev->do_ioctl = netdev_ioctl;
38862 +       dev->ethtool_ops = &netdev_ethtool_ops;
38863         dev->tx_timeout = via_rhine_tx_timeout;
38864         dev->watchdog_timeo = TX_TIMEOUT;
38865         if (np->drv_flags & ReqTxAlign)
38866 @@ -1741,90 +1743,87 @@
38867         writeb(np->rx_thresh | rx_mode, ioaddr + RxConfig);
38868  }
38869  
38870 -static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
38871 +static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
38872  {
38873         struct netdev_private *np = dev->priv;
38874 -       u32 ethcmd;
38875  
38876 -       if (get_user(ethcmd, (u32 *)useraddr))
38877 -               return -EFAULT;
38878 +       strcpy (info->driver, DRV_NAME);
38879 +       strcpy (info->version, DRV_VERSION);
38880 +       strcpy (info->bus_info, pci_name(np->pdev));
38881 +}
38882  
38883 -       switch (ethcmd) {
38884 -       case ETHTOOL_GDRVINFO: {
38885 -               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
38886 -               strcpy (info.driver, DRV_NAME);
38887 -               strcpy (info.version, DRV_VERSION);
38888 -               strcpy (info.bus_info, pci_name(np->pdev));
38889 -               if (copy_to_user (useraddr, &info, sizeof (info)))
38890 -                       return -EFAULT;
38891 -               return 0;
38892 -       }
38893 +static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
38894 +{
38895 +       struct netdev_private *np = dev->priv;
38896 +       int rc;
38897  
38898 -       /* get settings */
38899 -       case ETHTOOL_GSET: {
38900 -               struct ethtool_cmd ecmd = { ETHTOOL_GSET };
38901 -               if (!(np->drv_flags & CanHaveMII))
38902 -                       break;
38903 -               spin_lock_irq(&np->lock);
38904 -               mii_ethtool_gset(&np->mii_if, &ecmd);
38905 -               spin_unlock_irq(&np->lock);
38906 -               if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
38907 -                       return -EFAULT;
38908 -               return 0;
38909 -       }
38910 -       /* set settings */
38911 -       case ETHTOOL_SSET: {
38912 -               int r;
38913 -               struct ethtool_cmd ecmd;
38914 -               if (!(np->drv_flags & CanHaveMII))
38915 -                       break;
38916 -               if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
38917 -                       return -EFAULT;
38918 -               spin_lock_irq(&np->lock);
38919 -               r = mii_ethtool_sset(&np->mii_if, &ecmd);
38920 -               spin_unlock_irq(&np->lock);
38921 -               return r;
38922 -       }
38923 -       /* restart autonegotiation */
38924 -       case ETHTOOL_NWAY_RST: {
38925 -               if (!(np->drv_flags & CanHaveMII))
38926 -                       break;
38927 -               return mii_nway_restart(&np->mii_if);
38928 -       }
38929 -       /* get link status */
38930 -       case ETHTOOL_GLINK: {
38931 -               struct ethtool_value edata = {ETHTOOL_GLINK};
38932 -               if (!(np->drv_flags & CanHaveMII))
38933 -                       break;
38934 -               edata.data = mii_link_ok(&np->mii_if);
38935 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
38936 -                       return -EFAULT;
38937 -               return 0;
38938 -       }
38939 -
38940 -       /* get message-level */
38941 -       case ETHTOOL_GMSGLVL: {
38942 -               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
38943 -               edata.data = debug;
38944 -               if (copy_to_user(useraddr, &edata, sizeof(edata)))
38945 -                       return -EFAULT;
38946 -               return 0;
38947 -       }
38948 -       /* set message-level */
38949 -       case ETHTOOL_SMSGLVL: {
38950 -               struct ethtool_value edata;
38951 -               if (copy_from_user(&edata, useraddr, sizeof(edata)))
38952 -                       return -EFAULT;
38953 -               debug = edata.data;
38954 -               return 0;
38955 -       }
38956 -       default:
38957 -               break;
38958 -       }
38959 +       if (!(np->drv_flags & CanHaveMII))
38960 +               return -EINVAL;
38961 +
38962 +       spin_lock_irq(&np->lock);
38963 +       rc = mii_ethtool_gset(&np->mii_if, cmd);
38964 +       spin_unlock_irq(&np->lock);
38965 +
38966 +       return rc;
38967 +}
38968 +
38969 +static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
38970 +{
38971 +       struct netdev_private *np = dev->priv;
38972 +       int rc;
38973 +
38974 +       if (!(np->drv_flags & CanHaveMII))
38975 +               return -EINVAL;
38976 +
38977 +       spin_lock_irq(&np->lock);
38978 +       rc = mii_ethtool_sset(&np->mii_if, cmd);
38979 +       spin_unlock_irq(&np->lock);
38980  
38981 -       return -EOPNOTSUPP;
38982 +       return rc;
38983  }
38984  
38985 +static int netdev_nway_reset(struct net_device *dev)
38986 +{
38987 +       struct netdev_private *np = dev->priv;
38988 +
38989 +       if (!(np->drv_flags & CanHaveMII))
38990 +               return -EINVAL;
38991 +
38992 +       return mii_nway_restart(&np->mii_if);
38993 +}
38994 +
38995 +static u32 netdev_get_link(struct net_device *dev)
38996 +{
38997 +       struct netdev_private *np = dev->priv;
38998 +
38999 +       if (!(np->drv_flags & CanHaveMII))
39000 +               return 0;       /* -EINVAL */
39001 +
39002 +       return mii_link_ok(&np->mii_if);
39003 +}
39004 +
39005 +static u32 netdev_get_msglevel(struct net_device *dev)
39006 +{
39007 +       return debug;
39008 +}
39009 +
39010 +static void netdev_set_msglevel(struct net_device *dev, u32 value)
39011 +{
39012 +       debug = value;
39013 +}
39014 +
39015 +static struct ethtool_ops netdev_ethtool_ops = {
39016 +       .get_drvinfo            = netdev_get_drvinfo,
39017 +       .get_settings           = netdev_get_settings,
39018 +       .set_settings           = netdev_set_settings,
39019 +       .nway_reset             = netdev_nway_reset,
39020 +       .get_link               = netdev_get_link,
39021 +       .get_msglevel           = netdev_get_msglevel,
39022 +       .set_msglevel           = netdev_set_msglevel,
39023 +       .get_sg                 = ethtool_op_get_sg,
39024 +       .get_tx_csum            = ethtool_op_get_tx_csum,
39025 +};
39026 +
39027  static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39028  {
39029         struct netdev_private *np = dev->priv;
39030 @@ -1834,14 +1833,9 @@
39031         if (!netif_running(dev))
39032                 return -EINVAL;
39033  
39034 -       if (cmd == SIOCETHTOOL)
39035 -               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
39036 -
39037 -       else {
39038 -               spin_lock_irq(&np->lock);
39039 -               rc = generic_mii_ioctl(&np->mii_if, data, cmd, NULL);
39040 -               spin_unlock_irq(&np->lock);
39041 -       }
39042 +       spin_lock_irq(&np->lock);
39043 +       rc = generic_mii_ioctl(&np->mii_if, data, cmd, NULL);
39044 +       spin_unlock_irq(&np->lock);
39045  
39046         return rc;
39047  }
39048 diff -Nru a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
39049 --- a/drivers/net/wan/cosa.c    Tue Aug 19 21:00:03 2003
39050 +++ b/drivers/net/wan/cosa.c    Fri Aug 29 22:32:28 2003
39051 @@ -632,7 +632,7 @@
39052  {
39053         sppp_detach(chan->pppdev.dev);
39054         unregister_netdev(chan->pppdev.dev);
39055 -       free_netdev(chan->ppp.dev);
39056 +       free_netdev(chan->pppdev.dev);
39057  }
39058  
39059  static int cosa_sppp_open(struct net_device *d)
39060 @@ -961,12 +961,12 @@
39061         unsigned long flags;
39062         int n;
39063  
39064 -       if ((n=minor(file->f_dentry->d_inode->i_rdev)>>CARD_MINOR_BITS)
39065 +       if ((n=iminor(file->f_dentry->d_inode)>>CARD_MINOR_BITS)
39066                 >= nr_cards)
39067                 return -ENODEV;
39068         cosa = cosa_cards+n;
39069  
39070 -       if ((n=minor(file->f_dentry->d_inode->i_rdev)
39071 +       if ((n=iminor(file->f_dentry->d_inode)
39072                 & ((1<<CARD_MINOR_BITS)-1)) >= cosa->nchannels)
39073                 return -ENODEV;
39074         chan = cosa->chan + n;
39075 @@ -1009,7 +1009,7 @@
39076  /* To be done ... */
39077  static int cosa_fasync(struct inode *inode, struct file *file, int on)
39078  {
39079 -        int port = MINOR(inode->i_rdev);
39080 +        int port = iminor(inode);
39081          int rv = fasync_helper(inode, file, on, &fasync[port]);
39082          return rv < 0 ? rv : 0;
39083  }
39084 diff -Nru a/drivers/net/wan/cycx_drv.c b/drivers/net/wan/cycx_drv.c
39085 --- a/drivers/net/wan/cycx_drv.c        Tue Jul 15 10:01:29 2003
39086 +++ b/drivers/net/wan/cycx_drv.c        Sat Aug 23 20:42:31 2003
39087 @@ -70,12 +70,12 @@
39088  static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len);
39089  static void cycx_bootcfg(struct cycx_hw *hw);
39090  
39091 -static int reset_cyc2x(u32 addr);
39092 -static int detect_cyc2x(u32 addr);
39093 +static int reset_cyc2x(void *addr);
39094 +static int detect_cyc2x(void *addr);
39095  
39096  /* Miscellaneous functions */
39097  static void delay_cycx(int sec);
39098 -static int get_option_index(u32 *optlist, u32 optval);
39099 +static int get_option_index(long *optlist, long optval);
39100  static u16 checksum(u8 *buf, u32 len);
39101  
39102  #define wait_cyc(addr) cycx_exec(addr + CMD_OFFSET)
39103 @@ -92,14 +92,14 @@
39104   * These are arrays of configuration options used by verification routines.
39105   * The first element of each array is its size (i.e. number of options).
39106   */
39107 -static u32 cyc2x_dpmbase_options[] = {
39108 +static long cyc2x_dpmbase_options[] = {
39109         20,
39110         0xA0000, 0xA4000, 0xA8000, 0xAC000, 0xB0000, 0xB4000, 0xB8000,
39111         0xBC000, 0xC0000, 0xC4000, 0xC8000, 0xCC000, 0xD0000, 0xD4000,
39112         0xD8000, 0xDC000, 0xE0000, 0xE4000, 0xE8000, 0xEC000
39113  };
39114  
39115 -static u32 cycx_2x_irq_options[]  = { 7, 3, 5, 9, 10, 11, 12, 15 };
39116 +static long cycx_2x_irq_options[]  = { 7, 3, 5, 9, 10, 11, 12, 15 };
39117  
39118  /* Kernel Loadable Module Entry Points */
39119  /* Module 'insert' entry point.
39120 @@ -137,7 +137,7 @@
39121  EXPORT_SYMBOL(cycx_setup);
39122  int cycx_setup(struct cycx_hw *hw, void *cfm, u32 len)
39123  {
39124 -       unsigned long dpmbase = hw->dpmbase;
39125 +       long dpmbase = (long)hw->dpmbase;
39126         int err;
39127  
39128         /* Verify IRQ configuration options */
39129 @@ -147,17 +147,17 @@
39130         }
39131  
39132         /* Setup adapter dual-port memory window and test memory */
39133 -       if (!hw->dpmbase) {
39134 +       if (!dpmbase) {
39135                 printk(KERN_ERR "%s: you must specify the dpm address!\n",
39136                                 modname);
39137                 return -EINVAL;
39138 -       } else if (!get_option_index(cyc2x_dpmbase_options, hw->dpmbase)) {
39139 +       } else if (!get_option_index(cyc2x_dpmbase_options, dpmbase)) {
39140                 printk(KERN_ERR "%s: memory address 0x%lX is invalid!\n",
39141                                 modname, dpmbase);
39142                 return -EINVAL;
39143         }
39144  
39145 -       hw->dpmbase = (u32)ioremap(dpmbase, CYCX_WINDOWSIZE);
39146 +       hw->dpmbase = ioremap(dpmbase, CYCX_WINDOWSIZE);
39147         hw->dpmsize = CYCX_WINDOWSIZE;
39148  
39149         if (!detect_cyc2x(hw->dpmbase)) {
39150 @@ -181,8 +181,7 @@
39151  EXPORT_SYMBOL(cycx_down);
39152  int cycx_down(struct cycx_hw *hw)
39153  {
39154 -       iounmap((u32 *)hw->dpmbase);
39155 -
39156 +       iounmap(hw->dpmbase);
39157         return 0;
39158  }
39159  
39160 @@ -204,7 +203,7 @@
39161   * o Set exec flag.
39162   * o Busy-wait until flag is reset. */
39163  EXPORT_SYMBOL(cycx_exec);
39164 -int cycx_exec(u32 addr)
39165 +int cycx_exec(void *addr)
39166  {
39167         u16 i = 0;
39168         /* wait till addr content is zeroed */
39169 @@ -250,7 +249,7 @@
39170  /* Load Aux Routines */
39171  /* Reset board hardware.
39172     return 1 if memory exists at addr and 0 if not. */
39173 -static int memory_exists(u32 addr)
39174 +static int memory_exists(void *addr)
39175  {
39176         int tries = 0;
39177  
39178 @@ -268,9 +267,9 @@
39179  }
39180  
39181  /* Load reset code. */
39182 -static void reset_load(u32 addr, u8 *buffer, u32 cnt)
39183 +static void reset_load(void *addr, u8 *buffer, u32 cnt)
39184  {
39185 -       u32 pt_code = addr + RESET_OFFSET;
39186 +       void *pt_code = addr + RESET_OFFSET;
39187         u16 i; /*, j; */
39188  
39189         for (i = 0 ; i < cnt ; i++) {
39190 @@ -282,7 +281,7 @@
39191  /* Load buffer using boot interface.
39192   * o copy data from buffer to Cyclom-X memory
39193   * o wait for reset code to copy it to right portion of memory */
39194 -static int buffer_load(u32 addr, u8 *buffer, u32 cnt)
39195 +static int buffer_load(void *addr, u8 *buffer, u32 cnt)
39196  {
39197         memcpy_toio(addr + DATA_OFFSET, buffer, cnt);
39198         writew(GEN_BOOT_DAT, addr + CMD_OFFSET);
39199 @@ -291,7 +290,7 @@
39200  }
39201  
39202  /* Set up entry point and kick start Cyclom-X CPU. */
39203 -static void cycx_start(u32 addr)
39204 +static void cycx_start(void *addr)
39205  {
39206         /* put in 0x30 offset the jump instruction to the code entry point */
39207         writeb(0xea, addr + 0x30);
39208 @@ -305,9 +304,9 @@
39209  }
39210  
39211  /* Load and boot reset code. */
39212 -static void cycx_reset_boot(u32 addr, u8 *code, u32 len)
39213 +static void cycx_reset_boot(void *addr, u8 *code, u32 len)
39214  {
39215 -       u32 pt_start = addr + START_OFFSET;
39216 +       void *pt_start = addr + START_OFFSET;
39217  
39218         writeb(0xea, pt_start++); /* jmp to f000:3f00 */
39219         writeb(0x00, pt_start++);
39220 @@ -322,9 +321,9 @@
39221  }
39222  
39223  /* Load data.bin file through boot (reset) interface. */
39224 -static int cycx_data_boot(u32 addr, u8 *code, u32 len)
39225 +static int cycx_data_boot(void *addr, u8 *code, u32 len)
39226  {
39227 -       u32 pt_boot_cmd = addr + CMD_OFFSET;
39228 +       void *pt_boot_cmd = addr + CMD_OFFSET;
39229         u32 i;
39230  
39231         /* boot buffer lenght */
39232 @@ -353,9 +352,9 @@
39233  
39234  
39235  /* Load code.bin file through boot (reset) interface. */
39236 -static int cycx_code_boot(u32 addr, u8 *code, u32 len)
39237 +static int cycx_code_boot(void *addr, u8 *code, u32 len)
39238  {
39239 -       u32 pt_boot_cmd = addr + CMD_OFFSET;
39240 +       void *pt_boot_cmd = addr + CMD_OFFSET;
39241         u32 i;
39242  
39243         /* boot buffer lenght */
39244 @@ -392,7 +391,7 @@
39245         u8 *reset_image,
39246            *data_image,
39247            *code_image;
39248 -       u32 pt_cycld = hw->dpmbase + 0x400;
39249 +       void *pt_cycld = hw->dpmbase + 0x400;
39250         u16 cksum;
39251  
39252         /* Announce */
39253 @@ -426,7 +425,7 @@
39254         if (cksum != cfm->checksum) {
39255                 printk(KERN_ERR "%s:%s: firmware corrupted!\n",
39256                                 modname, __FUNCTION__);
39257 -               printk(KERN_ERR " cdsize = 0x%x (expected 0x%lx)\n",
39258 +               printk(KERN_ERR " cdsize = 0x%lx (expected 0x%lx)\n",
39259                                 len - sizeof(struct cycx_firmware) - 1,
39260                                 cfm->info.codesize);
39261                 printk(KERN_ERR " chksum = 0x%x (expected 0x%x)\n",
39262 @@ -435,9 +434,7 @@
39263         }
39264  
39265         /* If everything is ok, set reset, data and code pointers */
39266 -
39267 -       img_hdr = (struct cycx_fw_header *)(((u8 *)cfm) +
39268 -                                           sizeof(struct cycx_firmware) - 1);
39269 +       img_hdr = (struct cycx_fw_header *)&cfm->image;
39270  #ifdef FIRMWARE_DEBUG
39271         printk(KERN_INFO "%s:%s: image sizes\n", __FUNCTION__, modname);
39272         printk(KERN_INFO " reset=%lu\n", img_hdr->reset_size);
39273 @@ -526,7 +523,7 @@
39274   *     Return 1 if detected o.k. or 0 if failed.
39275   *     Note:   This test is destructive! Adapter will be left in shutdown
39276   *             state after the test. */
39277 -static int detect_cyc2x(u32 addr)
39278 +static int detect_cyc2x(void *addr)
39279  {
39280         reset_cyc2x(addr);
39281  
39282 @@ -536,7 +533,7 @@
39283  /* Miscellaneous */
39284  /* Get option's index into the options list.
39285   *     Return option's index (1 .. N) or zero if option is invalid. */
39286 -static int get_option_index(u32 *optlist, u32 optval)
39287 +static int get_option_index(long *optlist, long optval)
39288  {
39289         int i = 1;
39290  
39291 @@ -548,7 +545,7 @@
39292  }
39293  
39294  /* Reset adapter's CPU. */
39295 -static int reset_cyc2x(u32 addr)
39296 +static int reset_cyc2x(void *addr)
39297  {
39298         writeb(0, addr + RST_ENABLE);
39299         delay_cycx(2);
39300 diff -Nru a/drivers/net/wan/cycx_main.c b/drivers/net/wan/cycx_main.c
39301 --- a/drivers/net/wan/cycx_main.c       Tue May 20 07:19:38 2003
39302 +++ b/drivers/net/wan/cycx_main.c       Sat Aug 23 20:36:33 2003
39303 @@ -223,7 +223,7 @@
39304         /* Configure hardware, load firmware, etc. */
39305         memset(&card->hw, 0, sizeof(card->hw));
39306         card->hw.irq     = irq;
39307 -       card->hw.dpmbase = conf->maddr;
39308 +       card->hw.dpmbase = (void *)conf->maddr;
39309         card->hw.dpmsize = CYCX_WINDOWSIZE;
39310         card->hw.fwid    = CFID_X25_2X;
39311         card->lock       = SPIN_LOCK_UNLOCKED;
39312 @@ -236,7 +236,7 @@
39313         /* Initialize WAN device data space */
39314         wandev->irq       = irq;
39315         wandev->dma       = wandev->ioport = 0;
39316 -       wandev->maddr     = card->hw.dpmbase;
39317 +       wandev->maddr     = (unsigned long)card->hw.dpmbase;
39318         wandev->msize     = card->hw.dpmsize;
39319         wandev->hw_opt[2] = 0;
39320         wandev->hw_opt[3] = card->hw.fwid;
39321 diff -Nru a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
39322 --- a/drivers/net/wireless/airo.c       Tue Aug 19 20:13:55 2003
39323 +++ b/drivers/net/wireless/airo.c       Sun Aug 31 16:14:06 2003
39324 @@ -81,12 +81,12 @@
39325  #endif
39326  
39327  /* Support Cisco MIC feature */
39328 -/* As this feature requires the AES encryption algorithm, it is not included
39329 -   in the kernel tree. If you want to enable it, you need to download the
39330 -   aes.h, aestab.h and mic.h files from the CVS at
39331 -   http://sf.net/projects/airo-linux/ Put the files in the same directory
39332 -   as airo.c and compile normally */
39333 +#define MICSUPPORT
39334 +
39335 +#if defined(MICSUPPORT) && !defined(CONFIG_CRYPTO)
39336 +#warning MIC support requires Crypto API
39337  #undef MICSUPPORT
39338 +#endif
39339  
39340  /* Hack to do some power saving */
39341  #define POWER_ON_DOWN
39342 @@ -615,14 +615,14 @@
39343         u16 arlDelay;
39344         u16 _reserved4[1];
39345         /*---------- Aironet Extensions ----------*/
39346 -       u16 magicAction;
39347 +       u8 magicAction;
39348  #define MAGIC_ACTION_STSCHG 1
39349  #define MACIC_ACTION_RESUME 2
39350  #define MAGIC_IGNORE_MCAST (1<<8)
39351  #define MAGIC_IGNORE_BCAST (1<<9)
39352  #define MAGIC_SWITCH_TO_PSP (0<<10)
39353  #define MAGIC_STAY_IN_CAM (1<<10)
39354 -       u16 magicControl;
39355 +       u8 magicControl;
39356         u16 autoWake;
39357  } ConfigRid;
39358  
39359 @@ -843,6 +843,7 @@
39360  #define AIROGMICRID            11
39361  #define AIROGMICSTATS          12
39362  #define AIROGFLAGS             13
39363 +#define AIRORRID               15
39364  
39365  /* Leave gap of 40 commands after AIROGSTATSD32 for future */
39366  
39367 @@ -994,6 +995,8 @@
39368  static int micsetup(struct airo_info *ai);
39369  static int encapsulate(struct airo_info *ai, etherHead *pPacket, MICBuffer *buffer, int len);
39370  static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *pPacket, u16 payLen);
39371 +
39372 +#include <linux/crypto.h>
39373  #endif
39374  
39375  struct airo_info {
39376 @@ -1063,9 +1066,12 @@
39377  #endif /* WIRELESS_SPY */
39378  #endif /* WIRELESS_EXT > 15 */
39379  #endif /* WIRELESS_EXT */
39380 +#ifdef MICSUPPORT
39381         /* MIC stuff */
39382 +       struct crypto_tfm       *tfm;
39383         mic_module              mod[2];
39384         mic_statistics          micstats;
39385 +#endif
39386  };
39387  
39388  static inline int bap_read(struct airo_info *ai, u16 *pu16Dst, int bytelen,
39389 @@ -1079,7 +1085,462 @@
39390                                 struct airo_info *apriv );
39391  
39392  #ifdef MICSUPPORT
39393 -#include "mic.h"
39394 +/***********************************************************************
39395 + *                              MIC ROUTINES                           *
39396 + ***********************************************************************
39397 + */
39398 +
39399 +static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSeq);
39400 +static void MoveWindow(miccntx *context, u32 micSeq);
39401 +void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct crypto_tfm *);
39402 +void emmh32_init(emmh32_context *context);
39403 +void emmh32_update(emmh32_context *context, u8 *pOctets, int len);
39404 +void emmh32_final(emmh32_context *context, u8 digest[4]);
39405 +
39406 +/* micinit - Initialize mic seed */
39407 +
39408 +static void micinit(struct airo_info *ai)
39409 +{
39410 +       MICRid mic_rid;
39411 +
39412 +       clear_bit(JOB_MIC, &ai->flags);
39413 +       PC4500_readrid(ai, RID_MIC, &mic_rid, sizeof(mic_rid), 0);
39414 +       up(&ai->sem);
39415 +
39416 +       ai->micstats.enabled = (mic_rid.state & 0x00FF) ? 1 : 0;
39417 +
39418 +       if (ai->micstats.enabled) {
39419 +               /* Key must be valid and different */
39420 +               if (mic_rid.multicastValid && (!ai->mod[0].mCtx.valid ||
39421 +                   (memcmp (ai->mod[0].mCtx.key, mic_rid.multicast,
39422 +                            sizeof(ai->mod[0].mCtx.key)) != 0))) {
39423 +                       /* Age current mic Context */
39424 +                       memcpy(&ai->mod[1].mCtx,&ai->mod[0].mCtx,sizeof(miccntx));
39425 +                       /* Initialize new context */
39426 +                       memcpy(&ai->mod[0].mCtx.key,mic_rid.multicast,sizeof(mic_rid.multicast));
39427 +                       ai->mod[0].mCtx.window  = 33; //Window always points to the middle
39428 +                       ai->mod[0].mCtx.rx      = 0;  //Rx Sequence numbers
39429 +                       ai->mod[0].mCtx.tx      = 0;  //Tx sequence numbers
39430 +                       ai->mod[0].mCtx.valid   = 1;  //Key is now valid
39431 +  
39432 +                       /* Give key to mic seed */
39433 +                       emmh32_setseed(&ai->mod[0].mCtx.seed,mic_rid.multicast,sizeof(mic_rid.multicast), ai->tfm);
39434 +               }
39435 +
39436 +               /* Key must be valid and different */
39437 +               if (mic_rid.unicastValid && (!ai->mod[0].uCtx.valid || 
39438 +                   (memcmp(ai->mod[0].uCtx.key, mic_rid.unicast,
39439 +                           sizeof(ai->mod[0].uCtx.key)) != 0))) {
39440 +                       /* Age current mic Context */
39441 +                       memcpy(&ai->mod[1].uCtx,&ai->mod[0].uCtx,sizeof(miccntx));
39442 +                       /* Initialize new context */
39443 +                       memcpy(&ai->mod[0].uCtx.key,mic_rid.unicast,sizeof(mic_rid.unicast));
39444 +       
39445 +                       ai->mod[0].uCtx.window  = 33; //Window always points to the middle
39446 +                       ai->mod[0].uCtx.rx      = 0;  //Rx Sequence numbers
39447 +                       ai->mod[0].uCtx.tx      = 0;  //Tx sequence numbers
39448 +                       ai->mod[0].uCtx.valid   = 1;  //Key is now valid
39449 +       
39450 +                       //Give key to mic seed
39451 +                       emmh32_setseed(&ai->mod[0].uCtx.seed, mic_rid.unicast, sizeof(mic_rid.unicast), ai->tfm);
39452 +               }
39453 +       } else {
39454 +      /* So next time we have a valid key and mic is enabled, we will update
39455 +       * the sequence number if the key is the same as before.
39456 +       */
39457 +               ai->mod[0].uCtx.valid = 0;
39458 +               ai->mod[0].mCtx.valid = 0;
39459 +       }
39460 +}
39461 +
39462 +/* micsetup - Get ready for business */
39463 +
39464 +static int micsetup(struct airo_info *ai) {
39465 +       int i;
39466 +
39467 +       if (ai->tfm == NULL)
39468 +               ai->tfm = crypto_alloc_tfm("aes", 0);
39469 +
39470 +        if (ai->tfm == NULL) {
39471 +                printk(KERN_ERR "airo: failed to load transform for AES\n");
39472 +                return ERROR;
39473 +        }
39474 +
39475 +       for (i=0; i < NUM_MODULES; i++) {
39476 +               memset(&ai->mod[i].mCtx,0,sizeof(miccntx));
39477 +               memset(&ai->mod[i].uCtx,0,sizeof(miccntx));
39478 +       }
39479 +       return SUCCESS;
39480 +}
39481 +
39482 +char micsnap[]= {0xAA,0xAA,0x03,0x00,0x40,0x96,0x00,0x02};
39483 +
39484 +/*===========================================================================
39485 + * Description: Mic a packet
39486 + *    
39487 + *      Inputs: etherHead * pointer to an 802.3 frame
39488 + *    
39489 + *     Returns: BOOLEAN if successful, otherwise false.
39490 + *             PacketTxLen will be updated with the mic'd packets size.
39491 + *
39492 + *    Caveats: It is assumed that the frame buffer will already
39493 + *             be big enough to hold the largets mic message possible.
39494 + *            (No memory allocation is done here).
39495 + *  
39496 + *    Author: sbraneky (10/15/01)
39497 + *    Merciless hacks by rwilcher (1/14/02)
39498 + */
39499 +
39500 +static int encapsulate(struct airo_info *ai ,etherHead *frame, MICBuffer *mic, int payLen)
39501 +{
39502 +       miccntx   *context;
39503 +
39504 +       // Determine correct context
39505 +       // If not adhoc, always use unicast key
39506 +
39507 +       if (test_bit(FLAG_ADHOC, &ai->flags) && (frame->da[0] & 0x1))
39508 +               context = &ai->mod[0].mCtx;
39509 +       else
39510 +               context = &ai->mod[0].uCtx;
39511 +  
39512 +       if (!context->valid)
39513 +               return ERROR;
39514 +
39515 +       mic->typelen = htons(payLen + 16); //Length of Mic'd packet
39516 +
39517 +       memcpy(&mic->u.snap, micsnap, sizeof(micsnap)); // Add Snap
39518 +
39519 +       // Add Tx sequence
39520 +       mic->seq = htonl(context->tx);
39521 +       context->tx += 2;
39522 +
39523 +       emmh32_init(&context->seed); // Mic the packet
39524 +       emmh32_update(&context->seed,frame->da,ETH_ALEN * 2); // DA,SA
39525 +       emmh32_update(&context->seed,(u8*)&mic->typelen,10); // Type/Length and Snap
39526 +       emmh32_update(&context->seed,(u8*)&mic->seq,sizeof(mic->seq)); //SEQ
39527 +       emmh32_update(&context->seed,frame->da + ETH_ALEN * 2,payLen); //payload
39528 +       emmh32_final(&context->seed, (u8*)&mic->mic);
39529 +
39530 +       /*    New Type/length ?????????? */
39531 +       mic->typelen = 0; //Let NIC know it could be an oversized packet
39532 +       return SUCCESS;
39533 +}
39534 +
39535 +typedef enum {
39536 +    NONE,
39537 +    NOMIC,
39538 +    NOMICPLUMMED,
39539 +    SEQUENCE,
39540 +    INCORRECTMIC,
39541 +} mic_error;
39542 +
39543 +/*===========================================================================
39544 + *  Description: Decapsulates a MIC'd packet and returns the 802.3 packet
39545 + *               (removes the MIC stuff) if packet is a valid packet.
39546 + *      
39547 + *       Inputs: etherHead  pointer to the 802.3 packet             
39548 + *     
39549 + *      Returns: BOOLEAN - TRUE if packet should be dropped otherwise FALSE
39550 + *     
39551 + *      Author: sbraneky (10/15/01)
39552 + *    Merciless hacks by rwilcher (1/14/02)
39553 + *---------------------------------------------------------------------------
39554 + */
39555 +
39556 +static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *eth, u16 payLen)
39557 +{
39558 +       int      i;
39559 +       u32      micSEQ;
39560 +       miccntx  *context;
39561 +       u8       digest[4];
39562 +       mic_error micError = NONE;
39563 +
39564 +       // Check if the packet is a Mic'd packet
39565 +
39566 +       if (!ai->micstats.enabled) {
39567 +               //No Mic set or Mic OFF but we received a MIC'd packet.
39568 +               if (memcmp ((u8*)eth + 14, micsnap, sizeof(micsnap)) == 0) {
39569 +                       ai->micstats.rxMICPlummed++;
39570 +                       return ERROR;
39571 +               }
39572 +               return SUCCESS;
39573 +       }
39574 +
39575 +       if (ntohs(mic->typelen) == 0x888E)
39576 +               return SUCCESS;
39577 +
39578 +       if (memcmp (mic->u.snap, micsnap, sizeof(micsnap)) != 0) {
39579 +           // Mic enabled but packet isn't Mic'd
39580 +               ai->micstats.rxMICPlummed++;
39581 +               return ERROR;
39582 +       }
39583 +
39584 +       micSEQ = ntohl(mic->seq);            //store SEQ as CPU order
39585 +
39586 +       //At this point we a have a mic'd packet and mic is enabled
39587 +       //Now do the mic error checking.
39588 +
39589 +       //Receive seq must be odd
39590 +       if ( (micSEQ & 1) == 0 ) {
39591 +               ai->micstats.rxWrongSequence++;
39592 +               return ERROR;
39593 +       }
39594 +
39595 +       for (i = 0; i < NUM_MODULES; i++) {
39596 +               int mcast = eth->da[0] & 1;
39597 +               //Determine proper context 
39598 +               context = mcast ? &ai->mod[i].mCtx : &ai->mod[i].uCtx;
39599 +       
39600 +               //Make sure context is valid
39601 +               if (!context->valid) {
39602 +                       if (i == 0)
39603 +                               micError = NOMICPLUMMED;
39604 +                       continue;                
39605 +               }
39606 +               //DeMic it 
39607 +
39608 +               if (!mic->typelen)
39609 +                       mic->typelen = htons(payLen + sizeof(MICBuffer) - 2);
39610 +       
39611 +               emmh32_init(&context->seed);
39612 +               emmh32_update(&context->seed, eth->da, ETH_ALEN*2); 
39613 +               emmh32_update(&context->seed, (u8 *)&mic->typelen, sizeof(mic->typelen)+sizeof(mic->u.snap)); 
39614 +               emmh32_update(&context->seed, (u8 *)&mic->seq,sizeof(mic->seq));        
39615 +               emmh32_update(&context->seed, eth->da + ETH_ALEN*2,payLen);     
39616 +               //Calculate MIC
39617 +               emmh32_final(&context->seed, digest);
39618 +       
39619 +               if (memcmp(digest, &mic->mic, 4)) { //Make sure the mics match
39620 +                 //Invalid Mic
39621 +                       if (i == 0)
39622 +                               micError = INCORRECTMIC;
39623 +                       continue;
39624 +               }
39625 +
39626 +               //Check Sequence number if mics pass
39627 +               if (RxSeqValid(ai, context, mcast, micSEQ) == SUCCESS) {
39628 +                       ai->micstats.rxSuccess++;
39629 +                       return SUCCESS;
39630 +               }
39631 +               if (i == 0)
39632 +                       micError = SEQUENCE;
39633 +       }
39634 +
39635 +       // Update statistics
39636 +       switch (micError) {
39637 +               case NOMICPLUMMED: ai->micstats.rxMICPlummed++;   break;
39638 +               case SEQUENCE:    ai->micstats.rxWrongSequence++; break;
39639 +               case INCORRECTMIC: ai->micstats.rxIncorrectMIC++; break;
39640 +               case NONE:  break;
39641 +               case NOMIC: break;
39642 +       }
39643 +       return ERROR;
39644 +}
39645 +
39646 +/*===========================================================================
39647 + * Description:  Checks the Rx Seq number to make sure it is valid
39648 + *               and hasn't already been received
39649 + *   
39650 + *     Inputs: miccntx - mic context to check seq against
39651 + *             micSeq  - the Mic seq number
39652 + *   
39653 + *    Returns: TRUE if valid otherwise FALSE. 
39654 + *
39655 + *    Author: sbraneky (10/15/01)
39656 + *    Merciless hacks by rwilcher (1/14/02)
39657 + *---------------------------------------------------------------------------
39658 + */
39659 +
39660 +static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSeq)
39661 +{
39662 +       u32 seq,index;
39663 +
39664 +       //Allow for the ap being rebooted - if it is then use the next 
39665 +       //sequence number of the current sequence number - might go backwards
39666 +
39667 +       if (mcast) {
39668 +               if (test_bit(FLAG_UPDATE_MULTI, &ai->flags)) {
39669 +                       clear_bit (FLAG_UPDATE_MULTI, &ai->flags);
39670 +                       context->window = (micSeq > 33) ? micSeq : 33;
39671 +                       context->rx     = 0;        // Reset rx
39672 +               }
39673 +       } else if (test_bit(FLAG_UPDATE_UNI, &ai->flags)) {
39674 +               clear_bit (FLAG_UPDATE_UNI, &ai->flags);
39675 +               context->window = (micSeq > 33) ? micSeq : 33; // Move window
39676 +               context->rx     = 0;        // Reset rx
39677 +       }
39678 +
39679 +       //Make sequence number relative to START of window
39680 +       seq = micSeq - (context->window - 33);
39681 +
39682 +       //Too old of a SEQ number to check.
39683 +       if ((u32)seq < 0)
39684 +               return ERROR;
39685 +    
39686 +       if ( seq > 64 ) {
39687 +               //Window is infinite forward
39688 +               MoveWindow(context,micSeq);
39689 +               return SUCCESS;
39690 +       }
39691 +
39692 +       // We are in the window. Now check the context rx bit to see if it was already sent
39693 +       seq >>= 1;         //divide by 2 because we only have odd numbers
39694 +       index = 1 << seq;  //Get an index number
39695 +
39696 +       if (!(context->rx & index)) {
39697 +               //micSEQ falls inside the window.
39698 +               //Add seqence number to the list of received numbers.
39699 +               context->rx |= index;
39700 +
39701 +               MoveWindow(context,micSeq);
39702 +
39703 +               return SUCCESS;
39704 +       }
39705 +       return ERROR;
39706 +}
39707 +
39708 +static void MoveWindow(miccntx *context, u32 micSeq)
39709 +{
39710 +       u32 shift;
39711 +
39712 +       //Move window if seq greater than the middle of the window
39713 +       if (micSeq > context->window) {
39714 +               shift = (micSeq - context->window) >> 1;
39715 +    
39716 +                   //Shift out old
39717 +               if (shift < 32)
39718 +                       context->rx >>= shift;
39719 +               else
39720 +                       context->rx = 0;
39721 +
39722 +               context->window = micSeq;      //Move window
39723 +       }
39724 +}
39725 +
39726 +/*==============================================*/
39727 +/*========== EMMH ROUTINES  ====================*/
39728 +/*==============================================*/
39729 +
39730 +/* mic accumulate */
39731 +#define MIC_ACCUM(val) \
39732 +       context->accum += (u64)(val) * context->coeff[coeff_position++];
39733 +
39734 +static unsigned char aes_counter[16];
39735 +
39736 +/* expand the key to fill the MMH coefficient array */
39737 +void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct crypto_tfm *tfm)
39738 +{
39739 +  /* take the keying material, expand if necessary, truncate at 16-bytes */
39740 +  /* run through AES counter mode to generate context->coeff[] */
39741 +  
39742 +       int i,j;
39743 +       u32 counter;
39744 +       u8 *cipher;
39745 +       struct scatterlist sg[1];
39746 +
39747 +       crypto_cipher_setkey(tfm, pkey, 16);
39748 +       counter = 0;
39749 +       for (i = 0; i < (sizeof(context->coeff)/sizeof(context->coeff[0])); ) {
39750 +               aes_counter[15] = (u8)(counter >> 0);
39751 +               aes_counter[14] = (u8)(counter >> 8);
39752 +               aes_counter[13] = (u8)(counter >> 16);
39753 +               aes_counter[12] = (u8)(counter >> 24);
39754 +               counter++;
39755 +               sg[0].page = virt_to_page(aes_counter);
39756 +               sg[0].offset = ((long) aes_counter & ~PAGE_MASK);
39757 +               sg[0].length = 16;
39758 +               crypto_cipher_encrypt(tfm, sg, sg, 16);
39759 +               cipher = kmap(sg[0].page) + sg[0].offset;
39760 +               for (j=0; (j<16) && (i< (sizeof(context->coeff)/sizeof(context->coeff[0]))); ) {
39761 +                       context->coeff[i++] = ntohl(*(u32 *)&cipher[j]);
39762 +                       j += 4;
39763 +               }
39764 +       }
39765 +}
39766 +
39767 +/* prepare for calculation of a new mic */
39768 +void emmh32_init(emmh32_context *context)
39769 +{
39770 +       /* prepare for new mic calculation */
39771 +       context->accum = 0;
39772 +       context->position = 0;
39773 +}
39774 +
39775 +/* add some bytes to the mic calculation */
39776 +void emmh32_update(emmh32_context *context, u8 *pOctets, int len)
39777 +{
39778 +       int     coeff_position, byte_position;
39779 +  
39780 +       if (len == 0) return;
39781 +  
39782 +       coeff_position = context->position >> 2;
39783 +  
39784 +       /* deal with partial 32-bit word left over from last update */
39785 +       byte_position = context->position & 3;
39786 +       if (byte_position) {
39787 +               /* have a partial word in part to deal with */
39788 +               do {
39789 +                       if (len == 0) return;
39790 +                       context->part.d8[byte_position++] = *pOctets++;
39791 +                       context->position++;
39792 +                       len--;
39793 +               } while (byte_position < 4);
39794 +               MIC_ACCUM(htonl(context->part.d32));
39795 +       }
39796 +
39797 +       /* deal with full 32-bit words */
39798 +       while (len >= 4) {
39799 +               MIC_ACCUM(htonl(*(u32 *)pOctets));
39800 +               context->position += 4;
39801 +               pOctets += 4;
39802 +               len -= 4;
39803 +       }
39804 +
39805 +       /* deal with partial 32-bit word that will be left over from this update */
39806 +       byte_position = 0;
39807 +       while (len > 0) {
39808 +               context->part.d8[byte_position++] = *pOctets++;
39809 +               context->position++;
39810 +               len--;
39811 +       }
39812 +}
39813 +
39814 +/* mask used to zero empty bytes for final partial word */
39815 +static u32 mask32[4] = { 0x00000000L, 0xFF000000L, 0xFFFF0000L, 0xFFFFFF00L };
39816 +
39817 +/* calculate the mic */
39818 +void emmh32_final(emmh32_context *context, u8 digest[4])
39819 +{
39820 +       int     coeff_position, byte_position;
39821 +       u32     val;
39822 +  
39823 +       u64 sum, utmp;
39824 +       s64 stmp;
39825 +
39826 +       coeff_position = context->position >> 2;
39827 +  
39828 +       /* deal with partial 32-bit word left over from last update */
39829 +       byte_position = context->position & 3;
39830 +       if (byte_position) {
39831 +               /* have a partial word in part to deal with */
39832 +               val = htonl(context->part.d32);
39833 +               MIC_ACCUM(val & mask32[byte_position]); /* zero empty bytes */
39834 +       }
39835 +
39836 +       /* reduce the accumulated u64 to a 32-bit MIC */
39837 +       sum = context->accum;
39838 +       stmp = (sum  & 0xffffffffLL) - ((sum >> 32)  * 15);
39839 +       utmp = (stmp & 0xffffffffLL) - ((stmp >> 32) * 15);
39840 +       sum = utmp & 0xffffffffLL;
39841 +       if (utmp > 0x10000000fLL)
39842 +               sum -= 15;
39843 +
39844 +       val = (u32)sum;
39845 +       digest[0] = (val>>24) & 0xFF;
39846 +       digest[1] = (val>>16) & 0xFF;
39847 +       digest[2] = (val>>8) & 0xFF;
39848 +       digest[3] = val & 0xFF;
39849 +}
39850  #endif
39851  
39852  static int readBSSListRid(struct airo_info *ai, int first,
39853 @@ -1556,6 +2017,7 @@
39854         struct sockaddr *addr = p;
39855         Resp rsp;
39856  
39857 +       readConfigRid(ai, 1);
39858         memcpy (ai->config.macAddr, addr->sa_data, dev->addr_len);
39859         ai->need_commit = 1;
39860         disable_MAC(ai, 1);
39861 @@ -1624,6 +2086,10 @@
39862                 /* PCMCIA frees this stuff, so only for PCI and ISA */
39863                 release_region( dev->base_addr, 64 );
39864          }
39865 +#ifdef MICSUPPORT
39866 +       if (ai->tfm)
39867 +               crypto_free_tfm(ai->tfm);
39868 +#endif
39869         del_airo_dev( dev );
39870         free_netdev( dev );
39871  }
39872 @@ -1725,6 +2191,9 @@
39873         ai->thr_pid = kernel_thread(airo_thread, dev, CLONE_FS | CLONE_FILES);
39874         if (ai->thr_pid < 0)
39875                 goto err_out_free;
39876 +#ifdef MICSUPPORT
39877 +       ai->tfm = NULL;
39878 +#endif
39879         rc = add_airo_dev( dev );
39880         if (rc)
39881                 goto err_out_thr;
39882 @@ -2125,146 +2594,149 @@
39883  
39884                         if (len > 2312) {
39885                                 printk( KERN_ERR "airo: Bad size %d\n", len );
39886 -                               len = 0;
39887 +                               goto badrx;
39888                         }
39889 -                       if (len) {
39890 -                               if (test_bit(FLAG_802_11, &apriv->flags)) {
39891 -                                       bap_read (apriv, (u16*)&fc, sizeof(fc), BAP0);
39892 -                                       fc = le16_to_cpu(fc);
39893 -                                       switch (fc & 0xc) {
39894 -                                               case 4:
39895 -                                                       if ((fc & 0xe0) == 0xc0)
39896 -                                                               hdrlen = 10;
39897 -                                                       else
39898 -                                                               hdrlen = 16;
39899 -                                                       break;
39900 -                                               case 8:
39901 -                                                       if ((fc&0x300)==0x300){
39902 -                                                               hdrlen = 30;
39903 -                                                               break;
39904 -                                                       }
39905 -                                               default:
39906 -                                                       hdrlen = 24;
39907 -                                       }
39908 -                               } else
39909 -                                       hdrlen = ETH_ALEN * 2;
39910 +                       if (len == 0)
39911 +                               goto badrx;
39912  
39913 -                               skb = dev_alloc_skb( len + hdrlen + 2 );
39914 -                               if ( !skb ) {
39915 -                                       apriv->stats.rx_dropped++;
39916 -                                       len = 0;
39917 -                               }
39918 -                       }
39919 -                       if (len) {
39920 -                               buffer = (u16*)skb_put (skb, len + hdrlen);
39921 -                               if (test_bit(FLAG_802_11, &apriv->flags)) {
39922 -                                       buffer[0] = fc;
39923 -                                       bap_read (apriv, buffer + 1, hdrlen - 2, BAP0);
39924 -                                       if (hdrlen == 24)
39925 -                                               bap_read (apriv, tmpbuf, 6, BAP0);
39926 -
39927 -                                       bap_read (apriv, &gap, sizeof(gap), BAP0);
39928 -                                       gap = le16_to_cpu(gap);
39929 -                                       if (gap) {
39930 -                                               if (gap <= 8)
39931 -                                                       bap_read (apriv, tmpbuf, gap, BAP0);
39932 +                       if (test_bit(FLAG_802_11, &apriv->flags)) {
39933 +                               bap_read (apriv, (u16*)&fc, sizeof(fc), BAP0);
39934 +                               fc = le16_to_cpu(fc);
39935 +                               switch (fc & 0xc) {
39936 +                                       case 4:
39937 +                                               if ((fc & 0xe0) == 0xc0)
39938 +                                                       hdrlen = 10;
39939                                                 else
39940 -                                                       printk(KERN_ERR "airo: gaplen too big. Problems will follow...\n");
39941 -                                       }
39942 -
39943 -
39944 -                                       bap_read (apriv, buffer + hdrlen/2, len, BAP0);
39945 -                               } else {
39946 -                                       MICBuffer micbuf;
39947 -                                       bap_read (apriv, buffer, ETH_ALEN*2, BAP0);
39948 -                                       if (apriv->micstats.enabled) {
39949 -                                               bap_read (apriv,(u16*)&micbuf,sizeof(micbuf),BAP0);
39950 -                                               if (ntohs(micbuf.typelen) > 0x05DC)
39951 -                                                       bap_setup (apriv, fid, 0x44, BAP0);
39952 -                                               else {
39953 -                                                       len -= sizeof(micbuf);
39954 -                                                       if (len < 48)
39955 -                                                               len = 48;
39956 -                                                       skb_trim (skb, len + hdrlen);
39957 +                                                       hdrlen = 16;
39958 +                                               break;
39959 +                                       case 8:
39960 +                                               if ((fc&0x300)==0x300){
39961 +                                                       hdrlen = 30;
39962 +                                                       break;
39963                                                 }
39964 -                                       }
39965 -                                       bap_read(apriv,buffer+ETH_ALEN,len,BAP0);
39966 +                                       default:
39967 +                                               hdrlen = 24;
39968 +                               }
39969 +                       } else
39970 +                               hdrlen = ETH_ALEN * 2;
39971 +
39972 +                       skb = dev_alloc_skb( len + hdrlen + 2 );
39973 +                       if ( !skb ) {
39974 +                               apriv->stats.rx_dropped++;
39975 +                               goto badrx;
39976 +                       }
39977 +                       buffer = (u16*)skb_put (skb, len + hdrlen);
39978 +                       if (test_bit(FLAG_802_11, &apriv->flags)) {
39979 +                               buffer[0] = fc;
39980 +                               bap_read (apriv, buffer + 1, hdrlen - 2, BAP0);
39981 +                               if (hdrlen == 24)
39982 +                                       bap_read (apriv, tmpbuf, 6, BAP0);
39983 +
39984 +                               bap_read (apriv, &gap, sizeof(gap), BAP0);
39985 +                               gap = le16_to_cpu(gap);
39986 +                               if (gap) {
39987 +                                       if (gap <= 8)
39988 +                                               bap_read (apriv, tmpbuf, gap, BAP0);
39989 +                                       else
39990 +                                               printk(KERN_ERR "airo: gaplen too big. Problems will follow...\n");
39991 +                               }
39992 +                               bap_read (apriv, buffer + hdrlen/2, len, BAP0);
39993 +                       } else {
39994 +#ifdef MICSUPPORT
39995 +                               MICBuffer micbuf;
39996 +#endif
39997 +                               bap_read (apriv, buffer, ETH_ALEN*2, BAP0);
39998  #ifdef MICSUPPORT
39999 -                                       if (decapsulate(apriv,&micbuf,(etherHead*)buffer,len)) {
40000 -                                               dev_kfree_skb_irq (skb);
40001 -                                               len = 0;
40002 +                               if (apriv->micstats.enabled) {
40003 +                                       bap_read (apriv,(u16*)&micbuf,sizeof(micbuf),BAP0);
40004 +                                       if (ntohs(micbuf.typelen) > 0x05DC)
40005 +                                               bap_setup (apriv, fid, 0x44, BAP0);
40006 +                                       else {
40007 +                                               if (len <= sizeof(micbuf))
40008 +                                                       goto badmic;
40009 +
40010 +                                               len -= sizeof(micbuf);
40011 +                                               skb_trim (skb, len + hdrlen);
40012                                         }
40013 +                               }
40014  #endif
40015 +                               bap_read(apriv,buffer+ETH_ALEN,len,BAP0);
40016 +#ifdef MICSUPPORT
40017 +                               if (decapsulate(apriv,&micbuf,(etherHead*)buffer,len)) {
40018 +badmic:
40019 +                                       dev_kfree_skb_irq (skb);
40020 +badrx:
40021 +                                       OUT4500( apriv, EVACK, EV_RX);
40022 +                                       goto exitrx;
40023                                 }
40024 +#endif
40025                         }
40026 -                       if (len) {
40027  #if WIRELESS_EXT > 15
40028  #ifdef IW_WIRELESS_SPY         /* defined in iw_handler.h */
40029 -                               if (apriv->spy_data.spy_number > 0) {
40030 -                                       char *sa;
40031 -                                       struct iw_quality wstats;
40032 -                                       /* Prepare spy data : addr + qual */
40033 -                                       if (!test_bit(FLAG_802_11, &apriv->flags)) {
40034 -                                               sa = (char*)buffer + 6;
40035 -                                               bap_setup (apriv, fid, 8, BAP0);
40036 -                                               bap_read (apriv, (u16*)hdr.rssi, 2, BAP0);
40037 -                                       } else
40038 -                                               sa = (char*)buffer + 10;
40039 -                                       wstats.qual = hdr.rssi[0];
40040 -                                       if (apriv->rssi)
40041 -                                               wstats.level = 0x100 - apriv->rssi[hdr.rssi[1]].rssidBm;
40042 -                                       else
40043 -                                               wstats.level = (hdr.rssi[1] + 321) / 2;
40044 -                                       wstats.updated = 3;     
40045 -                                       /* Update spy records */
40046 -                                       wireless_spy_update(dev, sa, &wstats);
40047 -                               }
40048 +                       if (apriv->spy_data.spy_number > 0) {
40049 +                               char *sa;
40050 +                               struct iw_quality wstats;
40051 +                               /* Prepare spy data : addr + qual */
40052 +                               if (!test_bit(FLAG_802_11, &apriv->flags)) {
40053 +                                       sa = (char*)buffer + 6;
40054 +                                       bap_setup (apriv, fid, 8, BAP0);
40055 +                                       bap_read (apriv, (u16*)hdr.rssi, 2, BAP0);
40056 +                               } else
40057 +                                       sa = (char*)buffer + 10;
40058 +                               wstats.qual = hdr.rssi[0];
40059 +                               if (apriv->rssi)
40060 +                                       wstats.level = 0x100 - apriv->rssi[hdr.rssi[1]].rssidBm;
40061 +                               else
40062 +                                       wstats.level = (hdr.rssi[1] + 321) / 2;
40063 +                               wstats.updated = 3;     
40064 +                               /* Update spy records */
40065 +                               wireless_spy_update(dev, sa, &wstats);
40066 +                       }
40067  #endif /* IW_WIRELESS_SPY */
40068  #else /* WIRELESS_EXT > 15 */
40069  #ifdef WIRELESS_SPY
40070 -                               if (apriv->spy_number > 0) {
40071 -                                       int i;
40072 -                                       char *sa;
40073 -
40074 -                                       sa = (char*)buffer + (test_bit(FLAG_802_11, &apriv->flags) ? 10 : 6);
40075 -
40076 -                                       for (i=0; i<apriv->spy_number; i++)
40077 -                                               if (!memcmp(sa,apriv->spy_address[i],ETH_ALEN))
40078 -                                               {
40079 -                                                       if (!test_bit(FLAG_802_11, &apriv->flags)) {
40080 -                                                               bap_setup (apriv, fid, 8, BAP0);
40081 -                                                               bap_read (apriv, (u16*)hdr.rssi, 2, BAP0);
40082 -                                                       }
40083 -                                                       apriv->spy_stat[i].qual = hdr.rssi[0];
40084 -                                                       if (apriv->rssi)
40085 -                                                               apriv->spy_stat[i].level = 0x100 - apriv->rssi[hdr.rssi[1]].rssidBm;
40086 -                                                       else
40087 -                                                               apriv->spy_stat[i].level = (hdr.rssi[1] + 321) / 2;
40088 -                                                       apriv->spy_stat[i].noise = 0;
40089 -                                                       apriv->spy_stat[i].updated = 3;
40090 -                                                       break;
40091 +                       if (apriv->spy_number > 0) {
40092 +                               int i;
40093 +                               char *sa;
40094 +
40095 +                               sa = (char*)buffer + (test_bit(FLAG_802_11, &apriv->flags) ? 10 : 6);
40096 +
40097 +                               for (i=0; i<apriv->spy_number; i++)
40098 +                                       if (!memcmp(sa,apriv->spy_address[i],ETH_ALEN))
40099 +                                       {
40100 +                                               if (!test_bit(FLAG_802_11, &apriv->flags)) {
40101 +                                                       bap_setup (apriv, fid, 8, BAP0);
40102 +                                                       bap_read (apriv, (u16*)hdr.rssi, 2, BAP0);
40103                                                 }
40104 -                               }
40105 +                                               apriv->spy_stat[i].qual = hdr.rssi[0];
40106 +                                               if (apriv->rssi)
40107 +                                                       apriv->spy_stat[i].level = 0x100 - apriv->rssi[hdr.rssi[1]].rssidBm;
40108 +                                               else
40109 +                                                       apriv->spy_stat[i].level = (hdr.rssi[1] + 321) / 2;
40110 +                                               apriv->spy_stat[i].noise = 0;
40111 +                                               apriv->spy_stat[i].updated = 3;
40112 +                                               break;
40113 +                                       }
40114 +                       }
40115  #endif /* WIRELESS_SPY  */
40116  #endif /* WIRELESS_EXT > 15 */
40117 -                               OUT4500( apriv, EVACK, EV_RX);
40118 +                       OUT4500( apriv, EVACK, EV_RX);
40119  
40120 -                               if (test_bit(FLAG_802_11, &apriv->flags)) {
40121 -                                       skb->mac.raw = skb->data;
40122 -                                       skb->pkt_type = PACKET_OTHERHOST;
40123 -                                       skb->dev = apriv->wifidev;
40124 -                                       skb->protocol = htons(ETH_P_802_2);
40125 -                               } else {
40126 -                                       skb->dev = dev;
40127 -                                       skb->protocol = eth_type_trans(skb,dev);
40128 -                               }
40129 -                               skb->dev->last_rx = jiffies;
40130 -                               skb->ip_summed = CHECKSUM_NONE;
40131 +                       if (test_bit(FLAG_802_11, &apriv->flags)) {
40132 +                               skb->mac.raw = skb->data;
40133 +                               skb->pkt_type = PACKET_OTHERHOST;
40134 +                               skb->dev = apriv->wifidev;
40135 +                               skb->protocol = htons(ETH_P_802_2);
40136 +                       } else {
40137 +                               skb->dev = dev;
40138 +                               skb->protocol = eth_type_trans(skb,dev);
40139 +                       }
40140 +                       skb->dev->last_rx = jiffies;
40141 +                       skb->ip_summed = CHECKSUM_NONE;
40142  
40143 -                               netif_rx( skb );
40144 -                       } else
40145 -                               OUT4500( apriv, EVACK, EV_RX);
40146 +                       netif_rx( skb );
40147                 }
40148 +exitrx:
40149  
40150                 /* Check to see if a packet has been transmitted */
40151                 if (  status & ( EV_TX|EV_TXEXC ) ) {
40152 @@ -2469,6 +2941,9 @@
40153                                 printk(KERN_WARNING "airo: unknown received signal level scale\n");
40154                 }
40155                 ai->config.opmode = adhoc ? MODE_STA_IBSS : MODE_STA_ESS;
40156 +               ai->config.authType = AUTH_OPEN;
40157 +               ai->config.modulation = MOD_CCK;
40158 +               ai->config._reserved1a[0] = 2; /* ??? */
40159  
40160  #ifdef MICSUPPORT
40161                 if ((cap_rid.len>=sizeof(cap_rid)) && (cap_rid.extSoftCap&1) &&
40162 @@ -2515,6 +2990,7 @@
40163                         memcpy(mySsid.ssids[i].ssid, ssids[i],
40164                                mySsid.ssids[i].len);
40165                 }
40166 +               mySsid.len = sizeof(mySsid);
40167         }
40168  
40169         status = writeConfigRid(ai, 1);
40170 @@ -3692,6 +4168,8 @@
40171                        offset < data->writelen ) offset++;
40172                 offset++;
40173         }
40174 +       if (i)
40175 +               SSID_rid.len = sizeof(SSID_rid);
40176         disable_MAC(ai, 1);
40177         writeSsidRid(ai, &SSID_rid);
40178         enable_MAC(ai, &rsp, 1);
40179 @@ -4156,7 +4634,7 @@
40180  
40181  static int __init airo_init_module( void )
40182  {
40183 -       int i, rc = 0, have_isa_dev = 0;
40184 +       int i, have_isa_dev = 0;
40185  
40186         airo_entry = create_proc_entry("aironet",
40187                                        S_IFDIR | airo_perm,
40188 @@ -4174,7 +4652,7 @@
40189  
40190  #ifdef CONFIG_PCI
40191         printk( KERN_INFO "airo:  Probing for PCI adapters\n" );
40192 -       rc = pci_module_init(&airo_driver);
40193 +       pci_module_init(&airo_driver);
40194         printk( KERN_INFO "airo:  Finished probing for PCI adapters\n" );
40195  #endif
40196  
40197 @@ -4197,8 +4675,11 @@
40198         }
40199         remove_proc_entry("aironet", proc_root_driver);
40200  
40201 -       if (is_pci)
40202 +       if (is_pci) {
40203 +#ifdef CONFIG_PCI
40204                 pci_unregister_driver(&airo_driver);
40205 +#endif
40206 +       }
40207  }
40208  
40209  #ifdef WIRELESS_EXT
40210 @@ -4260,6 +4741,7 @@
40211                         printk(KERN_DEBUG "%s: New channel value of %d is invalid!\n", dev->name, fwrq->m);
40212                         rc = -EINVAL;
40213                 } else {
40214 +                       readConfigRid(local, 1);
40215                         /* Yes ! We can set it !!! */
40216                         local->config.channelSet = (u16)(channel - 1);
40217                         local->need_commit = 1;
40218 @@ -4280,6 +4762,7 @@
40219         struct airo_info *local = dev->priv;
40220         StatusRid status_rid;           /* Card status info */
40221  
40222 +       readConfigRid(local, 1);
40223         if ((local->config.opmode & 0xFF) == MODE_STA_ESS)
40224                 status_rid.channel = local->config.channelSet;
40225         else
40226 @@ -4336,6 +4819,7 @@
40227                        sizeof(SSID_rid.ssids[index].ssid));
40228                 memcpy(SSID_rid.ssids[index].ssid, extra, dwrq->length);
40229                 SSID_rid.ssids[index].len = dwrq->length - 1;
40230 +               SSID_rid.len = sizeof(SSID_rid);
40231         }
40232         /* Write it to the card */
40233         disable_MAC(local, 1);
40234 @@ -4445,6 +4929,7 @@
40235         if(dwrq->length > 16 + 1) {
40236                 return -E2BIG;
40237         }
40238 +       readConfigRid(local, 1);
40239         memset(local->config.nodeName, 0, sizeof(local->config.nodeName));
40240         memcpy(local->config.nodeName, extra, dwrq->length);
40241         local->need_commit = 1;
40242 @@ -4463,6 +4948,7 @@
40243  {
40244         struct airo_info *local = dev->priv;
40245  
40246 +       readConfigRid(local, 1);
40247         strncpy(extra, local->config.nodeName, 16);
40248         extra[16] = '\0';
40249         dwrq->length = strlen(extra) + 1;
40250 @@ -4519,6 +5005,7 @@
40251                 return -EINVAL;
40252         }
40253  
40254 +       readConfigRid(local, 1);
40255         /* Now, check if we want a fixed or auto value */
40256         if(vwrq->fixed == 0) {
40257                 /* Fill all the rates up to this max rate */
40258 @@ -4555,6 +5042,7 @@
40259  
40260         vwrq->value = status_rid.currentXmitRate * 500000;
40261         /* If more than one rate, set auto */
40262 +       readConfigRid(local, 1);
40263         vwrq->fixed = (local->config.rates[1] == 0);
40264  
40265         return 0;
40266 @@ -4577,6 +5065,7 @@
40267         if((rthr < 0) || (rthr > 2312)) {
40268                 return -EINVAL;
40269         }
40270 +       readConfigRid(local, 1);
40271         local->config.rtsThres = rthr;
40272         local->need_commit = 1;
40273  
40274 @@ -4594,6 +5083,7 @@
40275  {
40276         struct airo_info *local = dev->priv;
40277  
40278 +       readConfigRid(local, 1);
40279         vwrq->value = local->config.rtsThres;
40280         vwrq->disabled = (vwrq->value >= 2312);
40281         vwrq->fixed = 1;
40282 @@ -4619,6 +5109,7 @@
40283                 return -EINVAL;
40284         }
40285         fthr &= ~0x1;   /* Get an even value - is it really needed ??? */
40286 +       readConfigRid(local, 1);
40287         local->config.fragThresh = (u16)fthr;
40288         local->need_commit = 1;
40289  
40290 @@ -4636,6 +5127,7 @@
40291  {
40292         struct airo_info *local = dev->priv;
40293  
40294 +       readConfigRid(local, 1);
40295         vwrq->value = local->config.fragThresh;
40296         vwrq->disabled = (vwrq->value >= 2312);
40297         vwrq->fixed = 1;
40298 @@ -4655,6 +5147,7 @@
40299         struct airo_info *local = dev->priv;
40300         int commit = 1;
40301  
40302 +       readConfigRid(local, 1);
40303         if ((local->config.rmode & 0xff) >= RXMODE_RFMON)
40304                 commit = 2;
40305  
40306 @@ -4714,6 +5207,7 @@
40307  {
40308         struct airo_info *local = dev->priv;
40309  
40310 +       readConfigRid(local, 1);
40311         /* If not managed, assume it's ad-hoc */
40312         switch (local->config.opmode & 0xFF) {
40313                 case MODE_STA_ESS:
40314 @@ -4750,6 +5244,7 @@
40315         if(!(cap_rid.softCap & 2)) {
40316                 return -EOPNOTSUPP;
40317         } */
40318 +       readConfigRid(local, 1);
40319  
40320         /* Basic checking: do we have a key to set ?
40321          * Note : with the new API, it's impossible to get a NULL pointer.
40322 @@ -4836,6 +5331,7 @@
40323         if(!(cap_rid.softCap & 2)) {
40324                 return -EOPNOTSUPP;
40325         }
40326 +       readConfigRid(local, 1);
40327         /* Check encryption mode */
40328         switch(local->config.authType)  {
40329                 case AUTH_ENCRYPT:
40330 @@ -4892,6 +5388,7 @@
40331         clear_bit (FLAG_RADIO_OFF, &local->flags);
40332         for (i = 0; cap_rid.txPowerLevels[i] && (i < 8); i++)
40333                 if ((vwrq->value==cap_rid.txPowerLevels[i])) {
40334 +                       readConfigRid(local, 1);
40335                         local->config.txPower = vwrq->value;
40336                         local->need_commit = 1;
40337                         rc = -EINPROGRESS;      /* Call commit handler */
40338 @@ -4911,6 +5408,7 @@
40339  {
40340         struct airo_info *local = dev->priv;
40341  
40342 +       readConfigRid(local, 1);
40343         vwrq->value = local->config.txPower;
40344         vwrq->fixed = 1;        /* No power control */
40345         vwrq->disabled = test_bit(FLAG_RADIO_OFF, &local->flags);
40346 @@ -4934,6 +5432,7 @@
40347         if(vwrq->disabled) {
40348                 return -EINVAL;
40349         }
40350 +       readConfigRid(local, 1);
40351         if(vwrq->flags & IW_RETRY_LIMIT) {
40352                 if(vwrq->flags & IW_RETRY_MAX)
40353                         local->config.longRetryLimit = vwrq->value;
40354 @@ -4968,6 +5467,7 @@
40355  
40356         vwrq->disabled = 0;      /* Can't be disabled */
40357  
40358 +       readConfigRid(local, 1);
40359         /* Note : by default, display the min retry number */
40360         if((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
40361                 vwrq->flags = IW_RETRY_LIFETIME;
40362 @@ -5106,6 +5606,7 @@
40363  {
40364         struct airo_info *local = dev->priv;
40365  
40366 +       readConfigRid(local, 1);
40367         if (vwrq->disabled) {
40368                 if ((local->config.rmode & 0xFF) >= RXMODE_RFMON) {
40369                         return -EINVAL;
40370 @@ -5162,6 +5663,7 @@
40371  {
40372         struct airo_info *local = dev->priv;
40373  
40374 +       readConfigRid(local, 1);
40375         int mode = local->config.powerSaveMode;
40376         if ((vwrq->disabled = (mode == POWERSAVE_CAM)))
40377                 return 0;
40378 @@ -5191,6 +5693,7 @@
40379  {
40380         struct airo_info *local = dev->priv;
40381  
40382 +       readConfigRid(local, 1);
40383         local->config.rssiThreshold = vwrq->disabled ? RSSI_DEFAULT : vwrq->value;
40384         local->need_commit = 1;
40385  
40386 @@ -5208,6 +5711,7 @@
40387  {
40388         struct airo_info *local = dev->priv;
40389  
40390 +       readConfigRid(local, 1);
40391         vwrq->value = local->config.rssiThreshold;
40392         vwrq->disabled = (vwrq->value == 0);
40393         vwrq->fixed = 1;
40394 @@ -6017,7 +6521,7 @@
40395  
40396                 /* Separate R/W functions bracket legality here
40397                  */
40398 -               if ( com.command <= AIROGMICSTATS )
40399 +               if ( com.command <= AIRORRID )
40400                         rc = readrids(dev,&com);
40401                 else if ( com.command >= AIROPCAP && com.command <= AIROPLEAPUSR )
40402                         rc = writerids(dev,&com);
40403 @@ -6107,6 +6611,7 @@
40404  static int readrids(struct net_device *dev, aironet_ioctl *comp) {
40405         unsigned short ridcode;
40406         unsigned char *iobuf;
40407 +       int len;
40408         struct airo_info *ai = dev->priv;
40409  
40410         if (test_bit(FLAG_FLASHING, &ai->flags))
40411 @@ -6134,11 +6639,14 @@
40412         case AIROGSTAT:     ridcode = RID_STATUS;       break;
40413         case AIROGSTATSD32: ridcode = RID_STATSDELTA;   break;
40414         case AIROGSTATSC32: ridcode = RID_STATS;        break;
40415 +#ifdef MICSUPPORT
40416         case AIROGMICSTATS:
40417                 if (copy_to_user(comp->data, &ai->micstats,
40418                                  min((int)comp->len,(int)sizeof(ai->micstats))))
40419                         return -EFAULT;
40420                 return 0;
40421 +#endif
40422 +       case AIRORRID:      ridcode = comp->len;        break;
40423         default:
40424                 return -EINVAL;
40425                 break;
40426 @@ -6152,9 +6660,12 @@
40427          * then return it to the user
40428          * 9/22/2000 Honor user given length
40429          */
40430 +       if (comp->command == AIRORRID)
40431 +               len = le16_to_cpu(*(unsigned short *)iobuf); /* Yuck! */
40432 +       else
40433 +               len = comp->len;
40434  
40435 -       if (copy_to_user(comp->data, iobuf,
40436 -                        min((int)comp->len, (int)RIDS_SIZE))) {
40437 +       if (copy_to_user(comp->data, iobuf, min(len, (int)RIDS_SIZE))) {
40438                 kfree (iobuf);
40439                 return -EFAULT;
40440         }
40441 @@ -6222,9 +6733,11 @@
40442  
40443                 PC4500_readrid(ai,RID_STATSDELTACLEAR,iobuf,RIDS_SIZE, 1);
40444  
40445 +#ifdef MICSUPPORT
40446                 enabled = ai->micstats.enabled;
40447                 memset(&ai->micstats,0,sizeof(ai->micstats));
40448                 ai->micstats.enabled = enabled;
40449 +#endif
40450  
40451                 if (copy_to_user(comp->data, iobuf,
40452                                  min((int)comp->len, (int)RIDS_SIZE))) {
40453 diff -Nru a/drivers/net/wireless/airport.c b/drivers/net/wireless/airport.c
40454 --- a/drivers/net/wireless/airport.c    Tue Aug 19 20:53:17 2003
40455 +++ b/drivers/net/wireless/airport.c    Mon Aug 25 09:51:43 2003
40456 @@ -25,8 +25,6 @@
40457  #include <linux/if_arp.h>
40458  #include <linux/etherdevice.h>
40459  #include <linux/wireless.h>
40460 -#include <linux/adb.h>
40461 -#include <linux/pmu.h>
40462  
40463  #include <asm/io.h>
40464  #include <asm/system.h>
40465 @@ -48,96 +46,115 @@
40466         int ndev_registered;
40467  };
40468  
40469 -#ifdef CONFIG_PMAC_PBOOK
40470 -static int airport_sleep_notify(struct pmu_sleep_notifier *self, int when);
40471 -static struct pmu_sleep_notifier airport_sleep_notifier = {
40472 -       airport_sleep_notify, SLEEP_LEVEL_NET,
40473 -};
40474 -#endif
40475 +static int
40476 +airport_suspend(struct macio_dev *mdev, u32 state)
40477 +{
40478 +       struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
40479 +       struct orinoco_private *priv = dev->priv;
40480 +       struct airport *card = priv->card;
40481 +       unsigned long flags;
40482 +       int err;
40483 +
40484 +       printk(KERN_DEBUG "%s: Airport entering sleep mode\n", dev->name);
40485 +
40486 +       err = orinoco_lock(priv, &flags);
40487 +       if (err) {
40488 +               printk(KERN_ERR "%s: hw_unavailable on PBOOK_SLEEP_NOW\n",
40489 +                      dev->name);
40490 +               return 0;
40491 +       }
40492 +
40493 +       err = __orinoco_down(dev);
40494 +       if (err)
40495 +               printk(KERN_WARNING "%s: PBOOK_SLEEP_NOW: Error %d downing interface\n",
40496 +                      dev->name, err);
40497  
40498 -/*
40499 - * Function prototypes
40500 - */
40501 +       netif_device_detach(dev);
40502  
40503 -static struct net_device *airport_attach(struct device_node *of_node);
40504 -static void airport_detach(struct net_device *dev);
40505 +       priv->hw_unavailable++;
40506  
40507 -static struct net_device *airport_dev;
40508 +       orinoco_unlock(priv, &flags);
40509 +
40510 +       disable_irq(dev->irq);
40511 +       pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 0);
40512 +
40513 +       return 0;
40514 +}
40515  
40516 -#ifdef CONFIG_PMAC_PBOOK
40517  static int
40518 -airport_sleep_notify(struct pmu_sleep_notifier *self, int when)
40519 +airport_resume(struct macio_dev *mdev)
40520  {
40521 -       struct net_device *dev = airport_dev;
40522 +       struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
40523         struct orinoco_private *priv = dev->priv;
40524         struct airport *card = priv->card;
40525         unsigned long flags;
40526         int err;
40527 -       
40528 -       if (! airport_dev)
40529 -               return PBOOK_SLEEP_OK;
40530 -
40531 -       switch (when) {
40532 -       case PBOOK_SLEEP_NOW:
40533 -               printk(KERN_DEBUG "%s: Airport entering sleep mode\n", dev->name);
40534 -
40535 -               err = orinoco_lock(priv, &flags);
40536 -               if (err) {
40537 -                       printk(KERN_ERR "%s: hw_unavailable on PBOOK_SLEEP_NOW\n",
40538 -                              dev->name);
40539 -                       break;
40540 -               }
40541  
40542 -               err = __orinoco_down(dev);
40543 -               if (err)
40544 -                       printk(KERN_WARNING "%s: PBOOK_SLEEP_NOW: Error %d downing interface\n",
40545 -                              dev->name, err);
40546 +       printk(KERN_DEBUG "%s: Airport waking up\n", dev->name);
40547  
40548 -               netif_device_detach(dev);
40549 +       pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 1);
40550 +       mdelay(200);
40551  
40552 -               priv->hw_unavailable++;
40553 +       enable_irq(dev->irq);
40554  
40555 -               orinoco_unlock(priv, &flags);
40556 +       err = orinoco_reinit_firmware(dev);
40557 +       if (err) {
40558 +               printk(KERN_ERR "%s: Error %d re-initializing firmware on PBOOK_WAKE\n",
40559 +                      dev->name, err);
40560 +               return 0;
40561 +       }
40562  
40563 -               disable_irq(dev->irq);
40564 -               pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 0);
40565 -               break;
40566 +       spin_lock_irqsave(&priv->lock, flags);
40567  
40568 -       case PBOOK_WAKE:
40569 -               printk(KERN_DEBUG "%s: Airport waking up\n", dev->name);
40570 -               pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 1);
40571 -               mdelay(200);
40572 +       netif_device_attach(dev);
40573  
40574 -               enable_irq(dev->irq);
40575 +       priv->hw_unavailable--;
40576  
40577 -               err = orinoco_reinit_firmware(dev);
40578 -               if (err) {
40579 -                       printk(KERN_ERR "%s: Error %d re-initializing firmware on PBOOK_WAKE\n",
40580 +       if (priv->open && (! priv->hw_unavailable)) {
40581 +               err = __orinoco_up(dev);
40582 +               if (err)
40583 +                       printk(KERN_ERR "%s: Error %d restarting card on PBOOK_WAKE\n",
40584                                dev->name, err);
40585 -                       break;
40586 -               }
40587 +       }
40588  
40589 -               spin_lock_irqsave(&priv->lock, flags);
40590  
40591 -               netif_device_attach(dev);
40592 +       spin_unlock_irqrestore(&priv->lock, flags);
40593  
40594 -               priv->hw_unavailable--;
40595 +       return 0;
40596 +}
40597  
40598 -               if (priv->open && (! priv->hw_unavailable)) {
40599 -                       err = __orinoco_up(dev);
40600 -                       if (err)
40601 -                               printk(KERN_ERR "%s: Error %d restarting card on PBOOK_WAKE\n",
40602 -                                      dev->name, err);
40603 -               }
40604 +static int
40605 +airport_detach(struct macio_dev *mdev)
40606 +{
40607 +       struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
40608 +       struct orinoco_private *priv = dev->priv;
40609 +       struct airport *card = priv->card;
40610  
40611 +       if (card->ndev_registered)
40612 +               unregister_netdev(dev);
40613 +       card->ndev_registered = 0;
40614  
40615 -               spin_unlock_irqrestore(&priv->lock, flags);
40616 +       if (card->irq_requested)
40617 +               free_irq(dev->irq, dev);
40618 +       card->irq_requested = 0;
40619  
40620 -               break;
40621 -       }
40622 -       return PBOOK_SLEEP_OK;
40623 +       if (card->vaddr)
40624 +               iounmap(card->vaddr);
40625 +       card->vaddr = 0;
40626 +
40627 +       dev->base_addr = 0;
40628 +
40629 +       release_OF_resource(card->node, 0);
40630 +
40631 +       pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 0);
40632 +       current->state = TASK_UNINTERRUPTIBLE;
40633 +       schedule_timeout(HZ);
40634 +
40635 +       dev_set_drvdata(&mdev->ofdev.dev, NULL);
40636 +       free_netdev(dev);
40637 +
40638 +       return 0;
40639  }
40640 -#endif /* CONFIG_PMAC_PBOOK */
40641  
40642  static int airport_hard_reset(struct orinoco_private *priv)
40643  {
40644 @@ -170,25 +187,26 @@
40645         return 0;
40646  }
40647  
40648 -static struct net_device *
40649 -airport_attach(struct device_node *of_node)
40650 +static int
40651 +airport_attach(struct macio_dev *mdev, const struct of_match *match)
40652  {
40653         struct orinoco_private *priv;
40654         struct net_device *dev;
40655         struct airport *card;
40656         unsigned long phys_addr;
40657 +       struct device_node *of_node = mdev->ofdev.node;
40658         hermes_t *hw;
40659  
40660         if (of_node->n_addrs < 1 || of_node->n_intrs < 1) {
40661                 printk(KERN_ERR "airport: wrong interrupt/addresses in OF tree\n");
40662 -               return NULL;
40663 +               return -ENODEV;
40664         }
40665  
40666         /* Allocate space for private device-specific data */
40667         dev = alloc_orinocodev(sizeof(*card), airport_hard_reset);
40668         if (! dev) {
40669                 printk(KERN_ERR "airport: can't allocate device datas\n");
40670 -               return NULL;
40671 +               return -ENODEV;
40672         }
40673         priv = dev->priv;
40674         card = priv->card;
40675 @@ -199,11 +217,14 @@
40676         if (! request_OF_resource(of_node, 0, " (airport)")) {
40677                 printk(KERN_ERR "airport: can't request IO resource !\n");
40678                 kfree(dev);
40679 -               return NULL;
40680 +               return -ENODEV;
40681         }
40682  
40683         dev->name[0] = '\0';    /* register_netdev will give us an ethX name */
40684         SET_MODULE_OWNER(dev);
40685 +       SET_NETDEV_DEV(dev, &mdev->ofdev.dev);
40686 +
40687 +       dev_set_drvdata(&mdev->ofdev.dev, dev);
40688  
40689         /* Setup interrupts & base address */
40690         dev->irq = of_node->intrs[0].line;
40691 @@ -240,79 +261,50 @@
40692         }
40693         printk(KERN_DEBUG "airport: card registered for interface %s\n", dev->name);
40694         card->ndev_registered = 1;
40695 -
40696 -#ifdef CONFIG_PMAC_PBOOK
40697 -       pmu_register_sleep_notifier(&airport_sleep_notifier);
40698 -#endif
40699 -       return dev;
40700 -       
40701 +       return 0;
40702   failed:
40703 -       airport_detach(dev);
40704 -       return NULL;
40705 +       airport_detach(mdev);
40706 +       return -ENODEV;
40707  }                              /* airport_attach */
40708  
40709 -/*======================================================================
40710 -  This deletes a driver "instance".  
40711 -  ======================================================================*/
40712 -
40713 -static void
40714 -airport_detach(struct net_device *dev)
40715 -{
40716 -       struct orinoco_private *priv = dev->priv;
40717 -       struct airport *card = priv->card;
40718 -
40719 -#ifdef CONFIG_PMAC_PBOOK
40720 -       pmu_unregister_sleep_notifier(&airport_sleep_notifier);
40721 -#endif
40722 -       if (card->ndev_registered)
40723 -               unregister_netdev(dev);
40724 -       card->ndev_registered = 0;
40725 -
40726 -       if (card->irq_requested)
40727 -               free_irq(dev->irq, dev);
40728 -       card->irq_requested = 0;
40729 -
40730 -       if (card->vaddr)
40731 -               iounmap(card->vaddr);
40732 -       card->vaddr = 0;
40733 -
40734 -       dev->base_addr = 0;
40735 -
40736 -       release_OF_resource(card->node, 0);
40737 -
40738 -       pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 0);
40739 -       current->state = TASK_UNINTERRUPTIBLE;
40740 -       schedule_timeout(HZ);
40741 -
40742 -       free_netdev(dev);
40743 -}                              /* airport_detach */
40744  
40745  static char version[] __initdata = "airport.c 0.13e (Benjamin Herrenschmidt <benh@kernel.crashing.org>)";
40746  MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
40747  MODULE_DESCRIPTION("Driver for the Apple Airport wireless card.");
40748  MODULE_LICENSE("Dual MPL/GPL");
40749  
40750 +static struct of_match airport_match[] = 
40751 +{
40752 +       {
40753 +       .name           = "radio",
40754 +       .type           = OF_ANY_MATCH,
40755 +       .compatible     = OF_ANY_MATCH
40756 +       },
40757 +       {},
40758 +};
40759 +
40760 +static struct macio_driver airport_driver = 
40761 +{
40762 +       .name           = "airport",
40763 +       .match_table    = airport_match,
40764 +       .probe          = airport_attach,
40765 +       .remove         = airport_detach,
40766 +       .suspend        = airport_suspend,
40767 +       .resume         = airport_resume,
40768 +};
40769 +
40770  static int __init
40771  init_airport(void)
40772  {
40773 -       struct device_node *airport_node;
40774 -
40775         printk(KERN_DEBUG "%s\n", version);
40776  
40777 -       /* Lookup card in device tree */
40778 -       airport_node = find_devices("radio");
40779 -       if (airport_node && !strcmp(airport_node->parent->name, "mac-io"))
40780 -               airport_dev = airport_attach(airport_node);
40781 -
40782 -       return airport_dev ? 0 : -ENODEV;
40783 +       return macio_register_driver(&airport_driver);
40784  }
40785  
40786  static void __exit
40787  exit_airport(void)
40788  {
40789 -       if (airport_dev)
40790 -               airport_detach(airport_dev);
40791 -       airport_dev = NULL;
40792 +       return macio_unregister_driver(&airport_driver);
40793  }
40794  
40795  module_init(init_airport);
40796 diff -Nru a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
40797 --- a/drivers/net/wireless/ray_cs.c     Thu Aug  7 09:17:57 2003
40798 +++ b/drivers/net/wireless/ray_cs.c     Tue Aug 26 14:55:20 2003
40799 @@ -105,6 +105,9 @@
40800  static struct net_device_stats *ray_get_stats(struct net_device *dev);
40801  static int ray_dev_init(struct net_device *dev);
40802  static int ray_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
40803 +
40804 +static struct ethtool_ops netdev_ethtool_ops;
40805 +
40806  static int ray_open(struct net_device *dev);
40807  static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev);
40808  static void set_multicast_list(struct net_device *dev);
40809 @@ -408,6 +411,7 @@
40810      dev->set_config = &ray_dev_config;
40811      dev->get_stats  = &ray_get_stats;
40812      dev->do_ioctl = &ray_dev_ioctl;
40813 +    SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
40814  #if WIRELESS_EXT > 7   /* If wireless extension exist in the kernel */
40815      dev->get_wireless_stats = ray_get_wireless_stats;
40816  #endif
40817 @@ -1226,26 +1230,16 @@
40818  
40819  /*===========================================================================*/
40820  
40821 -static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
40822 +static void netdev_get_drvinfo(struct net_device *dev,
40823 +                              struct ethtool_drvinfo *info)
40824  {
40825 -       u32 ethcmd;
40826 -               
40827 -       if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
40828 -               return -EFAULT;
40829 -       
40830 -       switch (ethcmd) {
40831 -       case ETHTOOL_GDRVINFO: {
40832 -               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
40833 -               strncpy(info.driver, "ray_cs", sizeof(info.driver)-1);
40834 -               if (copy_to_user(useraddr, &info, sizeof(info)))
40835 -                       return -EFAULT;
40836 -               return 0;
40837 -       }
40838 -       }
40839 -       
40840 -       return -EOPNOTSUPP;
40841 +       strcpy(info->driver, "ray_cs");
40842  }
40843  
40844 +static struct ethtool_ops netdev_ethtool_ops = {
40845 +       .get_drvinfo            = netdev_get_drvinfo,
40846 +};
40847 +
40848  /*====================================================================*/
40849  
40850  static int ray_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40851 @@ -1265,10 +1259,6 @@
40852      /* Validate the command */
40853      switch (cmd)
40854      {
40855 -    case SIOCETHTOOL:
40856 -      err = netdev_ethtool_ioctl(dev, (void *) ifr->ifr_data);
40857 -      break;
40858 -
40859  #if WIRELESS_EXT > 7
40860        /* --------------- WIRELESS EXTENSIONS --------------- */
40861        /* Get name */
40862 diff -Nru a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
40863 --- a/drivers/net/yellowfin.c   Tue Aug 19 20:53:17 2003
40864 +++ b/drivers/net/yellowfin.c   Sun Aug 31 06:34:16 2003
40865 @@ -873,8 +873,6 @@
40866         /* Calculate the next Tx descriptor entry. */
40867         entry = yp->cur_tx % TX_RING_SIZE;
40868  
40869 -       yp->tx_skbuff[entry] = skb;
40870 -
40871         if (gx_fix) {   /* Note: only works for paddable protocols e.g.  IP. */
40872                 int cacheline_end = ((unsigned long)skb->data + skb->len) % 32;
40873                 /* Fix GX chipset errata. */
40874 @@ -889,6 +887,8 @@
40875                         return 0;
40876                 }
40877         }
40878 +       yp->tx_skbuff[entry] = skb;
40879 +
40880  #ifdef NO_TXSTATS
40881         yp->tx_ring[entry].addr = cpu_to_le32(pci_map_single(yp->pci_dev, 
40882                 skb->data, len, PCI_DMA_TODEVICE));
40883 diff -Nru a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
40884 --- a/drivers/parport/parport_pc.c      Thu Jul 31 08:59:04 2003
40885 +++ b/drivers/parport/parport_pc.c      Sun Aug 31 16:14:16 2003
40886 @@ -93,7 +93,7 @@
40887         int dma;
40888  } superios[NR_SUPERIOS] __devinitdata = { {0,},};
40889  
40890 -static int user_specified __devinitdata = 0;
40891 +static int user_specified;
40892  #if defined(CONFIG_PARPORT_PC_SUPERIO) || \
40893         (defined(CONFIG_PARPORT_1284) && defined(CONFIG_PARPORT_PC_FIFO))
40894  static int verbose_probing;
40895 diff -Nru a/drivers/pci/pci.ids b/drivers/pci/pci.ids
40896 --- a/drivers/pci/pci.ids       Wed Aug  6 12:32:59 2003
40897 +++ b/drivers/pci/pci.ids       Thu Aug 28 00:24:56 2003
40898 @@ -3247,7 +3247,8 @@
40899                 1148 5061  SK-9861 V2.0 Gigabit Ethernet 1000Base-SX Adapter
40900                 1148 5071  SK-9871 V2.0 Gigabit Ethernet 1000Base-ZX Adapter
40901                 1148 9521  SK-9521 10/100/1000Base-T Adapter
40902 -       4400  Gigabit Ethernet
40903 +       4400 SK-9Dxx Gigabit Ethernet Adapter
40904 +       4500 SK-9Mxx Gigabit Ethernet Adapter
40905  1149  Win System Corporation
40906  114a  VMIC
40907         5579  VMIPCI-5579 (Reflective Memory Card)
40908 @@ -5313,9 +5314,12 @@
40909                 1166 1648  NetXtreme CIOB-E 1000Base-T
40910         164d  NetXtreme BCM5702FE Gigabit Ethernet
40911         1653  NetXtreme BCM5705 Gigabit Ethernet
40912 +       1654  NetXtreme BCM5705 Gigabit Ethernet
40913         165d  NetXtreme BCM5705M Gigabit Ethernet
40914 +       165e  NetXtreme BCM5705M Gigabit Ethernet
40915         1696  NetXtreme BCM5782 Gigabit Ethernet
40916                 14e4 000d  NetXtreme BCM5782 1000Base-T
40917 +       169c  NetXtreme BCM5788 Gigabit Ethernet
40918         16a6  NetXtreme BCM5702 Gigabit Ethernet
40919                 0e11 00bb  NC7760 Gigabit Server Adapter (PCI-X, 10/100/1000-T)
40920                 1028 0126  BCM5702 1000Base-T
40921 @@ -5337,6 +5341,8 @@
40922         16c7  NetXtreme BCM5703 Gigabit Ethernet
40923                 14e4 0009  NetXtreme BCM5703 1000Base-T
40924                 14e4 000a  NetXtreme BCM5703 1000Base-SX
40925 +       170d  NetXtreme BCM5901 Gigabit Ethernet
40926 +       170e  NetXtreme BCM5901 Gigabit Ethernet
40927         4210  BCM4210 iLine10 HomePNA 2.0
40928         4211  BCM4211 iLine10 HomePNA 2.0 + V.90 56k modem
40929         4212  BCM4212 v.90 56k modem
40930 @@ -5877,6 +5883,8 @@
40931         03e8  AC1000 Gigabit Ethernet
40932         03e9  AC1001 Gigabit Ethernet
40933         03ea  AC9100 Gigabit Ethernet
40934 +               173b 0001  AC1002
40935 +       03eb  AC1003 Gigabit Ethernet
40936  1743  Peppercon AG
40937         8139  ROL/F-100 Fast Ethernet Adapter with ROL
40938  174b  PC Partner Limited
40939 diff -Nru a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
40940 --- a/drivers/pcmcia/cistpl.c   Sun Jul  6 16:03:10 2003
40941 +++ b/drivers/pcmcia/cistpl.c   Wed Aug 27 13:25:31 2003
40942 @@ -293,15 +293,17 @@
40943  #endif
40944         ret = read_cis_mem(s, attr, addr, len, ptr);
40945  
40946 -    /* Copy data into the cache */
40947 -    cis = kmalloc(sizeof(struct cis_cache_entry) + len, GFP_KERNEL);
40948 -    if (cis) {
40949 -       cis->addr = addr;
40950 -       cis->len = len;
40951 -       cis->attr = attr;
40952 -       memcpy(cis->cache, ptr, len);
40953 -       list_add(&cis->node, &s->cis_cache);
40954 -    }
40955 +       if (ret == 0) {
40956 +               /* Copy data into the cache */
40957 +               cis = kmalloc(sizeof(struct cis_cache_entry) + len, GFP_KERNEL);
40958 +               if (cis) {
40959 +                       cis->addr = addr;
40960 +                       cis->len = len;
40961 +                       cis->attr = attr;
40962 +                       memcpy(cis->cache, ptr, len);
40963 +                       list_add(&cis->node, &s->cis_cache);
40964 +               }
40965 +       }
40966  }
40967  
40968  static void
40969 diff -Nru a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
40970 --- a/drivers/pcmcia/ds.c       Mon Jun 16 13:20:14 2003
40971 +++ b/drivers/pcmcia/ds.c       Tue Aug 26 09:25:41 2003
40972 @@ -495,7 +495,7 @@
40973  
40974  static int ds_open(struct inode *inode, struct file *file)
40975  {
40976 -    socket_t i = minor(inode->i_rdev);
40977 +    socket_t i = iminor(inode);
40978      struct pcmcia_bus_socket *s;
40979      user_info_t *user;
40980  
40981 @@ -529,7 +529,7 @@
40982  
40983  static int ds_release(struct inode *inode, struct file *file)
40984  {
40985 -    socket_t i = minor(inode->i_rdev);
40986 +    socket_t i = iminor(inode);
40987      struct pcmcia_bus_socket *s;
40988      user_info_t *user, **link;
40989  
40990 @@ -563,7 +563,7 @@
40991  static ssize_t ds_read(struct file *file, char *buf,
40992                        size_t count, loff_t *ppos)
40993  {
40994 -    socket_t i = minor(file->f_dentry->d_inode->i_rdev);
40995 +    socket_t i = iminor(file->f_dentry->d_inode);
40996      struct pcmcia_bus_socket *s;
40997      user_info_t *user;
40998  
40999 @@ -594,7 +594,7 @@
41000  static ssize_t ds_write(struct file *file, const char *buf,
41001                         size_t count, loff_t *ppos)
41002  {
41003 -    socket_t i = minor(file->f_dentry->d_inode->i_rdev);
41004 +    socket_t i = iminor(file->f_dentry->d_inode);
41005      struct pcmcia_bus_socket *s;
41006      user_info_t *user;
41007  
41008 @@ -629,7 +629,7 @@
41009  /* No kernel lock - fine */
41010  static u_int ds_poll(struct file *file, poll_table *wait)
41011  {
41012 -    socket_t i = minor(file->f_dentry->d_inode->i_rdev);
41013 +    socket_t i = iminor(file->f_dentry->d_inode);
41014      struct pcmcia_bus_socket *s;
41015      user_info_t *user;
41016  
41017 @@ -653,7 +653,7 @@
41018  static int ds_ioctl(struct inode * inode, struct file * file,
41019                     u_int cmd, u_long arg)
41020  {
41021 -    socket_t i = minor(inode->i_rdev);
41022 +    socket_t i = iminor(inode);
41023      struct pcmcia_bus_socket *s;
41024      u_int size;
41025      int ret, err;
41026 diff -Nru a/drivers/pcmcia/ricoh.h b/drivers/pcmcia/ricoh.h
41027 --- a/drivers/pcmcia/ricoh.h    Mon Jul 14 07:42:47 2003
41028 +++ b/drivers/pcmcia/ricoh.h    Wed Aug 27 12:42:52 2003
41029 @@ -142,59 +142,61 @@
41030          config_writeb(socket, RL5C4XX_MISC_CONTROL, reg);
41031  }
41032  
41033 -static void ricoh_set_zv(struct pcmcia_socket *sock)
41034 +static void ricoh_set_zv(struct yenta_socket *socket)
41035  {
41036 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
41037          if(socket->dev->vendor == PCI_VENDOR_ID_RICOH)
41038          {
41039                  switch(socket->dev->device)
41040                  {
41041                          /* There may be more .. */
41042                 case  PCI_DEVICE_ID_RICOH_RL5C478:
41043 -                       sock->zoom_video = ricoh_zoom_video;
41044 +                       socket->socket.zoom_video = ricoh_zoom_video;
41045                         break;  
41046                  }
41047          }
41048  }
41049  
41050 -static int ricoh_init(struct pcmcia_socket *sock)
41051 +static void ricoh_save_state(struct yenta_socket *socket)
41052  {
41053 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
41054 -       yenta_init(sock);
41055 -       ricoh_set_zv(sock);
41056 +       rl_misc(socket) = config_readw(socket, RL5C4XX_MISC);
41057 +       rl_ctl(socket) = config_readw(socket, RL5C4XX_16BIT_CTL);
41058 +       rl_io(socket) = config_readw(socket, RL5C4XX_16BIT_IO_0);
41059 +       rl_mem(socket) = config_readw(socket, RL5C4XX_16BIT_MEM_0);
41060 +       rl_config(socket) = config_readw(socket, RL5C4XX_CONFIG);
41061 +}
41062  
41063 +static void ricoh_restore_state(struct yenta_socket *socket)
41064 +{
41065         config_writew(socket, RL5C4XX_MISC, rl_misc(socket));
41066         config_writew(socket, RL5C4XX_16BIT_CTL, rl_ctl(socket));
41067         config_writew(socket, RL5C4XX_16BIT_IO_0, rl_io(socket));
41068         config_writew(socket, RL5C4XX_16BIT_MEM_0, rl_mem(socket));
41069         config_writew(socket, RL5C4XX_CONFIG, rl_config(socket));
41070 -       
41071 -       return 0;
41072  }
41073  
41074  
41075  /*
41076 - * Magic Ricoh initialization code.. Save state at
41077 - * beginning, re-initialize it after suspend.
41078 + * Magic Ricoh initialization code..
41079   */
41080  static int ricoh_override(struct yenta_socket *socket)
41081  {
41082 -       rl_misc(socket) = config_readw(socket, RL5C4XX_MISC);
41083 -       rl_ctl(socket) = config_readw(socket, RL5C4XX_16BIT_CTL);
41084 -       rl_io(socket) = config_readw(socket, RL5C4XX_16BIT_IO_0);
41085 -       rl_mem(socket) = config_readw(socket, RL5C4XX_16BIT_MEM_0);
41086 -       rl_config(socket) = config_readw(socket, RL5C4XX_CONFIG);
41087 +       u16 config, ctl;
41088 +
41089 +       config = config_readw(socket, RL5C4XX_CONFIG);
41090  
41091         /* Set the default timings, don't trust the original values */
41092 -       rl_ctl(socket) = RL5C4XX_16CTL_IO_TIMING | RL5C4XX_16CTL_MEM_TIMING;
41093 +       ctl = RL5C4XX_16CTL_IO_TIMING | RL5C4XX_16CTL_MEM_TIMING;
41094  
41095         if(socket->dev->device < PCI_DEVICE_ID_RICOH_RL5C475) {
41096 -               rl_ctl(socket) |= RL5C46X_16CTL_LEVEL_1 | RL5C46X_16CTL_LEVEL_2;
41097 +               ctl |= RL5C46X_16CTL_LEVEL_1 | RL5C46X_16CTL_LEVEL_2;
41098         } else {
41099 -               rl_config(socket) |= RL5C4XX_CONFIG_PREFETCH;
41100 +               config |= RL5C4XX_CONFIG_PREFETCH;
41101         }
41102  
41103 -       socket->socket.ops->init = ricoh_init;
41104 +       config_writew(socket, RL5C4XX_16BIT_CTL, ctl);
41105 +       config_writew(socket, RL5C4XX_CONFIG, config);
41106 +
41107 +       ricoh_set_zv(socket);
41108  
41109         return 0;
41110  }
41111 diff -Nru a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c
41112 --- a/drivers/pcmcia/sa1111_generic.c   Sun Jun 15 04:35:08 2003
41113 +++ b/drivers/pcmcia/sa1111_generic.c   Sun Aug 24 07:45:05 2003
41114 @@ -16,6 +16,7 @@
41115  
41116  #include <asm/hardware.h>
41117  #include <asm/hardware/sa1111.h>
41118 +#include <asm/io.h>
41119  #include <asm/irq.h>
41120  
41121  #include "sa1111_generic.h"
41122 @@ -118,16 +119,15 @@
41123         sa11xx_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
41124  }
41125  
41126 -static int pcmcia_probe(struct device *dev)
41127 +static int pcmcia_probe(struct sa1111_dev *dev)
41128  {
41129 -       struct sa1111_dev *sadev = SA1111_DEV(dev);
41130         char *base;
41131  
41132 -       if (!request_mem_region(sadev->res.start, 512,
41133 -                               SA1111_DRIVER_NAME(sadev)))
41134 +       if (!request_mem_region(dev->res.start, 512,
41135 +                               SA1111_DRIVER_NAME(dev)))
41136                 return -EBUSY;
41137  
41138 -       base = sadev->mapbase;
41139 +       base = dev->mapbase;
41140  
41141         /*
41142          * Initialise the suspend state.
41143 @@ -136,61 +136,68 @@
41144         sa1111_writel(PCCR_S0_FLT | PCCR_S1_FLT, base + SA1111_PCCR);
41145  
41146  #ifdef CONFIG_SA1100_ADSBITSY
41147 -       pcmcia_adsbitsy_init(dev);
41148 +       pcmcia_adsbitsy_init(&dev->dev);
41149  #endif
41150  #ifdef CONFIG_SA1100_BADGE4
41151 -       pcmcia_badge4_init(dev);
41152 +       pcmcia_badge4_init(&dev->dev);
41153  #endif
41154  #ifdef CONFIG_SA1100_GRAPHICSMASTER
41155 -       pcmcia_graphicsmaster_init(dev);
41156 +       pcmcia_graphicsmaster_init(&dev->dev);
41157  #endif
41158  #ifdef CONFIG_SA1100_JORNADA720
41159 -       pcmcia_jornada720_init(dev);
41160 +       pcmcia_jornada720_init(&dev->dev);
41161  #endif
41162  #ifdef CONFIG_ASSABET_NEPONSET
41163 -       pcmcia_neponset_init(dev);
41164 +       pcmcia_neponset_init(&dev->dev);
41165  #endif
41166  #ifdef CONFIG_SA1100_PFS168
41167 -       pcmcia_pfs_init(dev);
41168 +       pcmcia_pfs_init(&dev->dev);
41169  #endif
41170  #ifdef CONFIG_SA1100_PT_SYSTEM3
41171 -       pcmcia_system3_init(dev);
41172 +       pcmcia_system3_init(&dev->dev);
41173  #endif
41174  #ifdef CONFIG_SA1100_XP860
41175 -       pcmcia_xp860_init(dev);
41176 +       pcmcia_xp860_init(&dev->dev);
41177  #endif
41178         return 0;
41179  }
41180  
41181 -static int __devexit pcmcia_remove(struct device *dev)
41182 +static int __devexit pcmcia_remove(struct sa1111_dev *dev)
41183  {
41184 -       struct sa1111_dev *sadev = SA1111_DEV(dev);
41185 -
41186 -       sa11xx_drv_pcmcia_remove(dev);
41187 -       release_mem_region(sadev->res.start, 512);
41188 +       sa11xx_drv_pcmcia_remove(&dev->dev);
41189 +       release_mem_region(dev->res.start, 512);
41190         return 0;
41191  }
41192  
41193 +static int pcmcia_suspend(struct sa1111_dev *dev, u32 state)
41194 +{
41195 +       return pcmcia_socket_dev_suspend(&dev->dev, state, SUSPEND_SAVE_STATE);
41196 +}
41197 +
41198 +static int pcmcia_resume(struct sa1111_dev *dev)
41199 +{
41200 +       return pcmcia_socket_dev_resume(&dev->dev, RESUME_RESTORE_STATE);
41201 +}
41202 +
41203  static struct sa1111_driver pcmcia_driver = {
41204         .drv = {
41205 -               .name           = "sa1111-pcmcia",
41206 -               .bus            = &sa1111_bus_type,
41207 -               .probe          = pcmcia_probe,
41208 -               .remove         = __devexit_p(pcmcia_remove),
41209 -               .suspend        = pcmcia_socket_dev_suspend,
41210 -               .resume         = pcmcia_socket_dev_resume,
41211 +               .name   = "sa1111-pcmcia",
41212         },
41213 -       .devid                  = SA1111_DEVID_PCMCIA,
41214 +       .devid          = SA1111_DEVID_PCMCIA,
41215 +       .probe          = pcmcia_probe,
41216 +       .remove         = __devexit_p(pcmcia_remove),
41217 +       .suspend        = pcmcia_suspend,
41218 +       .resume         = pcmcia_resume,
41219  };
41220  
41221  static int __init sa1111_drv_pcmcia_init(void)
41222  {
41223 -       return driver_register(&pcmcia_driver.drv);
41224 +       return sa1111_driver_register(&pcmcia_driver);
41225  }
41226  
41227  static void __exit sa1111_drv_pcmcia_exit(void)
41228  {
41229 -       driver_unregister(&pcmcia_driver.drv);
41230 +       sa1111_driver_unregister(&pcmcia_driver);
41231  }
41232  
41233  module_init(sa1111_drv_pcmcia_init);
41234 diff -Nru a/drivers/pcmcia/ti113x.h b/drivers/pcmcia/ti113x.h
41235 --- a/drivers/pcmcia/ti113x.h   Wed Aug  6 15:59:05 2003
41236 +++ b/drivers/pcmcia/ti113x.h   Wed Aug 27 12:58:54 2003
41237 @@ -136,16 +136,34 @@
41238  
41239  #ifdef CONFIG_CARDBUS
41240  
41241 -static int ti_intctl(struct yenta_socket *socket)
41242 +/*
41243 + * Texas Instruments CardBus controller overrides.
41244 + */
41245 +#define ti_sysctl(socket)      ((socket)->private[0])
41246 +#define ti_cardctl(socket)     ((socket)->private[1])
41247 +#define ti_devctl(socket)      ((socket)->private[2])
41248 +#define ti_diag(socket)                ((socket)->private[3])
41249 +#define ti_irqmux(socket)      ((socket)->private[4])
41250 +
41251 +/*
41252 + * These are the TI specific power management handlers.
41253 + */
41254 +static void ti_save_state(struct yenta_socket *socket)
41255  {
41256 -       u8 new, reg = exca_readb(socket, I365_INTCTL);
41257 +       ti_sysctl(socket) = config_readl(socket, TI113X_SYSTEM_CONTROL);
41258 +       ti_irqmux(socket) = config_readl(socket, TI122X_IRQMUX);
41259 +       ti_cardctl(socket) = config_readb(socket, TI113X_CARD_CONTROL);
41260 +       ti_devctl(socket) = config_readb(socket, TI113X_DEVICE_CONTROL);
41261 +       ti_diag(socket) = config_readb(socket, TI1250_DIAGNOSTIC);
41262 +}
41263  
41264 -       new = reg & ~I365_INTR_ENA;
41265 -       if (socket->cb_irq)
41266 -               new |= I365_INTR_ENA;
41267 -       if (new != reg)
41268 -               exca_writeb(socket, I365_INTCTL, new);
41269 -       return 0;
41270 +static void ti_restore_state(struct yenta_socket *socket)
41271 +{
41272 +       config_writel(socket, TI113X_SYSTEM_CONTROL, ti_sysctl(socket));
41273 +       config_writel(socket, TI122X_IRQMUX, ti_irqmux(socket));
41274 +       config_writeb(socket, TI113X_CARD_CONTROL, ti_cardctl(socket));
41275 +       config_writeb(socket, TI113X_DEVICE_CONTROL, ti_devctl(socket));
41276 +       config_writeb(socket, TI1250_DIAGNOSTIC, ti_diag(socket));
41277  }
41278  
41279  /*
41280 @@ -185,8 +203,8 @@
41281  
41282         ti_zoom_video(sock, onoff);
41283  
41284 -       reg = config_readb(socket, 0x84);
41285 -       reg |= (1<<7);  /* ZV bus enable */
41286 +       reg = config_readb(socket, TI1250_MULTIMEDIA_CTL);
41287 +       reg |= TI1250_MMC_ZVOUTEN;      /* ZV bus enable */
41288  
41289         if(PCI_FUNC(socket->dev->devfn)==1)
41290                 shift = 1;
41291 @@ -204,12 +222,11 @@
41292                 reg &= ~(1<<shift);     /* Socket zoon video off */
41293         }
41294  
41295 -       config_writeb(socket, 0x84, reg);
41296 +       config_writeb(socket, TI1250_MULTIMEDIA_CTL, reg);
41297  }
41298  
41299 -static void ti_set_zv(struct pcmcia_socket *sock)
41300 +static void ti_set_zv(struct yenta_socket *socket)
41301  {
41302 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
41303         if(socket->dev->vendor == PCI_VENDOR_ID_TI)
41304         {
41305                 switch(socket->dev->device)
41306 @@ -218,24 +235,16 @@
41307                         case PCI_DEVICE_ID_TI_1220:
41308                         case PCI_DEVICE_ID_TI_1221:
41309                         case PCI_DEVICE_ID_TI_1225:
41310 -                               sock->zoom_video = ti_zoom_video;
41311 +                               socket->socket.zoom_video = ti_zoom_video;
41312                                 break;  
41313                         case PCI_DEVICE_ID_TI_1250:
41314                         case PCI_DEVICE_ID_TI_1251A:
41315                         case PCI_DEVICE_ID_TI_1251B:
41316                         case PCI_DEVICE_ID_TI_1450:
41317 -                               sock->zoom_video = ti1250_zoom_video;
41318 +                               socket->socket.zoom_video = ti1250_zoom_video;
41319                 }
41320         }
41321  }
41322 -static int ti_init(struct pcmcia_socket *sock)
41323 -{
41324 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
41325 -       yenta_init(sock);
41326 -       ti_set_zv(sock);
41327 -       ti_intctl(socket);
41328 -       return 0;
41329 -}
41330  
41331  
41332  /*
41333 @@ -250,6 +259,18 @@
41334   *   This makes us correctly get PCI CSC interrupt
41335   *   events.
41336   */
41337 +static int ti_init(struct yenta_socket *socket)
41338 +{
41339 +       u8 new, reg = exca_readb(socket, I365_INTCTL);
41340 +
41341 +       new = reg & ~I365_INTR_ENA;
41342 +       if (socket->cb_irq)
41343 +               new |= I365_INTR_ENA;
41344 +       if (new != reg)
41345 +               exca_writeb(socket, I365_INTCTL, new);
41346 +       return 0;
41347 +}
41348 +
41349  static int ti_override(struct yenta_socket *socket)
41350  {
41351         u8 new, reg = exca_readb(socket, I365_INTCTL);
41352 @@ -258,6 +279,8 @@
41353         if (new != reg)
41354                 exca_writeb(socket, I365_INTCTL, new);
41355  
41356 +       ti_set_zv(socket);
41357 +
41358  #if 0
41359         /*
41360          * If ISA interrupts don't work, then fall back to routing card
41361 @@ -285,83 +308,85 @@
41362         }
41363  #endif
41364  
41365 -       socket->socket.ops->init = ti_init;
41366 -       return 0;
41367 -}
41368 -
41369 -#define ti_sysctl(socket)      ((socket)->private[0])
41370 -#define ti_cardctl(socket)     ((socket)->private[1])
41371 -#define ti_devctl(socket)      ((socket)->private[2])
41372 -#define ti_diag(socket)                ((socket)->private[3])
41373 -#define ti_irqmux(socket)      ((socket)->private[4])
41374 -
41375 -
41376 -static int ti113x_init(struct pcmcia_socket *sock)
41377 -{
41378 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
41379 -       yenta_init(sock);
41380 -       ti_set_zv(sock);
41381 -
41382 -       config_writel(socket, TI113X_SYSTEM_CONTROL, ti_sysctl(socket));
41383 -       config_writeb(socket, TI113X_CARD_CONTROL, ti_cardctl(socket));
41384 -       config_writeb(socket, TI113X_DEVICE_CONTROL, ti_devctl(socket));
41385 -       ti_intctl(socket);
41386         return 0;
41387  }
41388  
41389  static int ti113x_override(struct yenta_socket *socket)
41390  {
41391 -       ti_sysctl(socket) = config_readl(socket, TI113X_SYSTEM_CONTROL);
41392 -       ti_cardctl(socket) = config_readb(socket, TI113X_CARD_CONTROL);
41393 -       ti_devctl(socket) = config_readb(socket, TI113X_DEVICE_CONTROL);
41394 +       u8 cardctl;
41395  
41396 -       ti_cardctl(socket) &= ~(TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_IREQ | TI113X_CCR_PCI_CSC);
41397 +       cardctl = config_readb(socket, TI113X_CARD_CONTROL);
41398 +       cardctl &= ~(TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_IREQ | TI113X_CCR_PCI_CSC);
41399         if (socket->cb_irq)
41400 -               ti_cardctl(socket) |= TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_CSC | TI113X_CCR_PCI_IREQ;
41401 -       ti_override(socket);
41402 -       socket->socket.ops->init = ti113x_init;
41403 -       return 0;
41404 +               cardctl |= TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_CSC | TI113X_CCR_PCI_IREQ;
41405 +       config_writeb(socket, TI113X_CARD_CONTROL, cardctl);
41406 +
41407 +       return ti_override(socket);
41408  }
41409  
41410  
41411 -static int ti1250_init(struct pcmcia_socket *sock)
41412 +static int ti12xx_override(struct yenta_socket *socket)
41413  {
41414 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
41415 -       ti113x_init(sock);
41416 -       ti_irqmux(socket) = config_readl(socket, TI122X_IRQMUX);
41417 -#if 0
41418 -       ti_irqmux(socket) = (ti_irqmux(socket) & ~0x0f) | 0x02; /* route INTA */
41419 -       if (!(ti_sysctl(socket) & TI122X_SCR_INTRTIE))
41420 -               ti_irqmux(socket) |= 0x20; /* route INTB */
41421 -#endif
41422 -       
41423 -       config_writel(socket, TI122X_IRQMUX, ti_irqmux(socket));
41424 -               
41425 -       config_writeb(socket, TI1250_DIAGNOSTIC, ti_diag(socket));
41426 -       return 0;
41427 +       u32 val;
41428 +
41429 +       /* make sure that memory burst is active */
41430 +       val = config_readl(socket, TI113X_SYSTEM_CONTROL);
41431 +       if (!(val & TI122X_SCR_MRBURSTUP)) {
41432 +               printk(KERN_INFO "Yenta: Enabling burst memory read transactions\n");
41433 +               val |= TI122X_SCR_MRBURSTUP;
41434 +               config_writel(socket, TI113X_SYSTEM_CONTROL, val);
41435 +       }
41436 +
41437 +       /*
41438 +        * Yenta expects controllers to use CSCINT to route
41439 +        * CSC interrupts to PCI rather than INTVAL.
41440 +        */
41441 +       val = config_readb(socket, TI1250_DIAGNOSTIC);
41442 +       printk(KERN_INFO "Yenta: Using %s to route CSC interrupts to PCI\n",
41443 +               (val & TI1250_DIAG_PCI_CSC) ? "CSCINT" : "INTVAL");
41444 +       printk(KERN_INFO "Yenta: Routing CardBus interrupts to %s\n",
41445 +               (val & TI1250_DIAG_PCI_IREQ) ? "PCI" : "ISA");
41446 +
41447 +       return ti_override(socket);
41448  }
41449  
41450 +
41451  static int ti1250_override(struct yenta_socket *socket)
41452  {
41453 -       ti_diag(socket) = config_readb(socket, TI1250_DIAGNOSTIC);
41454 +       u8 old, diag;
41455  
41456 -       ti_diag(socket) &= ~(TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ);
41457 +       old = config_readb(socket, TI1250_DIAGNOSTIC);
41458 +       diag = old & ~(TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ);
41459         if (socket->cb_irq)
41460 -               ti_diag(socket) |= TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ;
41461 -       ti113x_override(socket);
41462 -       socket->socket.ops->init = ti1250_init;
41463 -       return 0;
41464 -}
41465 +               diag |= TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ;
41466  
41467 +       if (diag != old) {
41468 +               printk(KERN_INFO "Yenta: adjusting diagnostic: %02x -> %02x\n",
41469 +                       old, diag);
41470 +               config_writeb(socket, TI1250_DIAGNOSTIC, diag);
41471 +       }
41472  
41473 -static int ti12xx_override(struct yenta_socket *socket)
41474 -{
41475 -       /* make sure that memory burst is active */
41476 -       ti_sysctl(socket) = config_readl(socket, TI113X_SYSTEM_CONTROL);
41477 -       ti_sysctl(socket) |= TI122X_SCR_MRBURSTUP;
41478 -       config_writel(socket, TI113X_SYSTEM_CONTROL, ti_sysctl(socket));
41479 +#if 0
41480 +       /*
41481 +        * This is highly machine specific, and we should NOT touch
41482 +        * this register - we have no knowledge how the hardware
41483 +        * is actually wired.
41484 +        *
41485 +        * If we're going to do this, we should probably look into
41486 +        * using the subsystem IDs.
41487 +        *
41488 +        * On ThinkPad 380XD, this changes MFUNC0 from the ISA IRQ3
41489 +        * output (which it is) to IRQ2.  We also change MFUNC1
41490 +        * from ISA IRQ4 to IRQ6.
41491 +        */
41492 +       irqmux = config_readl(socket, TI122X_IRQMUX);
41493 +       irqmux = (irqmux & ~0x0f) | 0x02; /* route INTA */
41494 +       if (!(ti_sysctl(socket) & TI122X_SCR_INTRTIE))
41495 +               irqmux = (irqmux & ~0xf0) | 0x20; /* route INTB */
41496 +       config_writel(socket, TI122X_IRQMUX, irqmux);
41497 +#endif
41498  
41499 -       return ti113x_override(socket);
41500 +       return ti12xx_override(socket);
41501  }
41502  
41503  #endif /* CONFIG_CARDBUS */
41504 diff -Nru a/drivers/pcmcia/topic.h b/drivers/pcmcia/topic.h
41505 --- a/drivers/pcmcia/topic.h    Fri Oct 18 16:11:25 2002
41506 +++ b/drivers/pcmcia/topic.h    Wed Aug 27 13:19:32 2003
41507 @@ -31,20 +31,7 @@
41508  #ifndef _LINUX_TOPIC_H
41509  #define _LINUX_TOPIC_H
41510  
41511 -#ifndef PCI_VENDOR_ID_TOSHIBA
41512 -#define PCI_VENDOR_ID_TOSHIBA          0x1179
41513 -#endif
41514 -#ifndef PCI_DEVICE_ID_TOSHIBA_TOPIC95_A
41515 -#define PCI_DEVICE_ID_TOSHIBA_TOPIC95_A        0x0603
41516 -#endif
41517 -#ifndef PCI_DEVICE_ID_TOSHIBA_TOPIC95_B
41518 -#define PCI_DEVICE_ID_TOSHIBA_TOPIC95_B        0x060a
41519 -#endif
41520 -#ifndef PCI_DEVICE_ID_TOSHIBA_TOPIC97
41521 -#define PCI_DEVICE_ID_TOSHIBA_TOPIC97  0x060f
41522 -#endif
41523 -
41524 -/* Register definitions for Toshiba ToPIC95 controllers */
41525 +/* Register definitions for Toshiba ToPIC95/97/100 controllers */
41526  
41527  #define TOPIC_SOCKET_CONTROL           0x0090  /* 32 bit */
41528  #define  TOPIC_SCR_IRQSEL              0x00000001
41529 @@ -92,5 +79,62 @@
41530  #define  TOPIC97_RCR_RI_DISABLE                0x00000004
41531  #define  TOPIC97_RCR_CAUDIO_OFF                0x00000002
41532  #define  TOPIC_RCR_CAUDIO_INVERT       0x00000001
41533 +
41534 +#define TOPIC97_MISC1                  0x00ad  /* 8bit */
41535 +#define  TOPIC97_MISC1_CLOCKRUN_ENABLE 0x80
41536 +#define  TOPIC97_MISC1_CLOCKRUN_MODE   0x40
41537 +#define  TOPIC97_MISC1_DETECT_REQ_ENA  0x10
41538 +#define  TOPIC97_MISC1_SCK_CLEAR_DIS   0x04
41539 +#define  TOPIC97_MISC1_R2_LOW_ENABLE   0x10
41540 +
41541 +#define TOPIC97_MISC2                  0x00ae  /* 8 bit */
41542 +#define  TOPIC97_MISC2_SPWRCLK_MASK    0x70
41543 +#define  TOPIC97_MISC2_SPWRMOD         0x08
41544 +#define  TOPIC97_MISC2_SPWR_ENABLE     0x04
41545 +#define  TOPIC97_MISC2_ZV_MODE         0x02
41546 +#define  TOPIC97_MISC2_ZV_ENABLE       0x01
41547 +
41548 +#define TOPIC97_ZOOM_VIDEO_CONTROL     0x009c  /* 8 bit */
41549 +#define  TOPIC97_ZV_CONTROL_ENABLE     0x01
41550 +
41551 +#define TOPIC97_AUDIO_VIDEO_SWITCH     0x003c  /* 8 bit */
41552 +#define  TOPIC97_AVS_AUDIO_CONTROL     0x02
41553 +#define  TOPIC97_AVS_VIDEO_CONTROL     0x01
41554 +
41555 +
41556 +static void topic97_zoom_video(struct pcmcia_socket *sock, int onoff)
41557 +{
41558 +       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
41559 +       u8 reg_zv, reg;
41560 +
41561 +       reg_zv = config_readb(socket, TOPIC97_ZOOM_VIDEO_CONTROL);
41562 +       if (onoff) {
41563 +               reg_zv |= TOPIC97_ZV_CONTROL_ENABLE;
41564 +               config_writeb(socket, TOPIC97_ZOOM_VIDEO_CONTROL, reg_zv);
41565 +
41566 +               reg = config_readb(socket, TOPIC97_MISC2);
41567 +               reg |= TOPIC97_MISC2_ZV_ENABLE;
41568 +               config_writeb(socket, TOPIC97_MISC2, reg);
41569 +
41570 +               /* not sure this is needed, doc is unclear */
41571 +#if 0
41572 +               reg = config_readb(socket, TOPIC97_AUDIO_VIDEO_SWITCH);
41573 +               reg |= TOPIC97_AVS_AUDIO_CONTROL | TOPIC97_AVS_VIDEO_CONTROL;
41574 +               config_writeb(socket, TOPIC97_AUDIO_VIDEO_SWITCH, reg);
41575 +#endif
41576 +       }
41577 +       else {
41578 +               reg_zv &= ~TOPIC97_ZV_CONTROL_ENABLE;
41579 +               config_writeb(socket, TOPIC97_ZOOM_VIDEO_CONTROL, reg_zv);
41580 +       }
41581 +
41582 +}
41583 +
41584 +static int topic97_override(struct yenta_socket *socket)
41585 +{
41586 +       /* ToPIC97/100 support ZV */
41587 +       socket->socket.zoom_video = topic97_zoom_video;
41588 +       return 0;
41589 +}
41590  
41591  #endif /* _LINUX_TOPIC_H */
41592 diff -Nru a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
41593 --- a/drivers/pcmcia/yenta_socket.c     Thu Aug 14 16:53:49 2003
41594 +++ b/drivers/pcmcia/yenta_socket.c     Wed Aug 27 13:19:32 2003
41595 @@ -443,73 +443,6 @@
41596         add_timer(&socket->poll_timer);
41597  }
41598  
41599 -/*
41600 - * Only probe "regular" interrupts, don't
41601 - * touch dangerous spots like the mouse irq,
41602 - * because there are mice that apparently
41603 - * get really confused if they get fondled
41604 - * too intimately.
41605 - *
41606 - * Default to 11, 10, 9, 7, 6, 5, 4, 3.
41607 - */
41608 -static u32 isa_interrupts = 0x0ef8;
41609 -
41610 -static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mask)
41611 -{
41612 -       int i;
41613 -       unsigned long val;
41614 -       u16 bridge_ctrl;
41615 -       u32 mask;
41616 -
41617 -       /* Set up ISA irq routing to probe the ISA irqs.. */
41618 -       bridge_ctrl = config_readw(socket, CB_BRIDGE_CONTROL);
41619 -       if (!(bridge_ctrl & CB_BRIDGE_INTR)) {
41620 -               bridge_ctrl |= CB_BRIDGE_INTR;
41621 -               config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
41622 -       }
41623 -
41624 -       /*
41625 -        * Probe for usable interrupts using the force
41626 -        * register to generate bogus card status events.
41627 -        */
41628 -       cb_writel(socket, CB_SOCKET_EVENT, -1);
41629 -       cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK);
41630 -       exca_writeb(socket, I365_CSCINT, 0);
41631 -       val = probe_irq_on() & isa_irq_mask;
41632 -       for (i = 1; i < 16; i++) {
41633 -               if (!((val >> i) & 1))
41634 -                       continue;
41635 -               exca_writeb(socket, I365_CSCINT, I365_CSC_STSCHG | (i << 4));
41636 -               cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS);
41637 -               udelay(100);
41638 -               cb_writel(socket, CB_SOCKET_EVENT, -1);
41639 -       }
41640 -       cb_writel(socket, CB_SOCKET_MASK, 0);
41641 -       exca_writeb(socket, I365_CSCINT, 0);
41642 -       
41643 -       mask = probe_irq_mask(val) & 0xffff;
41644 -
41645 -       bridge_ctrl &= ~CB_BRIDGE_INTR;
41646 -       config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
41647 -
41648 -       return mask;
41649 -}
41650 -
41651 -/*
41652 - * Set static data that doesn't need re-initializing..
41653 - */
41654 -static void yenta_get_socket_capabilities(struct yenta_socket *socket, u32 isa_irq_mask)
41655 -{
41656 -       socket->socket.features |= SS_CAP_PAGE_REGS | SS_CAP_PCCARD | SS_CAP_CARDBUS;
41657 -       socket->socket.map_size = 0x1000;
41658 -       socket->socket.pci_irq = socket->cb_irq;
41659 -       socket->socket.irq_mask = yenta_probe_irq(socket, isa_irq_mask);
41660 -       socket->socket.cb_dev = socket->dev;
41661 -
41662 -       printk("Yenta IRQ list %04x, PCI irq%d\n", socket->socket.irq_mask, socket->cb_irq);
41663 -}
41664 -
41665 -
41666  static void yenta_clear_maps(struct yenta_socket *socket)
41667  {
41668         int i;
41669 @@ -528,42 +461,13 @@
41670         }
41671  }
41672  
41673 -/*
41674 - * Initialize the standard cardbus registers
41675 - */
41676 -static void yenta_config_init(struct yenta_socket *socket)
41677 +/* Called at resume and initialization events */
41678 +static int yenta_sock_init(struct pcmcia_socket *sock)
41679  {
41680 +       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
41681         u16 bridge;
41682 -       struct pci_dev *dev = socket->dev;
41683 -
41684 -       pci_set_power_state(socket->dev, 0);
41685 -
41686 -       config_writel(socket, CB_LEGACY_MODE_BASE, 0);
41687 -       config_writel(socket, PCI_BASE_ADDRESS_0, dev->resource[0].start);
41688 -       config_writew(socket, PCI_COMMAND,
41689 -                       PCI_COMMAND_IO |
41690 -                       PCI_COMMAND_MEMORY |
41691 -                       PCI_COMMAND_MASTER |
41692 -                       PCI_COMMAND_WAIT);
41693 -
41694 -       /* MAGIC NUMBERS! Fixme */
41695 -       config_writeb(socket, PCI_CACHE_LINE_SIZE, L1_CACHE_BYTES / 4);
41696 -       config_writeb(socket, PCI_LATENCY_TIMER, 168);
41697 -       config_writel(socket, PCI_PRIMARY_BUS,
41698 -               (176 << 24) |                      /* sec. latency timer */
41699 -               (dev->subordinate->subordinate << 16) | /* subordinate bus */
41700 -               (dev->subordinate->secondary << 8) |  /* secondary bus */
41701 -               dev->subordinate->primary);                /* primary bus */
41702  
41703 -       /*
41704 -        * Set up the bridging state:
41705 -        *  - enable write posting.
41706 -        *  - memory window 0 prefetchable, window 1 non-prefetchable
41707 -        *  - PCI interrupts enabled if a PCI interrupt exists..
41708 -        */
41709 -       bridge = config_readw(socket, CB_BRIDGE_CONTROL);
41710 -       bridge &= ~(CB_BRIDGE_CRST | CB_BRIDGE_PREFETCH1 | CB_BRIDGE_INTR | CB_BRIDGE_ISAEN | CB_BRIDGE_VGAEN);
41711 -       bridge |= CB_BRIDGE_PREFETCH0 | CB_BRIDGE_POSTEN;
41712 +       bridge = config_readw(socket, CB_BRIDGE_CONTROL) & ~CB_BRIDGE_INTR;
41713         if (!socket->cb_irq)
41714                 bridge |= CB_BRIDGE_INTR;
41715         config_writew(socket, CB_BRIDGE_CONTROL, bridge);
41716 @@ -573,41 +477,27 @@
41717  
41718         /* Redo card voltage interrogation */
41719         cb_writel(socket, CB_SOCKET_FORCE, CB_CVSTEST);
41720 -}
41721  
41722 -/* Called at resume and initialization events */
41723 -static int yenta_init(struct pcmcia_socket *sock)
41724 -{
41725 -       struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
41726 -       yenta_config_init(socket);
41727         yenta_clear_maps(socket);
41728  
41729 -       /* Re-enable interrupts */
41730 +       if (socket->type && socket->type->sock_init)
41731 +               socket->type->sock_init(socket);
41732 +
41733 +       /* Re-enable CSC interrupts */
41734         cb_writel(socket, CB_SOCKET_MASK, CB_CDMASK);
41735 +
41736         return 0;
41737  }
41738  
41739 -static int yenta_suspend(struct pcmcia_socket *sock)
41740 +static int yenta_sock_suspend(struct pcmcia_socket *sock)
41741  {
41742         struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
41743  
41744         yenta_set_socket(sock, &dead_socket);
41745  
41746 -       /* Disable interrupts */
41747 +       /* Disable CSC interrupts */
41748         cb_writel(socket, CB_SOCKET_MASK, 0x0);
41749  
41750 -       /*
41751 -        * This does not work currently. The controller
41752 -        * loses too much information during D3 to come up
41753 -        * cleanly. We should probably fix yenta_init()
41754 -        * to update all the critical registers, notably
41755 -        * the IO and MEM bridging region data.. That is
41756 -        * something that pci_set_power_state() should
41757 -        * probably know about bridges anyway.
41758 -        *
41759 -       pci_set_power_state(socket->dev, 3);
41760 -        */
41761 -
41762         return 0;
41763  }
41764  
41765 @@ -758,8 +648,8 @@
41766  
41767  
41768  static struct pccard_operations yenta_socket_operations = {
41769 -       .init                   = yenta_init,
41770 -       .suspend                = yenta_suspend,
41771 +       .init                   = yenta_sock_init,
41772 +       .suspend                = yenta_sock_suspend,
41773         .get_status             = yenta_get_status,
41774         .get_socket             = yenta_get_socket,
41775         .set_socket             = yenta_set_socket,
41776 @@ -770,52 +660,165 @@
41777  
41778  #include "ti113x.h"
41779  #include "ricoh.h"
41780 +#include "topic.h"
41781 +
41782 +enum {
41783 +       CARDBUS_TYPE_DEFAULT = -1,
41784 +       CARDBUS_TYPE_TI,
41785 +       CARDBUS_TYPE_TI113X,
41786 +       CARDBUS_TYPE_TI12XX,
41787 +       CARDBUS_TYPE_TI1250,
41788 +       CARDBUS_TYPE_RICOH,
41789 +       CARDBUS_TYPE_TOPIC97
41790 +};
41791  
41792  /*
41793   * Different cardbus controllers have slightly different
41794   * initialization sequences etc details. List them here..
41795   */
41796 -#define PD(x,y) PCI_VENDOR_ID_##x, PCI_DEVICE_ID_##x##_##y
41797 -struct cardbus_override_struct {
41798 -       unsigned short vendor;
41799 -       unsigned short device;
41800 -       int (*override) (struct yenta_socket *socket);
41801 -} cardbus_override[] = {
41802 -       { PD(TI,1031),  &ti_override },
41803 -
41804 -       /* TBD: Check if these TI variants can use more
41805 -        * advanced overrides instead */
41806 -       { PD(TI,1210),  &ti_override },
41807 -       { PD(TI,1211),  &ti_override },
41808 -       { PD(TI,1251A), &ti_override },
41809 -       { PD(TI,1251B), &ti_override },
41810 -       { PD(TI,1420),  &ti_override },
41811 -       { PD(TI,1450),  &ti_override },
41812 -       { PD(TI,4410),  &ti_override },
41813 -       { PD(TI,4451),  &ti_override },
41814 -
41815 -       { PD(TI,1130),  &ti113x_override },
41816 -       { PD(TI,1131),  &ti113x_override },
41817 -
41818 -       { PD(TI,1220),  &ti12xx_override },
41819 -       { PD(TI,1221),  &ti12xx_override },
41820 -       { PD(TI,1225),  &ti12xx_override },
41821 -       { PD(TI,1520),  &ti12xx_override },
41822 -
41823 -       { PD(TI,1250),  &ti1250_override },
41824 -       { PD(TI,1410),  &ti1250_override },
41825 -
41826 -       { PD(RICOH,RL5C465), &ricoh_override },
41827 -       { PD(RICOH,RL5C466), &ricoh_override },
41828 -       { PD(RICOH,RL5C475), &ricoh_override },
41829 -       { PD(RICOH,RL5C476), &ricoh_override },
41830 -       { PD(RICOH,RL5C478), &ricoh_override },
41831 -
41832 -       { }, /* all zeroes */
41833 +struct cardbus_type cardbus_type[] = {
41834 +       [CARDBUS_TYPE_TI]       = {
41835 +               .override       = ti_override,
41836 +               .save_state     = ti_save_state,
41837 +               .restore_state  = ti_restore_state,
41838 +               .sock_init      = ti_init,
41839 +       },
41840 +       [CARDBUS_TYPE_TI113X]   = {
41841 +               .override       = ti113x_override,
41842 +               .save_state     = ti_save_state,
41843 +               .restore_state  = ti_restore_state,
41844 +               .sock_init      = ti_init,
41845 +       },
41846 +       [CARDBUS_TYPE_TI12XX]   = {
41847 +               .override       = ti12xx_override,
41848 +               .save_state     = ti_save_state,
41849 +               .restore_state  = ti_restore_state,
41850 +               .sock_init      = ti_init,
41851 +       },
41852 +       [CARDBUS_TYPE_TI1250]   = {
41853 +               .override       = ti1250_override,
41854 +               .save_state     = ti_save_state,
41855 +               .restore_state  = ti_restore_state,
41856 +               .sock_init      = ti_init,
41857 +       },
41858 +       [CARDBUS_TYPE_RICOH]    = {
41859 +               .override       = ricoh_override,
41860 +               .save_state     = ricoh_save_state,
41861 +               .restore_state  = ricoh_restore_state,
41862 +       },
41863 +       [CARDBUS_TYPE_TOPIC97]  = {
41864 +               .override       = topic97_override,
41865 +       },
41866  };
41867  
41868  
41869  /*
41870 + * Only probe "regular" interrupts, don't
41871 + * touch dangerous spots like the mouse irq,
41872 + * because there are mice that apparently
41873 + * get really confused if they get fondled
41874 + * too intimately.
41875 + *
41876 + * Default to 11, 10, 9, 7, 6, 5, 4, 3.
41877 + */
41878 +static u32 isa_interrupts = 0x0ef8;
41879 +
41880 +static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mask)
41881 +{
41882 +       int i;
41883 +       unsigned long val;
41884 +       u16 bridge_ctrl;
41885 +       u32 mask;
41886 +
41887 +       /* Set up ISA irq routing to probe the ISA irqs.. */
41888 +       bridge_ctrl = config_readw(socket, CB_BRIDGE_CONTROL);
41889 +       if (!(bridge_ctrl & CB_BRIDGE_INTR)) {
41890 +               bridge_ctrl |= CB_BRIDGE_INTR;
41891 +               config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
41892 +       }
41893 +
41894 +       /*
41895 +        * Probe for usable interrupts using the force
41896 +        * register to generate bogus card status events.
41897 +        */
41898 +       cb_writel(socket, CB_SOCKET_EVENT, -1);
41899 +       cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK);
41900 +       exca_writeb(socket, I365_CSCINT, 0);
41901 +       val = probe_irq_on() & isa_irq_mask;
41902 +       for (i = 1; i < 16; i++) {
41903 +               if (!((val >> i) & 1))
41904 +                       continue;
41905 +               exca_writeb(socket, I365_CSCINT, I365_CSC_STSCHG | (i << 4));
41906 +               cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS);
41907 +               udelay(100);
41908 +               cb_writel(socket, CB_SOCKET_EVENT, -1);
41909 +       }
41910 +       cb_writel(socket, CB_SOCKET_MASK, 0);
41911 +       exca_writeb(socket, I365_CSCINT, 0);
41912 +
41913 +       mask = probe_irq_mask(val) & 0xffff;
41914 +
41915 +       bridge_ctrl &= ~CB_BRIDGE_INTR;
41916 +       config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
41917 +
41918 +       return mask;
41919 +}
41920 +
41921 +/*
41922 + * Set static data that doesn't need re-initializing..
41923 + */
41924 +static void yenta_get_socket_capabilities(struct yenta_socket *socket, u32 isa_irq_mask)
41925 +{
41926 +       socket->socket.features |= SS_CAP_PAGE_REGS | SS_CAP_PCCARD | SS_CAP_CARDBUS;
41927 +       socket->socket.map_size = 0x1000;
41928 +       socket->socket.pci_irq = socket->cb_irq;
41929 +       socket->socket.irq_mask = yenta_probe_irq(socket, isa_irq_mask);
41930 +       socket->socket.cb_dev = socket->dev;
41931 +
41932 +       printk(KERN_INFO "Yenta: ISA IRQ list %04x, PCI irq%d\n",
41933 +              socket->socket.irq_mask, socket->cb_irq);
41934 +}
41935 +
41936 +/*
41937 + * Initialize the standard cardbus registers
41938 + */
41939 +static void yenta_config_init(struct yenta_socket *socket)
41940 +{
41941 +       u16 bridge;
41942 +       struct pci_dev *dev = socket->dev;
41943 +
41944 +       pci_set_power_state(socket->dev, 0);
41945 +
41946 +       config_writel(socket, CB_LEGACY_MODE_BASE, 0);
41947 +       config_writel(socket, PCI_BASE_ADDRESS_0, dev->resource[0].start);
41948 +       config_writew(socket, PCI_COMMAND,
41949 +                       PCI_COMMAND_IO |
41950 +                       PCI_COMMAND_MEMORY |
41951 +                       PCI_COMMAND_MASTER |
41952 +                       PCI_COMMAND_WAIT);
41953 +
41954 +       /* MAGIC NUMBERS! Fixme */
41955 +       config_writeb(socket, PCI_CACHE_LINE_SIZE, L1_CACHE_BYTES / 4);
41956 +       config_writeb(socket, PCI_LATENCY_TIMER, 168);
41957 +       config_writel(socket, PCI_PRIMARY_BUS,
41958 +               (176 << 24) |                      /* sec. latency timer */
41959 +               (dev->subordinate->subordinate << 16) | /* subordinate bus */
41960 +               (dev->subordinate->secondary << 8) |  /* secondary bus */
41961 +               dev->subordinate->primary);                /* primary bus */
41962 +
41963 +       /*
41964 +        * Set up the bridging state:
41965 +        *  - enable write posting.
41966 +        *  - memory window 0 prefetchable, window 1 non-prefetchable
41967 +        *  - PCI interrupts enabled if a PCI interrupt exists..
41968 +        */
41969 +       bridge = config_readw(socket, CB_BRIDGE_CONTROL);
41970 +       bridge &= ~(CB_BRIDGE_CRST | CB_BRIDGE_PREFETCH1 | CB_BRIDGE_INTR | CB_BRIDGE_ISAEN | CB_BRIDGE_VGAEN);
41971 +       bridge |= CB_BRIDGE_PREFETCH0 | CB_BRIDGE_POSTEN | CB_BRIDGE_INTR;
41972 +       config_writew(socket, CB_BRIDGE_CONTROL, bridge);
41973 +}
41974 +
41975 +/*
41976   * Initialize a cardbus controller. Make sure we have a usable
41977   * interrupt, and that we can map the cardbus area. Fill in the
41978   * socket information structure..
41979 @@ -823,7 +826,6 @@
41980  static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_id *id)
41981  {
41982         struct yenta_socket *socket;
41983 -       struct cardbus_override_struct *d;
41984         int ret;
41985         
41986         socket = kmalloc(sizeof(struct yenta_socket), GFP_KERNEL);
41987 @@ -887,14 +889,13 @@
41988         socket->cb_irq = dev->irq;
41989  
41990         /* Do we have special options for the device? */
41991 -       d = cardbus_override;
41992 -       while (d->override) {
41993 -               if ((dev->vendor == d->vendor) && (dev->device == d->device)) {
41994 -                       ret = d->override(socket);
41995 -                       if (ret < 0)
41996 -                               goto unmap;
41997 -               }
41998 -               d++;
41999 +       if (id->driver_data != CARDBUS_TYPE_DEFAULT &&
42000 +           id->driver_data < ARRAY_SIZE(cardbus_type)) {
42001 +               socket->type = &cardbus_type[id->driver_data];
42002 +
42003 +               ret = socket->type->override(socket);
42004 +               if (ret < 0)
42005 +                       goto unmap;
42006         }
42007  
42008         /* We must finish initialization here */
42009 @@ -933,25 +934,97 @@
42010  
42011  static int yenta_dev_suspend (struct pci_dev *dev, u32 state)
42012  {
42013 -       return pcmcia_socket_dev_suspend(&dev->dev, state, SUSPEND_SAVE_STATE);
42014 +       struct yenta_socket *socket = pci_get_drvdata(dev);
42015 +       int ret;
42016 +
42017 +       ret = pcmcia_socket_dev_suspend(&dev->dev, state, SUSPEND_SAVE_STATE);
42018 +
42019 +       if (socket) {
42020 +               if (socket->type && socket->type->save_state)
42021 +                       socket->type->save_state(socket);
42022 +
42023 +               /* FIXME: pci_save_state needs to have a better interface */
42024 +               pci_save_state(dev, socket->saved_state);
42025 +               pci_read_config_dword(dev, 16*4, &socket->saved_state[16]);
42026 +               pci_read_config_dword(dev, 17*4, &socket->saved_state[17]);
42027 +               pci_set_power_state(dev, 3);
42028 +       }
42029 +
42030 +       return ret;
42031  }
42032  
42033  
42034  static int yenta_dev_resume (struct pci_dev *dev)
42035  {
42036 +       struct yenta_socket *socket = pci_get_drvdata(dev);
42037 +
42038 +       if (socket) {
42039 +               pci_set_power_state(dev, 0);
42040 +               /* FIXME: pci_restore_state needs to have a better interface */
42041 +               pci_restore_state(dev, socket->saved_state);
42042 +               pci_write_config_dword(dev, 16*4, socket->saved_state[16]);
42043 +               pci_write_config_dword(dev, 17*4, socket->saved_state[17]);
42044 +
42045 +               if (socket->type && socket->type->restore_state)
42046 +                       socket->type->restore_state(socket);
42047 +       }
42048 +
42049         return pcmcia_socket_dev_resume(&dev->dev, RESUME_RESTORE_STATE);
42050  }
42051  
42052  
42053 -static struct pci_device_id yenta_table [] = { {
42054 -       .class          = PCI_CLASS_BRIDGE_CARDBUS << 8,
42055 -       .class_mask     = ~0,
42056 -
42057 -       .vendor         = PCI_ANY_ID,
42058 -       .device         = PCI_ANY_ID,
42059 -       .subvendor      = PCI_ANY_ID,
42060 -       .subdevice      = PCI_ANY_ID,
42061 -}, { /* all zeroes */ }
42062 +#define CB_ID(vend,dev,type)                           \
42063 +       {                                               \
42064 +               .vendor         = vend,                 \
42065 +               .device         = dev,                  \
42066 +               .subvendor      = PCI_ANY_ID,           \
42067 +               .subdevice      = PCI_ANY_ID,           \
42068 +               .class          = PCI_CLASS_BRIDGE_CARDBUS << 8, \
42069 +               .class_mask     = ~0,                   \
42070 +               .driver_data    = CARDBUS_TYPE_##type,  \
42071 +       }
42072 +
42073 +static struct pci_device_id yenta_table [] = {
42074 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1031, TI),
42075 +
42076 +       /*
42077 +        * TBD: Check if these TI variants can use more
42078 +        * advanced overrides instead.  (I can't get the
42079 +        * data sheets for these devices. --rmk)
42080 +        */
42081 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1210, TI),
42082 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1251B, TI),
42083 +
42084 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1130, TI113X),
42085 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1131, TI113X),
42086 +
42087 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1211, TI12XX),
42088 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1220, TI12XX),
42089 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1221, TI12XX),
42090 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1225, TI12XX),
42091 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1251A, TI12XX),
42092 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1420, TI12XX),
42093 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1450, TI12XX),
42094 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1520, TI12XX),
42095 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4410, TI12XX),
42096 +//     CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4450, TI12XX),
42097 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4451, TI12XX),
42098 +
42099 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1250, TI1250),
42100 +       CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1410, TI1250),
42101 +
42102 +       CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C465, RICOH),
42103 +       CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C466, RICOH),
42104 +       CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C475, RICOH),
42105 +       CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, RICOH),
42106 +       CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C478, RICOH),
42107 +
42108 +       CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC97, TOPIC97),
42109 +       CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC100, TOPIC97),
42110 +
42111 +       /* match any cardbus bridge */
42112 +       CB_ID(PCI_ANY_ID, PCI_ANY_ID, DEFAULT),
42113 +       { /* all zeroes */ }
42114  };
42115  MODULE_DEVICE_TABLE(pci, yenta_table);
42116  
42117 diff -Nru a/drivers/pcmcia/yenta_socket.h b/drivers/pcmcia/yenta_socket.h
42118 --- a/drivers/pcmcia/yenta_socket.h     Mon Jun 30 13:33:00 2003
42119 +++ b/drivers/pcmcia/yenta_socket.h     Wed Aug 27 12:42:53 2003
42120 @@ -95,6 +95,15 @@
42121   */
42122  #define CB_MEM_PAGE(map)       (0x40 + (map))
42123  
42124 +struct yenta_socket;
42125 +
42126 +struct cardbus_type {
42127 +       int     (*override)(struct yenta_socket *);
42128 +       void    (*save_state)(struct yenta_socket *);
42129 +       void    (*restore_state)(struct yenta_socket *);
42130 +       int     (*sock_init)(struct yenta_socket *);
42131 +};
42132 +
42133  struct yenta_socket {
42134         struct pci_dev *dev;
42135         int cb_irq, io_irq;
42136 @@ -102,9 +111,13 @@
42137         struct timer_list poll_timer;
42138  
42139         struct pcmcia_socket socket;
42140 +       struct cardbus_type *type;
42141  
42142         /* A few words of private data for special stuff of overrides... */
42143         unsigned int private[8];
42144 +
42145 +       /* PCI saved state */
42146 +       u32 saved_state[18];
42147  };
42148  
42149  
42150 diff -Nru a/drivers/s390/char/tape_char.c b/drivers/s390/char/tape_char.c
42151 --- a/drivers/s390/char/tape_char.c     Mon May 26 12:20:47 2003
42152 +++ b/drivers/s390/char/tape_char.c     Tue Aug 26 09:25:41 2003
42153 @@ -238,14 +238,14 @@
42154         struct tape_device *device;
42155         int minor, rc;
42156  
42157 -       if (major(filp->f_dentry->d_inode->i_rdev) != tapechar_major)
42158 +       if (imajor(filp->f_dentry->d_inode) != tapechar_major)
42159                 return -ENODEV;
42160 -       minor = minor(filp->f_dentry->d_inode->i_rdev);
42161 +       minor = iminor(filp->f_dentry->d_inode);
42162         device = tape_get_device(minor / TAPE_MINORS_PER_DEV);
42163         if (IS_ERR(device)) {
42164                 return PTR_ERR(device);
42165         }
42166 -       DBF_EVENT(6, "TCHAR:open: %x\n", minor(inode->i_rdev));
42167 +       DBF_EVENT(6, "TCHAR:open: %x\n", iminor(inode));
42168         rc = tape_open(device);
42169         if (rc == 0) {
42170                 rc = tape_assign(device);
42171 @@ -269,7 +269,7 @@
42172         struct tape_device *device;
42173  
42174         device = (struct tape_device *) filp->private_data;
42175 -       DBF_EVENT(6, "TCHAR:release: %x\n", minor(inode->i_rdev));
42176 +       DBF_EVENT(6, "TCHAR:release: %x\n", iminor(inode));
42177  #if 0
42178         // FIXME: this is broken. Either MTWEOF/MTWEOF/MTBSR is done
42179         // EVERYTIME the user switches from write to something different
42180 @@ -281,7 +281,7 @@
42181         /*
42182          * If this is the rewinding tape minor then rewind.
42183          */
42184 -       if ((minor(inode->i_rdev) & 1) != 0)
42185 +       if ((iminor(inode) & 1) != 0)
42186                 tape_mtop(device, MTREW, 1);
42187         if (device->char_data.idal_buf != NULL) {
42188                 idal_buffer_free(device->char_data.idal_buf);
42189 diff -Nru a/drivers/s390/char/tubio.h b/drivers/s390/char/tubio.h
42190 --- a/drivers/s390/char/tubio.h Wed Jun 11 12:32:58 2003
42191 +++ b/drivers/s390/char/tubio.h Tue Aug 26 09:25:41 2003
42192 @@ -377,7 +377,7 @@
42193   */
42194  extern inline tub_t *INODE2TUB(struct inode *ip)
42195  {
42196 -       unsigned int minor = minor(ip->i_rdev);
42197 +       unsigned int minor = iminor(ip);
42198         tub_t *tubp = NULL;
42199         if (minor == 0 && current->tty) {
42200                 if (current->tty->driver == tty3270_driver)
42201 diff -Nru a/drivers/s390/net/cu3088.c b/drivers/s390/net/cu3088.c
42202 --- a/drivers/s390/net/cu3088.c Sun May 25 17:00:00 2003
42203 +++ b/drivers/s390/net/cu3088.c Tue Aug 19 09:22:46 2003
42204 @@ -64,7 +64,7 @@
42205  group_write(struct device_driver *drv, const char *buf, size_t count)
42206  {
42207         const char *start, *end;
42208 -       char bus_ids[2][BUS_ID_SIZE], *argv[2];
42209 +       char bus_ids[2][BUS_ID_SIZE+1], *argv[2];
42210         int i;
42211         int ret;
42212         struct ccwgroup_driver *cdrv;
42213 @@ -79,7 +79,7 @@
42214  
42215                 if (!(end = strchr(start, delim[i])))
42216                         return count;
42217 -               len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start);
42218 +               len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start)+1;
42219                 strlcpy (bus_ids[i], start, len);
42220                 argv[i] = bus_ids[i];
42221                 start = end + 1;
42222 diff -Nru a/drivers/s390/net/qeth.c b/drivers/s390/net/qeth.c
42223 --- a/drivers/s390/net/qeth.c   Thu Jul 17 10:27:34 2003
42224 +++ b/drivers/s390/net/qeth.c   Sun Aug 31 16:14:08 2003
42225 @@ -9765,19 +9765,19 @@
42226  };
42227  
42228  static struct file_operations qeth_procfile_fops = {
42229 -       ioctl:qeth_procfile_ioctl,
42230 -       read:qeth_procfile_read,
42231 -       open:qeth_procfile_open,
42232 -       release:qeth_procfile_release,
42233 +       .ioctl = qeth_procfile_ioctl,
42234 +       .read = qeth_procfile_read,
42235 +       .open = qeth_procfile_open,
42236 +       .release = qeth_procfile_release,
42237  };
42238  
42239  static struct proc_dir_entry *qeth_proc_file;
42240  
42241  static struct file_operations qeth_ipato_procfile_fops = {
42242 -       read:qeth_procfile_read,        /* same as above! */
42243 -       write:qeth_ipato_procfile_write,
42244 -       open:qeth_ipato_procfile_open,
42245 -       release:qeth_procfile_release   /* same as above! */
42246 +       .read = qeth_procfile_read,     /* same as above! */
42247 +       .write = qeth_ipato_procfile_write,
42248 +       .open = qeth_ipato_procfile_open,
42249 +       .release = qeth_procfile_release        /* same as above! */
42250  };
42251  
42252  static struct proc_dir_entry *qeth_ipato_proc_file;
42253 diff -Nru a/drivers/sbus/char/bpp.c b/drivers/sbus/char/bpp.c
42254 --- a/drivers/sbus/char/bpp.c   Wed May  7 08:47:30 2003
42255 +++ b/drivers/sbus/char/bpp.c   Tue Aug 26 09:25:41 2003
42256 @@ -440,7 +440,7 @@
42257   */
42258  static int bpp_open(struct inode *inode, struct file *f)
42259  {
42260 -      unsigned minor = minor(inode->i_rdev);
42261 +      unsigned minor = iminor(inode);
42262        int ret;
42263  
42264        spin_lock(&bpp_open_lock);
42265 @@ -470,7 +470,7 @@
42266   */
42267  static int bpp_release(struct inode *inode, struct file *f)
42268  {
42269 -      unsigned minor = minor(inode->i_rdev);
42270 +      unsigned minor = iminor(inode);
42271  
42272        spin_lock(&bpp_open_lock);
42273        instances[minor].opened = 0;
42274 @@ -634,7 +634,7 @@
42275  static ssize_t bpp_read(struct file *f, char *c, size_t cnt, loff_t * ppos)
42276  {
42277        long rc;
42278 -      const unsigned minor = minor(f->f_dentry->d_inode->i_rdev);
42279 +      unsigned minor = iminor(f->f_dentry->d_inode);
42280        if (minor >= BPP_NO) return -ENODEV;
42281        if (!instances[minor].present) return -ENODEV;
42282  
42283 @@ -787,7 +787,7 @@
42284  static ssize_t bpp_write(struct file *f, const char *c, size_t cnt, loff_t * ppos)
42285  {
42286        long errno = 0;
42287 -      const unsigned minor = minor(f->f_dentry->d_inode->i_rdev);
42288 +      unsigned minor = iminor(f->f_dentry->d_inode);
42289        if (minor >= BPP_NO) return -ENODEV;
42290        if (!instances[minor].present) return -ENODEV;
42291  
42292 @@ -813,7 +813,7 @@
42293  {
42294        int errno = 0;
42295  
42296 -      unsigned minor = minor(inode->i_rdev);
42297 +      unsigned minor = iminor(inode);
42298        if (minor >= BPP_NO) return -ENODEV;
42299        if (!instances[minor].present) return -ENODEV;
42300  
42301 diff -Nru a/drivers/sbus/char/cpwatchdog.c b/drivers/sbus/char/cpwatchdog.c
42302 --- a/drivers/sbus/char/cpwatchdog.c    Tue Apr 22 23:40:00 2003
42303 +++ b/drivers/sbus/char/cpwatchdog.c    Tue Aug 26 09:25:41 2003
42304 @@ -295,7 +295,7 @@
42305  
42306  static int wd_open(struct inode *inode, struct file *f)
42307  {
42308 -       switch(minor(inode->i_rdev))
42309 +       switch(iminor(inode))
42310         {
42311                 case WD0_MINOR:
42312                         f->private_data = &wd_dev.watchdog[WD0_ID];
42313 diff -Nru a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c
42314 --- a/drivers/sbus/char/display7seg.c   Thu Jan 16 11:49:15 2003
42315 +++ b/drivers/sbus/char/display7seg.c   Tue Aug 26 09:25:41 2003
42316 @@ -91,7 +91,7 @@
42317  
42318  static int d7s_open(struct inode *inode, struct file *f)
42319  {
42320 -       if (D7S_MINOR != minor(inode->i_rdev))
42321 +       if (D7S_MINOR != iminor(inode))
42322                 return -ENODEV;
42323         atomic_inc(&d7s_users);
42324         return 0;
42325 @@ -121,7 +121,7 @@
42326         __u8 regs = readb(d7s_regs);
42327         __u8 ireg = 0;
42328  
42329 -       if (D7S_MINOR != minor(inode->i_rdev))
42330 +       if (D7S_MINOR != iminor(inode))
42331                 return -ENODEV;
42332  
42333         switch (cmd) {
42334 diff -Nru a/drivers/sbus/char/rtc.c b/drivers/sbus/char/rtc.c
42335 --- a/drivers/sbus/char/rtc.c   Thu Jul 18 23:11:59 2002
42336 +++ b/drivers/sbus/char/rtc.c   Mon Sep  1 00:27:41 2003
42337 @@ -28,7 +28,7 @@
42338  static int rtc_busy = 0;
42339  
42340  /* Retrieve the current date and time from the real time clock. */
42341 -void get_rtc_time(struct rtc_time *t)
42342 +static void get_rtc_time(struct rtc_time *t)
42343  {
42344         unsigned long regs = mstk48t02_regs;
42345         u8 tmp;
42346 diff -Nru a/drivers/sbus/char/vfc_dev.c b/drivers/sbus/char/vfc_dev.c
42347 --- a/drivers/sbus/char/vfc_dev.c       Wed May  7 08:47:30 2003
42348 +++ b/drivers/sbus/char/vfc_dev.c       Tue Aug 26 09:25:41 2003
42349 @@ -184,7 +184,7 @@
42350         struct vfc_dev *dev;
42351  
42352         spin_lock(&vfc_dev_lock);
42353 -       dev = vfc_get_dev_ptr(MINOR(inode->i_rdev));
42354 +       dev = vfc_get_dev_ptr(iminor(inode));
42355         if (dev == NULL) {
42356                 spin_unlock(&vfc_dev_lock);
42357                 return -ENODEV;
42358 @@ -215,7 +215,7 @@
42359         struct vfc_dev *dev;
42360  
42361         spin_lock(&vfc_dev_lock);
42362 -       dev = vfc_get_dev_ptr(MINOR(inode->i_rdev));
42363 +       dev = vfc_get_dev_ptr(iminor(inode));
42364         if (!dev || !dev->busy) {
42365                 spin_unlock(&vfc_dev_lock);
42366                 return -EINVAL;
42367 @@ -557,7 +557,7 @@
42368         unsigned int tmp;
42369         struct vfc_dev *dev;
42370  
42371 -       dev = vfc_get_dev_ptr(MINOR(inode->i_rdev));
42372 +       dev = vfc_get_dev_ptr(iminor(inode));
42373         if(dev == NULL)
42374                 return -ENODEV;
42375         
42376 @@ -602,7 +602,7 @@
42377                 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCRDINFO)\n", dev->instance));
42378                 break;
42379         default:
42380 -               ret = vfc_debug(vfc_get_dev_ptr(MINOR(inode->i_rdev)),
42381 +               ret = vfc_debug(vfc_get_dev_ptr(iminor(inode)),
42382                                 cmd, arg);
42383                 break;
42384         };
42385 @@ -616,7 +616,7 @@
42386         unsigned int map_size, ret, map_offset;
42387         struct vfc_dev *dev;
42388         
42389 -       dev = vfc_get_dev_ptr(MINOR(inode->i_rdev));
42390 +       dev = vfc_get_dev_ptr(iminor(inode));
42391         if(dev == NULL)
42392                 return -ENODEV;
42393  
42394 diff -Nru a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
42395 --- a/drivers/scsi/3w-xxxx.c    Sat Aug 16 11:46:50 2003
42396 +++ b/drivers/scsi/3w-xxxx.c    Tue Aug 26 09:25:41 2003
42397 @@ -628,7 +628,7 @@
42398         unsigned long *cpu_addr;
42399         TW_New_Ioctl *tw_ioctl;
42400         TW_Passthru *passthru;
42401 -       TW_Device_Extension *tw_dev = tw_device_extension_list[minor(inode->i_rdev)];
42402 +       TW_Device_Extension *tw_dev = tw_device_extension_list[iminor(inode)];
42403         int retval = -EFAULT;
42404  
42405         dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n");
42406 @@ -786,7 +786,7 @@
42407  
42408         dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n");
42409  
42410 -       minor_number = minor(inode->i_rdev);
42411 +       minor_number = iminor(inode);
42412         if (minor_number >= tw_device_extension_count)
42413                 return -ENODEV;
42414  
42415 diff -Nru a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
42416 --- a/drivers/scsi/aacraid/linit.c      Thu Jul 31 07:32:16 2003
42417 +++ b/drivers/scsi/aacraid/linit.c      Tue Aug 26 09:25:41 2003
42418 @@ -565,7 +565,7 @@
42419  
42420  static int aac_cfg_open(struct inode * inode, struct file * file )
42421  {
42422 -       unsigned minor_number = minor(inode->i_rdev);
42423 +       unsigned minor_number = iminor(inode);
42424         if(minor_number >= aac_count)
42425                 return -ENODEV;
42426         return 0;
42427 @@ -601,7 +601,7 @@
42428   
42429  static int aac_cfg_ioctl(struct inode * inode,  struct file * file, unsigned int cmd, unsigned long arg )
42430  {
42431 -       struct aac_dev *dev = aac_devices[minor(inode->i_rdev)];
42432 +       struct aac_dev *dev = aac_devices[iminor(inode)];
42433         return aac_do_ioctl(dev, cmd, (void *)arg);
42434  }
42435  
42436 diff -Nru a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
42437 --- a/drivers/scsi/advansys.c   Fri May  2 12:35:39 2003
42438 +++ b/drivers/scsi/advansys.c   Sun Aug 31 16:15:44 2003
42439 @@ -6199,7 +6199,9 @@
42440  
42441  static Scsi_Host_Template driver_template = {
42442      .proc_name                  = "advansys",
42443 +#ifdef CONFIG_PROC_FS
42444      .proc_info                  = advansys_proc_info,
42445 +#endif
42446      .name                       = "advansys",
42447      .detect                     = advansys_detect, 
42448      .release                    = advansys_release,
42449 diff -Nru a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
42450 --- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c    Thu Jun 19 16:46:06 2003
42451 +++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c    Sun Aug 31 16:14:08 2003
42452 @@ -72,10 +72,10 @@
42453  MODULE_DEVICE_TABLE(pci, ahd_linux_pci_id_table);
42454  
42455  struct pci_driver aic79xx_pci_driver = {
42456 -       name:           "aic79xx",
42457 -       probe:          ahd_linux_pci_dev_probe,
42458 -       remove:         ahd_linux_pci_dev_remove,
42459 -       id_table:       ahd_linux_pci_id_table
42460 +       .name           = "aic79xx",
42461 +       .probe          = ahd_linux_pci_dev_probe,
42462 +       .remove         = ahd_linux_pci_dev_remove,
42463 +       .id_table       = ahd_linux_pci_id_table
42464  };
42465  
42466  static void
42467 diff -Nru a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
42468 --- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c    Wed May 14 15:00:40 2003
42469 +++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c    Sun Aug 31 16:14:08 2003
42470 @@ -75,10 +75,10 @@
42471  MODULE_DEVICE_TABLE(pci, ahc_linux_pci_id_table);
42472  
42473  struct pci_driver aic7xxx_pci_driver = {
42474 -       name:           "aic7xxx",
42475 -       probe:          ahc_linux_pci_dev_probe,
42476 -       remove:         ahc_linux_pci_dev_remove,
42477 -       id_table:       ahc_linux_pci_id_table
42478 +       .name           = "aic7xxx",
42479 +       .probe          = ahc_linux_pci_dev_probe,
42480 +       .remove         = ahc_linux_pci_dev_remove,
42481 +       .id_table       = ahc_linux_pci_id_table
42482  };
42483  
42484  static void
42485 diff -Nru a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
42486 --- a/drivers/scsi/dpt_i2o.c    Fri May  2 12:45:47 2003
42487 +++ b/drivers/scsi/dpt_i2o.c    Tue Aug 26 09:25:41 2003
42488 @@ -1551,7 +1551,7 @@
42489  
42490         //TODO check for root access
42491         //
42492 -       minor = minor(inode->i_rdev);
42493 +       minor = iminor(inode);
42494         if (minor >= hba_count) {
42495                 return -ENXIO;
42496         }
42497 @@ -1582,7 +1582,7 @@
42498         int minor;
42499         adpt_hba* pHba;
42500  
42501 -       minor = minor(inode->i_rdev);
42502 +       minor = iminor(inode);
42503         if (minor >= hba_count) {
42504                 return -ENXIO;
42505         }
42506 @@ -1878,7 +1878,7 @@
42507         adpt_hba* pHba;
42508         ulong flags;
42509  
42510 -       minor = minor(inode->i_rdev);
42511 +       minor = iminor(inode);
42512         if (minor >= DPTI_MAX_HBA){
42513                 return -ENXIO;
42514         }
42515 diff -Nru a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
42516 --- a/drivers/scsi/hosts.c      Sat Aug 16 16:09:46 2003
42517 +++ b/drivers/scsi/hosts.c      Sun Aug 31 16:15:45 2003
42518 @@ -158,7 +158,13 @@
42519         scsi_proc_hostdir_rm(shost->hostt);
42520         scsi_destroy_command_freelist(shost);
42521  
42522 -       put_device(parent);
42523 +       /*
42524 +        * Some drivers (eg aha1542) do scsi_register()/scsi_unregister()
42525 +        * during probing without performing a scsi_set_device() in between.
42526 +        * In this case dev->parent is NULL.
42527 +        */
42528 +       if (parent)
42529 +               put_device(parent);
42530         kfree(shost);
42531  }
42532  
42533 diff -Nru a/drivers/scsi/hosts.h b/drivers/scsi/hosts.h
42534 --- a/drivers/scsi/hosts.h      Mon Jun 23 04:00:34 2003
42535 +++ b/drivers/scsi/hosts.h      Mon Sep  1 13:56:57 2003
42536 @@ -25,7 +25,6 @@
42537  #define _HOSTS_H
42538  
42539  #include <linux/config.h>
42540 -#include <linux/proc_fs.h>
42541  
42542  #include <scsi/scsi_host.h>
42543  
42544 diff -Nru a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
42545 --- a/drivers/scsi/megaraid.c   Sat Aug 16 11:46:50 2003
42546 +++ b/drivers/scsi/megaraid.c   Mon Sep  1 13:56:57 2003
42547 @@ -36,6 +36,7 @@
42548  #include <asm/uaccess.h>
42549  #include <asm/io.h>
42550  #include <linux/delay.h>
42551 +#include <linux/proc_fs.h>
42552  #include <linux/reboot.h>
42553  #include <linux/module.h>
42554  #include <linux/list.h>
42555 diff -Nru a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
42556 --- a/drivers/scsi/nsp32.c      Tue Aug 19 12:35:44 2003
42557 +++ b/drivers/scsi/nsp32.c      Sun Aug 31 16:14:08 2003
42558 @@ -2809,13 +2809,13 @@
42559                 for (j = 0; j < NUMBER(data->lunt[0]); j++) {
42560                         int offset = i * NUMBER(data->lunt[0]) + j;
42561                         nsp32_lunt tmp = {
42562 -                               SCpnt:       NULL,
42563 -                               save_datp:   0,
42564 -                               msgin03:     FALSE,
42565 -                               sg_num:      0,
42566 -                               cur_entry:   0,
42567 -                               sglun:       &(data->sg_list[offset]),
42568 -                               sglun_paddr: data->sg_paddr + (offset * sizeof(nsp32_sglun)),
42569 +                               .SCpnt       = NULL,
42570 +                               .save_datp   = 0,
42571 +                               .msgin03     = FALSE,
42572 +                               .sg_num      = 0,
42573 +                               .cur_entry   = 0,
42574 +                               .sglun       = &(data->sg_list[offset]),
42575 +                               .sglun_paddr = data->sg_paddr + (offset * sizeof(nsp32_sglun)),
42576                         };
42577  
42578                         data->lunt[i][j] = tmp;
42579 diff -Nru a/drivers/scsi/osst.c b/drivers/scsi/osst.c
42580 --- a/drivers/scsi/osst.c       Fri May  2 12:38:35 2003
42581 +++ b/drivers/scsi/osst.c       Tue Aug 26 09:25:41 2003
42582 @@ -132,9 +132,9 @@
42583  #define OSST_TIMEOUT (200 * HZ)
42584  #define OSST_LONG_TIMEOUT (1800 * HZ)
42585  
42586 -#define TAPE_NR(x) (minor(x) & ~(-1 << ST_MODE_SHIFT))
42587 -#define TAPE_MODE(x) ((minor(x) & ST_MODE_MASK) >> ST_MODE_SHIFT)
42588 -#define TAPE_REWIND(x) ((minor(x) & 0x80) == 0)
42589 +#define TAPE_NR(x) (iminor(x) & ~(-1 << ST_MODE_SHIFT))
42590 +#define TAPE_MODE(x) ((iminor(x) & ST_MODE_MASK) >> ST_MODE_SHIFT)
42591 +#define TAPE_REWIND(x) ((iminor(x) & 0x80) == 0)
42592  #define TAPE_IS_RAW(x) (TAPE_MODE(x) & (ST_NBR_MODES >> 1))
42593  
42594  /* Internal ioctl to set both density (uppermost 8 bits) and blocksize (lower
42595 @@ -4215,8 +4215,8 @@
42596         ST_mode      * STm;
42597         ST_partstat  * STps;
42598         char         * name;
42599 -       int            dev  = TAPE_NR(inode->i_rdev);
42600 -       int            mode = TAPE_MODE(inode->i_rdev);
42601 +       int            dev  = TAPE_NR(inode);
42602 +       int            mode = TAPE_MODE(inode);
42603  
42604         write_lock(&os_scsi_tapes_lock);
42605         if (dev >= osst_max_dev || os_scsi_tapes == NULL ||
42606 @@ -4244,7 +4244,7 @@
42607         filp->private_data = STp;
42608         STp->in_use = 1;
42609         write_unlock(&os_scsi_tapes_lock);
42610 -       STp->rew_at_close = TAPE_REWIND(inode->i_rdev);
42611 +       STp->rew_at_close = TAPE_REWIND(inode);
42612  
42613         if( !scsi_block_when_processing_errors(STp->device) ) {
42614                 return -ENXIO;
42615 @@ -4264,7 +4264,7 @@
42616         flags = filp->f_flags;
42617         STp->write_prot = ((flags & O_ACCMODE) == O_RDONLY);
42618  
42619 -       STp->raw = TAPE_IS_RAW(inode->i_rdev);
42620 +       STp->raw = TAPE_IS_RAW(inode);
42621         if (STp->raw)
42622                 STp->header_ok = 0;
42623  
42624 diff -Nru a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42625 --- a/drivers/scsi/sg.c Sat Aug 16 11:46:50 2003
42626 +++ b/drivers/scsi/sg.c Tue Aug 26 09:25:41 2003
42627 @@ -238,7 +238,7 @@
42628  static int
42629  sg_open(struct inode *inode, struct file *filp)
42630  {
42631 -       int dev = minor(inode->i_rdev);
42632 +       int dev = iminor(inode);
42633         int flags = filp->f_flags;
42634         Sg_device *sdp;
42635         Sg_fd *sfp;
42636 diff -Nru a/drivers/scsi/sr.c b/drivers/scsi/sr.c
42637 --- a/drivers/scsi/sr.c Thu Jul 31 08:28:30 2003
42638 +++ b/drivers/scsi/sr.c Mon Sep  1 06:28:41 2003
42639 @@ -695,6 +695,10 @@
42640         unsigned char *buffer;
42641         int rc, n;
42642         struct scsi_mode_data data;
42643 +       struct scsi_request *SRpnt;
42644 +       unsigned char cmd[MAX_COMMAND_SIZE];
42645 +       unsigned int the_result;
42646 +       int retries;
42647  
42648         static char *loadmech[] =
42649         {
42650 @@ -708,11 +712,46 @@
42651                 ""
42652         };
42653  
42654 +       /* allocate a request for the TEST_UNIT_READY */
42655 +       SRpnt = scsi_allocate_request(cd->device);
42656 +       if (!SRpnt) {
42657 +               printk(KERN_WARNING "(get_capabilities:) Request allocation "
42658 +                      "failure.\n");
42659 +               return;
42660 +       }
42661 +
42662 +       /* allocate transfer buffer */
42663         buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
42664         if (!buffer) {
42665                 printk(KERN_ERR "sr: out of memory.\n");
42666 +               scsi_release_request(SRpnt);
42667                 return;
42668         }
42669 +
42670 +       /* issue TEST_UNIT_READY until the initial startup UNIT_ATTENTION
42671 +        * conditions are gone, or a timeout happens
42672 +        */
42673 +       retries = 0;
42674 +       do {
42675 +               memset((void *)cmd, 0, MAX_COMMAND_SIZE);
42676 +               cmd[0] = TEST_UNIT_READY;
42677 +
42678 +               SRpnt->sr_cmd_len = 0;
42679 +               SRpnt->sr_sense_buffer[0] = 0;
42680 +               SRpnt->sr_sense_buffer[2] = 0;
42681 +               SRpnt->sr_data_direction = DMA_NONE;
42682 +
42683 +               scsi_wait_req (SRpnt, (void *) cmd, buffer,
42684 +                              0, SR_TIMEOUT, MAX_RETRIES);
42685 +
42686 +               the_result = SRpnt->sr_result;
42687 +               retries++;
42688 +       } while (retries < 5 && 
42689 +                (!scsi_status_is_good(the_result) ||
42690 +                 ((driver_byte(the_result) & DRIVER_SENSE) &&
42691 +                  SRpnt->sr_sense_buffer[2] == UNIT_ATTENTION)));
42692 +
42693 +       /* ask for mode page 0x2a */
42694         rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128,
42695                              SR_TIMEOUT, 3, &data);
42696  
42697 @@ -722,6 +761,7 @@
42698                 cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R |
42699                                          CDC_DVD | CDC_DVD_RAM |
42700                                          CDC_SELECT_DISC | CDC_SELECT_SPEED);
42701 +               scsi_release_request(SRpnt);
42702                 kfree(buffer);
42703                 printk("%s: scsi-1 drive\n", cd->cdi.name);
42704                 return;
42705 @@ -775,6 +815,7 @@
42706         /*else    I don't think it can close its tray
42707                 cd->cdi.mask |= CDC_CLOSE_TRAY; */
42708  
42709 +       scsi_release_request(SRpnt);
42710         kfree(buffer);
42711  }
42712  
42713 diff -Nru a/drivers/scsi/st.c b/drivers/scsi/st.c
42714 --- a/drivers/scsi/st.c Mon Aug 11 11:44:45 2003
42715 +++ b/drivers/scsi/st.c Tue Aug 26 12:05:16 2003
42716 @@ -140,8 +140,8 @@
42717  #define ST_TIMEOUT (900 * HZ)
42718  #define ST_LONG_TIMEOUT (14000 * HZ)
42719  
42720 -#define TAPE_NR(x) (minor(x) & ~(-1 << ST_MODE_SHIFT))
42721 -#define TAPE_MODE(x) ((minor(x) & ST_MODE_MASK) >> ST_MODE_SHIFT)
42722 +#define TAPE_NR(x) (iminor(x) & ~(-1 << ST_MODE_SHIFT))
42723 +#define TAPE_MODE(x) ((iminor(x) & ST_MODE_MASK) >> ST_MODE_SHIFT)
42724  
42725  /* Internal ioctl to set both density (uppermost 8 bits) and blocksize (lower
42726     24 bits) */
42727 @@ -786,7 +786,7 @@
42728         ST_partstat *STps;
42729         char *name = tape_name(STp);
42730         struct inode *inode = filp->f_dentry->d_inode;
42731 -       int mode = TAPE_MODE(inode->i_rdev);
42732 +       int mode = TAPE_MODE(inode);
42733  
42734         STp->ready = ST_READY;
42735  
42736 @@ -980,7 +980,7 @@
42737         int i, retval = (-EIO);
42738         Scsi_Tape *STp;
42739         ST_partstat *STps;
42740 -       int dev = TAPE_NR(inode->i_rdev);
42741 +       int dev = TAPE_NR(inode);
42742         char *name;
42743  
42744         write_lock(&st_dev_arr_lock);
42745 @@ -1004,7 +1004,7 @@
42746         }
42747         STp->in_use = 1;
42748         write_unlock(&st_dev_arr_lock);
42749 -       STp->rew_at_close = STp->autorew_dev = (minor(inode->i_rdev) & 0x80) == 0;
42750 +       STp->rew_at_close = STp->autorew_dev = (iminor(inode) & 0x80) == 0;
42751  
42752  
42753         if (!scsi_block_when_processing_errors(STp->device)) {
42754 diff -Nru a/drivers/serial/Kconfig b/drivers/serial/Kconfig
42755 --- a/drivers/serial/Kconfig    Fri Aug  1 03:02:30 2003
42756 +++ b/drivers/serial/Kconfig    Sun Aug 24 08:17:18 2003
42757 @@ -430,12 +430,12 @@
42758  
42759  config SERIAL_CORE
42760         tristate
42761 -       default m if SERIAL_AMBA!=y && SERIAL_CLPS711X!=y && SERIAL_21285!=y && !SERIAL_SA1100 && !SERIAL_ANAKIN && !SERIAL_UART00 && SERIAL_8250!=y && SERIAL_MUX!=y && !SERIAL_ROCKETPORT && !SERIAL_SUNCORE && !V850E_UART && (SERIAL_AMBA=m || SERIAL_CLPS711X=m || SERIAL_21285=m || SERIAL_8250=m || SERIAL_MUX=m || SERIAL98=m)
42762 -       default y if SERIAL_AMBA=y || SERIAL_CLPS711X=y || SERIAL_21285=y || SERIAL_SA1100 || SERIAL_ANAKIN || SERIAL_UART00 || SERIAL_8250=y || SERIAL_MUX=y || SERIAL_ROCKETPORT || SERIAL_SUNCORE || V850E_UART || SERIAL98=y
42763 +       default m if SERIAL_AMBA!=y && SERIAL_CLPS711X!=y && SERIAL_21285!=y && !SERIAL_SA1100 && !SERIAL_ANAKIN && !SERIAL_UART00 && SERIAL_8250!=y && SERIAL_MUX!=y && !SERIAL_ROCKETPORT && !SERIAL_SUNCORE && !V850E_UART && SERIAL_PMACZILOG!=y && (SERIAL_AMBA=m || SERIAL_CLPS711X=m || SERIAL_21285=m || SERIAL_8250=m || SERIAL_MUX=m || SERIAL98=m || SERIAL_PMACZILOG=m)
42764 +       default y if SERIAL_AMBA=y || SERIAL_CLPS711X=y || SERIAL_21285=y || SERIAL_SA1100 || SERIAL_ANAKIN || SERIAL_UART00 || SERIAL_8250=y || SERIAL_MUX=y || SERIAL_ROCKETPORT || SERIAL_SUNCORE || V850E_UART || SERIAL98=y || SERIAL_PMACZILOG=y
42765  
42766  config SERIAL_CORE_CONSOLE
42767         bool
42768 -       depends on SERIAL_AMBA_CONSOLE || SERIAL_CLPS711X_CONSOLE || SERIAL_21285_CONSOLE || SERIAL_SA1100_CONSOLE || SERIAL_ANAKIN_CONSOLE || SERIAL_UART00_CONSOLE || SERIAL_8250_CONSOLE || SERIAL_MUX_CONSOLE || SERIAL_SUNZILOG_CONSOLE || SERIAL_SUNSU_CONSOLE || SERIAL_SUNSAB_CONSOLE || V850E_UART_CONSOLE || SERIAL98_CONSOLE
42769 +       depends on SERIAL_AMBA_CONSOLE || SERIAL_CLPS711X_CONSOLE || SERIAL_21285_CONSOLE || SERIAL_SA1100_CONSOLE || SERIAL_ANAKIN_CONSOLE || SERIAL_UART00_CONSOLE || SERIAL_8250_CONSOLE || SERIAL_MUX_CONSOLE || SERIAL_SUNZILOG_CONSOLE || SERIAL_SUNSU_CONSOLE || SERIAL_SUNSAB_CONSOLE || V850E_UART_CONSOLE || SERIAL98_CONSOLE || SERIAL_PMACZILOG_CONSOLE
42770         default y
42771  
42772  config SERIAL_68328
42773 @@ -472,6 +472,22 @@
42774         bool
42775         depends on SERIAL_68360_SMC || SERIAL_68360_SCC
42776         default y
42777 +
42778 +config SERIAL_PMACZILOG
42779 +       tristate "PowerMac z85c30 ESCC support"
42780 +       depends on PPC_OF
42781 +       help
42782 +         This driver supports the Zilog z85C30 serial ports found on
42783 +         PowerMac machines.
42784 +         Say Y or M if you want to be able to these serial ports.
42785 +
42786 +config SERIAL_PMACZILOG_CONSOLE
42787 +       bool "Console on PowerMac z85c30 serial port"
42788 +       depends on SERIAL_PMACZILOG=y
42789 +       help
42790 +         If you would like to be able to use the z85c30 serial port
42791 +         on your PowerMac as the console, you can do so by answering
42792 +         Y to this option.
42793  
42794  endmenu
42795  
42796 diff -Nru a/drivers/serial/Makefile b/drivers/serial/Makefile
42797 --- a/drivers/serial/Makefile   Tue Jul 15 03:23:50 2003
42798 +++ b/drivers/serial/Makefile   Sun Aug 24 08:17:18 2003
42799 @@ -31,3 +31,4 @@
42800  obj-$(CONFIG_SERIAL_COLDFIRE) += mcfserial.o
42801  obj-$(CONFIG_V850E_UART) += v850e_uart.o
42802  obj-$(CONFIG_SERIAL98) += serial98.o
42803 +obj-$(CONFIG_SERIAL_PMACZILOG) += pmac_zilog.o
42804 diff -Nru a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c
42805 --- /dev/null   Wed Dec 31 16:00:00 1969
42806 +++ b/drivers/serial/pmac_zilog.c       Sun Aug 24 08:05:53 2003
42807 @@ -0,0 +1,1626 @@
42808 +/*
42809 + * linux/drivers/serial/pmac_zilog.c
42810 + * 
42811 + * Driver for PowerMac Z85c30 based ESCC cell found in the
42812 + * "macio" ASICs of various PowerMac models
42813 + * 
42814 + * Copyright (C) 2003 Ben. Herrenschmidt (benh@kernel.crashing.org)
42815 + *
42816 + * Derived from drivers/macintosh/macserial.c by Paul Mackerras
42817 + * and drivers/serial/sunzilog.c by David S. Miller
42818 + *
42819 + * Hrm... actually, I ripped most of sunzilog (Thanks David !) and
42820 + * adapted special tweaks needed for us. I don't think it's worth
42821 + * merging back those though. The DMA code still has to get in
42822 + * and once done, I expect that driver to remain fairly stable in
42823 + * the long term, unless we change the driver model again...
42824 + *
42825 + * This program is free software; you can redistribute it and/or modify
42826 + * it under the terms of the GNU General Public License as published by
42827 + * the Free Software Foundation; either version 2 of the License, or
42828 + * (at your option) any later version.
42829 + *
42830 + * This program is distributed in the hope that it will be useful,
42831 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
42832 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
42833 + * GNU General Public License for more details.
42834 + *
42835 + * You should have received a copy of the GNU General Public License
42836 + * along with this program; if not, write to the Free Software
42837 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
42838 + *
42839 + * TODO:   - Add DMA support
42840 + *         - Defer port shutdown to a few seconds after close
42841 + *         - maybe put something right into up->clk_divisor
42842 + */
42843 +
42844 +#undef DEBUG
42845 +
42846 +#include <linux/config.h>
42847 +#include <linux/module.h>
42848 +#include <linux/tty.h>
42849 +
42850 +#include <linux/tty_flip.h>
42851 +#include <linux/major.h>
42852 +#include <linux/string.h>
42853 +#include <linux/fcntl.h>
42854 +#include <linux/mm.h>
42855 +#include <linux/kernel.h>
42856 +#include <linux/delay.h>
42857 +#include <linux/init.h>
42858 +#include <linux/console.h>
42859 +#include <linux/slab.h>
42860 +#include <linux/adb.h>
42861 +#include <linux/pmu.h>
42862 +#include <asm/sections.h>
42863 +#include <asm/io.h>
42864 +#include <asm/irq.h>
42865 +#include <asm/prom.h>
42866 +#include <asm/bitops.h>
42867 +#include <asm/machdep.h>
42868 +#include <asm/pmac_feature.h>
42869 +#include <asm/kgdb.h>
42870 +#include <asm/dbdma.h>
42871 +#include <asm/macio.h>
42872 +
42873 +#include <linux/serial.h>
42874 +#include <linux/serial_core.h>
42875 +
42876 +#include "pmac_zilog.h"
42877 +
42878 +
42879 +/* Not yet implemented */
42880 +#undef HAS_DBDMA
42881 +
42882 +static char version[] __initdata = "pmac_zilog.c 0.5a (Benjamin Herrenschmidt <benh@kernel.crashing.org>)";
42883 +MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
42884 +MODULE_DESCRIPTION("Driver for the PowerMac serial ports.");
42885 +MODULE_LICENSE("GPL");
42886 +
42887 +#define PWRDBG(fmt, arg...)    printk(KERN_DEBUG fmt , ## arg)
42888 +
42889 +
42890 +/*
42891 + * For the sake of early serial console, we can do a pre-probe
42892 + * (optional) of the ports at rather early boot time.
42893 + */
42894 +static struct uart_pmac_port   pmz_ports[MAX_ZS_PORTS];
42895 +static int                     pmz_ports_count;
42896 +
42897 +
42898 +/* 
42899 + * Load all registers to reprogram the port
42900 + * This function must only be called when the TX is not busy.  The UART
42901 + * port lock must be held and local interrupts disabled.
42902 + */
42903 +static void pmz_load_zsregs(struct uart_pmac_port *up, u8 *regs)
42904 +{
42905 +       int i;
42906 +
42907 +       /* Let pending transmits finish.  */
42908 +       for (i = 0; i < 1000; i++) {
42909 +               unsigned char stat = read_zsreg(up, R1);
42910 +               if (stat & ALL_SNT)
42911 +                       break;
42912 +               udelay(100);
42913 +       }
42914 +
42915 +       ZS_CLEARERR(up);
42916 +       zssync(up);
42917 +       ZS_CLEARFIFO(up);
42918 +       zssync(up);
42919 +       ZS_CLEARERR(up);
42920 +
42921 +       /* Disable all interrupts.  */
42922 +       write_zsreg(up, R1,
42923 +                   regs[R1] & ~(RxINT_MASK | TxINT_ENAB | EXT_INT_ENAB));
42924 +
42925 +       /* Set parity, sync config, stop bits, and clock divisor.  */
42926 +       write_zsreg(up, R4, regs[R4]);
42927 +
42928 +       /* Set misc. TX/RX control bits.  */
42929 +       write_zsreg(up, R10, regs[R10]);
42930 +
42931 +       /* Set TX/RX controls sans the enable bits.  */
42932 +       write_zsreg(up, R3, regs[R3] & ~RxENABLE);
42933 +       write_zsreg(up, R5, regs[R5] & ~TxENABLE);
42934 +
42935 +       /* Synchronous mode config.  */
42936 +       write_zsreg(up, R6, regs[R6]);
42937 +       write_zsreg(up, R7, regs[R7]);
42938 +
42939 +       /* Disable baud generator.  */
42940 +       write_zsreg(up, R14, regs[R14] & ~BRENAB);
42941 +
42942 +       /* Clock mode control.  */
42943 +       write_zsreg(up, R11, regs[R11]);
42944 +
42945 +       /* Lower and upper byte of baud rate generator divisor.  */
42946 +       write_zsreg(up, R12, regs[R12]);
42947 +       write_zsreg(up, R13, regs[R13]);
42948 +       
42949 +       /* Now rewrite R14, with BRENAB (if set).  */
42950 +       write_zsreg(up, R14, regs[R14]);
42951 +
42952 +       /* External status interrupt control.  */
42953 +       write_zsreg(up, R15, regs[R15]);
42954 +
42955 +       /* Reset external status interrupts.  */
42956 +       write_zsreg(up, R0, RES_EXT_INT);
42957 +       write_zsreg(up, R0, RES_EXT_INT);
42958 +
42959 +       /* Rewrite R3/R5, this time without enables masked.  */
42960 +       write_zsreg(up, R3, regs[R3]);
42961 +       write_zsreg(up, R5, regs[R5]);
42962 +
42963 +       /* Rewrite R1, this time without IRQ enabled masked.  */
42964 +       write_zsreg(up, R1, regs[R1]);
42965 +
42966 +       /* Enable interrupts */
42967 +       write_zsreg(up, R9, regs[R9]);
42968 +}
42969 +
42970 +/* 
42971 + * We do like sunzilog to avoid disrupting pending Tx
42972 + * Reprogram the Zilog channel HW registers with the copies found in the
42973 + * software state struct.  If the transmitter is busy, we defer this update
42974 + * until the next TX complete interrupt.  Else, we do it right now.
42975 + *
42976 + * The UART port lock must be held and local interrupts disabled.
42977 + */
42978 +static void pmz_maybe_update_regs(struct uart_pmac_port *up)
42979 +{
42980 +#if 1
42981 +               if (!ZS_REGS_HELD(up)) {
42982 +               if (ZS_TX_ACTIVE(up)) {
42983 +                       up->flags |= PMACZILOG_FLAG_REGS_HELD;
42984 +               } else {
42985 +                       pr_debug("pmz: maybe_update_regs: updating\n");
42986 +                       pmz_load_zsregs(up, up->curregs);
42987 +               }
42988 +       }
42989 +#else
42990 +               pr_debug("pmz: maybe_update_regs: updating\n");
42991 +        pmz_load_zsregs(up, up->curregs);
42992 +#endif
42993 +}
42994 +
42995 +static void pmz_receive_chars(struct uart_pmac_port *up, struct pt_regs *regs)
42996 +{
42997 +       struct tty_struct *tty = up->port.info->tty;    /* XXX info==NULL? */
42998 +
42999 +       while (1) {
43000 +               unsigned char ch, r1;
43001 +
43002 +               if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) {
43003 +                       tty->flip.work.func((void *)tty);
43004 +                       if (tty->flip.count >= TTY_FLIPBUF_SIZE)
43005 +                               /* XXX Ignores SysRq when we need it most. Fix. */
43006 +                               return; 
43007 +               }
43008 +
43009 +               r1 = read_zsreg(up, R1);
43010 +               if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR)) {
43011 +                       write_zsreg(up, R0, ERR_RES);
43012 +                       zssync(up);
43013 +               }
43014 +
43015 +               ch = read_zsreg(up, R0);
43016 +
43017 +               /* This funny hack depends upon BRK_ABRT not interfering
43018 +                * with the other bits we care about in R1.
43019 +                */
43020 +               if (ch & BRK_ABRT)
43021 +                       r1 |= BRK_ABRT;
43022 +
43023 +               ch = read_zsdata(up);
43024 +               ch &= up->parity_mask;
43025 +
43026 +               /* A real serial line, record the character and status.  */
43027 +               *tty->flip.char_buf_ptr = ch;
43028 +               *tty->flip.flag_buf_ptr = TTY_NORMAL;
43029 +               up->port.icount.rx++;
43030 +               if (r1 & (BRK_ABRT | PAR_ERR | Rx_OVR | CRC_ERR)) {
43031 +                       if (r1 & BRK_ABRT) {
43032 +                               r1 &= ~(PAR_ERR | CRC_ERR);
43033 +                               up->port.icount.brk++;
43034 +                               if (uart_handle_break(&up->port))
43035 +                                       goto next_char;
43036 +                       }
43037 +                       else if (r1 & PAR_ERR)
43038 +                               up->port.icount.parity++;
43039 +                       else if (r1 & CRC_ERR)
43040 +                               up->port.icount.frame++;
43041 +                       if (r1 & Rx_OVR)
43042 +                               up->port.icount.overrun++;
43043 +                       r1 &= up->port.read_status_mask;
43044 +                       if (r1 & BRK_ABRT)
43045 +                               *tty->flip.flag_buf_ptr = TTY_BREAK;
43046 +                       else if (r1 & PAR_ERR)
43047 +                               *tty->flip.flag_buf_ptr = TTY_PARITY;
43048 +                       else if (r1 & CRC_ERR)
43049 +                               *tty->flip.flag_buf_ptr = TTY_FRAME;
43050 +               }
43051 +               if (uart_handle_sysrq_char(&up->port, ch, regs))
43052 +                       goto next_char;
43053 +
43054 +               if (up->port.ignore_status_mask == 0xff ||
43055 +                   (r1 & up->port.ignore_status_mask) == 0) {
43056 +                       tty->flip.flag_buf_ptr++;
43057 +                       tty->flip.char_buf_ptr++;
43058 +                       tty->flip.count++;
43059 +               }
43060 +               if ((r1 & Rx_OVR) &&
43061 +                   tty->flip.count < TTY_FLIPBUF_SIZE) {
43062 +                       *tty->flip.flag_buf_ptr = TTY_OVERRUN;
43063 +                       tty->flip.flag_buf_ptr++;
43064 +                       tty->flip.char_buf_ptr++;
43065 +                       tty->flip.count++;
43066 +               }
43067 +       next_char:
43068 +               ch = read_zsreg(up, R0);
43069 +               if (!(ch & Rx_CH_AV))
43070 +                       break;
43071 +       }
43072 +
43073 +       tty_flip_buffer_push(tty);
43074 +}
43075 +
43076 +static void pmz_status_handle(struct uart_pmac_port *up, struct pt_regs *regs)
43077 +{
43078 +       unsigned char status;
43079 +
43080 +       status = read_zsreg(up, R0);
43081 +       write_zsreg(up, R0, RES_EXT_INT);
43082 +       zssync(up);
43083 +
43084 +       if (ZS_WANTS_MODEM_STATUS(up)) {
43085 +               if (status & SYNC_HUNT)
43086 +                       up->port.icount.dsr++;
43087 +
43088 +               /* The Zilog just gives us an interrupt when DCD/CTS/etc. change.
43089 +                * But it does not tell us which bit has changed, we have to keep
43090 +                * track of this ourselves.
43091 +                */
43092 +               if ((status & DCD) ^ up->prev_status)
43093 +                       uart_handle_dcd_change(&up->port,
43094 +                                              (status & DCD));
43095 +               if ((status & CTS) ^ up->prev_status)
43096 +                       uart_handle_cts_change(&up->port,
43097 +                                              (status & CTS));
43098 +
43099 +               wake_up_interruptible(&up->port.info->delta_msr_wait);
43100 +       }
43101 +
43102 +       up->prev_status = status;
43103 +}
43104 +
43105 +static void pmz_transmit_chars(struct uart_pmac_port *up)
43106 +{
43107 +       struct circ_buf *xmit;
43108 +
43109 +       if (ZS_IS_CONS(up)) {
43110 +               unsigned char status = read_zsreg(up, R0);
43111 +
43112 +               /* TX still busy?  Just wait for the next TX done interrupt.
43113 +                *
43114 +                * It can occur because of how we do serial console writes.  It would
43115 +                * be nice to transmit console writes just like we normally would for
43116 +                * a TTY line. (ie. buffered and TX interrupt driven).  That is not
43117 +                * easy because console writes cannot sleep.  One solution might be
43118 +                * to poll on enough port->xmit space becomming free.  -DaveM
43119 +                */
43120 +               if (!(status & Tx_BUF_EMP))
43121 +                       return;
43122 +       }
43123 +
43124 +       up->flags &= ~PMACZILOG_FLAG_TX_ACTIVE;
43125 +
43126 +       if (ZS_REGS_HELD(up)) {
43127 +               pmz_load_zsregs(up, up->curregs);
43128 +               up->flags &= ~PMACZILOG_FLAG_REGS_HELD;
43129 +       }
43130 +
43131 +       if (ZS_TX_STOPPED(up)) {
43132 +               up->flags &= ~PMACZILOG_FLAG_TX_STOPPED;
43133 +               goto ack_tx_int;
43134 +       }
43135 +
43136 +       if (up->port.x_char) {
43137 +               up->flags |= PMACZILOG_FLAG_TX_ACTIVE;
43138 +               write_zsdata(up, up->port.x_char);
43139 +               zssync(up);
43140 +               up->port.icount.tx++;
43141 +               up->port.x_char = 0;
43142 +               return;
43143 +       }
43144 +
43145 +       if (up->port.info == NULL)
43146 +               goto ack_tx_int;
43147 +       xmit = &up->port.info->xmit;
43148 +       if (uart_circ_empty(xmit)) {
43149 +               uart_write_wakeup(&up->port);
43150 +               goto ack_tx_int;
43151 +       }
43152 +       if (uart_tx_stopped(&up->port))
43153 +               goto ack_tx_int;
43154 +
43155 +       up->flags |= PMACZILOG_FLAG_TX_ACTIVE;
43156 +       write_zsdata(up, xmit->buf[xmit->tail]);
43157 +       zssync(up);
43158 +
43159 +       xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
43160 +       up->port.icount.tx++;
43161 +
43162 +       if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
43163 +               uart_write_wakeup(&up->port);
43164 +
43165 +       return;
43166 +
43167 +ack_tx_int:
43168 +       write_zsreg(up, R0, RES_Tx_P);
43169 +       zssync(up);
43170 +}
43171 +
43172 +/* Hrm... we register that twice, fixme later.... */
43173 +static irqreturn_t pmz_interrupt(int irq, void *dev_id, struct pt_regs *regs)
43174 +{
43175 +       struct uart_pmac_port *up = dev_id;
43176 +       struct uart_pmac_port *up_a;
43177 +       struct uart_pmac_port *up_b;
43178 +       int rc = IRQ_NONE;
43179 +       u8 r3;
43180 +
43181 +       up_a = ZS_IS_CHANNEL_A(up) ? up : up->mate;
43182 +       up_b = up_a->mate;
43183 +       
43184 +               spin_lock(&up_a->port.lock);
43185 +       r3 = read_zsreg(up, R3);
43186 +       pr_debug("pmz_irq: %x\n", r3);
43187 +
43188 +               /* Channel A */
43189 +               if (r3 & (CHAEXT | CHATxIP | CHARxIP)) {
43190 +               write_zsreg(up_a, R0, RES_H_IUS);
43191 +               zssync(up_a);           
43192 +               pr_debug("pmz: irq channel A: %x\n", r3);
43193 +               if (r3 & CHARxIP)
43194 +                       pmz_receive_chars(up_a, regs);
43195 +                       if (r3 & CHAEXT)
43196 +                               pmz_status_handle(up_a, regs);
43197 +                       if (r3 & CHATxIP)
43198 +                               pmz_transmit_chars(up_a);
43199 +               rc = IRQ_HANDLED;
43200 +               }
43201 +               spin_unlock(&up_a->port.lock);
43202 +       
43203 +               spin_lock(&up_b->port.lock);
43204 +       if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) {
43205 +               write_zsreg(up_b, R0, RES_H_IUS);
43206 +               zssync(up_b);
43207 +               pr_debug("pmz: irq channel B: %x\n", r3);
43208 +                       if (r3 & CHBRxIP)
43209 +                               pmz_receive_chars(up_b, regs);
43210 +                       if (r3 & CHBEXT)
43211 +                               pmz_status_handle(up_b, regs);
43212 +                       if (r3 & CHBTxIP)
43213 +                               pmz_transmit_chars(up_b);
43214 +               rc = IRQ_HANDLED;
43215 +               }
43216 +               spin_unlock(&up_b->port.lock);
43217 +
43218 +
43219 +       return rc;
43220 +}
43221 +
43222 +/*
43223 + * Peek the status register, lock not held by caller
43224 + */
43225 +static inline u8 pmz_peek_status(struct uart_pmac_port *up)
43226 +{
43227 +       unsigned long flags;
43228 +       u8 status;
43229 +       
43230 +       spin_lock_irqsave(&up->port.lock, flags);
43231 +       status = read_zsreg(up, R0);
43232 +       spin_unlock_irqrestore(&up->port.lock, flags);
43233 +
43234 +       return status;
43235 +}
43236 +
43237 +/* 
43238 + * Check if transmitter is empty
43239 + * The port lock is not held.
43240 + */
43241 +static unsigned int pmz_tx_empty(struct uart_port *port)
43242 +{
43243 +       unsigned char status;
43244 +
43245 +       status = pmz_peek_status(to_pmz(port));
43246 +       if (status & Tx_BUF_EMP)
43247 +               return TIOCSER_TEMT;
43248 +       return 0;
43249 +}
43250 +
43251 +/* 
43252 + * Set Modem Control (RTS & DTR) bits
43253 + * The port lock is held and interrupts are disabled.
43254 + * Note: Shall we really filter out RTS on external ports or
43255 + * should that be dealt at higher level only ?
43256 + */
43257 +static void pmz_set_mctrl(struct uart_port *port, unsigned int mctrl)
43258 +{
43259 +       struct uart_pmac_port *up = to_pmz(port);
43260 +       unsigned char set_bits, clear_bits;
43261 +
43262 +        /* Do nothing for irda for now... */
43263 +       if (ZS_IS_IRDA(up))
43264 +               return;
43265 +
43266 +       set_bits = clear_bits = 0;
43267 +
43268 +       if (ZS_IS_INTMODEM(up)) {
43269 +               if (mctrl & TIOCM_RTS)
43270 +                       set_bits |= RTS;
43271 +               else
43272 +                       clear_bits |= RTS;
43273 +       }
43274 +       if (mctrl & TIOCM_DTR)
43275 +               set_bits |= DTR;
43276 +       else
43277 +               clear_bits |= DTR;
43278 +
43279 +       /* NOTE: Not subject to 'transmitter active' rule.  */ 
43280 +       up->curregs[R5] |= set_bits;
43281 +       up->curregs[R5] &= ~clear_bits;
43282 +       write_zsreg(up, R5, up->curregs[R5]);
43283 +       zssync(up);
43284 +}
43285 +
43286 +/* 
43287 + * Get Modem Control bits (only the input ones, the core will
43288 + * or that with a cached value of the control ones)
43289 + * The port lock is not held.
43290 + */
43291 +static unsigned int pmz_get_mctrl(struct uart_port *port)
43292 +{
43293 +       unsigned char status;
43294 +       unsigned int ret;
43295 +
43296 +       status = pmz_peek_status(to_pmz(port));
43297 +
43298 +       ret = 0;
43299 +       if (status & DCD)
43300 +               ret |= TIOCM_CAR;
43301 +       if (status & SYNC_HUNT)
43302 +               ret |= TIOCM_DSR;
43303 +       if (status & CTS)
43304 +               ret |= TIOCM_CTS;
43305 +
43306 +       return ret;
43307 +}
43308 +
43309 +/* 
43310 + * Stop TX side. Dealt like sunzilog at next Tx interrupt,
43311 + * though for DMA, we will have to do a bit more. What is
43312 + * the meaning of the tty_stop bit ? XXX
43313 + * The port lock is held and interrupts are disabled.
43314 + */
43315 +static void pmz_stop_tx(struct uart_port *port, unsigned int tty_stop)
43316 +{
43317 +       to_pmz(port)->flags |= PMACZILOG_FLAG_TX_STOPPED;
43318 +}
43319 +
43320 +/* 
43321 + * Kick the Tx side.
43322 + * The port lock is held and interrupts are disabled.
43323 + */
43324 +static void pmz_start_tx(struct uart_port *port, unsigned int tty_start)
43325 +{
43326 +       struct uart_pmac_port *up = to_pmz(port);
43327 +       unsigned char status;
43328 +
43329 +       pr_debug("pmz: start_tx()\n");
43330 +
43331 +       up->flags |= PMACZILOG_FLAG_TX_ACTIVE;
43332 +       up->flags &= ~PMACZILOG_FLAG_TX_STOPPED;
43333 +
43334 +       status = read_zsreg(up, R0);
43335 +
43336 +       /* TX busy?  Just wait for the TX done interrupt.  */
43337 +       if (!(status & Tx_BUF_EMP))
43338 +               return;
43339 +
43340 +       /* Send the first character to jump-start the TX done
43341 +        * IRQ sending engine.
43342 +        */
43343 +       if (port->x_char) {
43344 +               write_zsdata(up, port->x_char);
43345 +               zssync(up);
43346 +               port->icount.tx++;
43347 +               port->x_char = 0;
43348 +       } else {
43349 +               struct circ_buf *xmit = &port->info->xmit;
43350 +
43351 +               write_zsdata(up, xmit->buf[xmit->tail]);
43352 +               zssync(up);
43353 +               xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
43354 +               port->icount.tx++;
43355 +
43356 +               if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
43357 +                       uart_write_wakeup(&up->port);
43358 +       }
43359 +       pr_debug("pmz: start_tx() done.\n");
43360 +}
43361 +
43362 +/* 
43363 + * Stop Rx side, basically disable emitting of
43364 + * Rx interrupts on the port
43365 + * The port lock is held.
43366 + */
43367 +static void pmz_stop_rx(struct uart_port *port)
43368 +{
43369 +       struct uart_pmac_port *up = to_pmz(port);
43370 +
43371 +       if (ZS_IS_CONS(up))
43372 +               return;
43373 +
43374 +       pr_debug("pmz: stop_rx()()\n");
43375 +
43376 +       /* Disable all RX interrupts.  */
43377 +       up->curregs[R1] &= ~RxINT_MASK;
43378 +       pmz_maybe_update_regs(up);
43379 +
43380 +       pr_debug("pmz: stop_rx() done.\n");
43381 +}
43382 +
43383 +/* 
43384 + * Enable modem status change interrupts
43385 + * The port lock is not held.
43386 + */
43387 +static void pmz_enable_ms(struct uart_port *port)
43388 +{
43389 +       struct uart_pmac_port *up = to_pmz(port);
43390 +       unsigned char new_reg;
43391 +       unsigned long flags;
43392 +
43393 +       spin_lock_irqsave(&port->lock, flags);
43394 +
43395 +       new_reg = up->curregs[R15] | (DCDIE | SYNCIE | CTSIE);
43396 +       if (new_reg != up->curregs[R15]) {
43397 +               up->curregs[R15] = new_reg;
43398 +
43399 +               /* NOTE: Not subject to 'transmitter active' rule.  */ 
43400 +               write_zsreg(up, R15, up->curregs[R15]);
43401 +       }
43402 +
43403 +       spin_unlock_irqrestore(&port->lock, flags);
43404 +}
43405 +
43406 +/* 
43407 + * Control break state emission
43408 + * The port lock is not held.
43409 + */
43410 +static void pmz_break_ctl(struct uart_port *port, int break_state)
43411 +{
43412 +       struct uart_pmac_port *up = to_pmz(port);
43413 +       unsigned char set_bits, clear_bits, new_reg;
43414 +       unsigned long flags;
43415 +
43416 +       set_bits = clear_bits = 0;
43417 +
43418 +       if (break_state)
43419 +               set_bits |= SND_BRK;
43420 +       else
43421 +               clear_bits |= SND_BRK;
43422 +
43423 +       spin_lock_irqsave(&port->lock, flags);
43424 +
43425 +       new_reg = (up->curregs[R5] | set_bits) & ~clear_bits;
43426 +       if (new_reg != up->curregs[R5]) {
43427 +               up->curregs[R5] = new_reg;
43428 +
43429 +               /* NOTE: Not subject to 'transmitter active' rule.  */ 
43430 +               write_zsreg(up, R5, up->curregs[R5]);
43431 +       }
43432 +
43433 +       spin_unlock_irqrestore(&port->lock, flags);
43434 +}
43435 +
43436 +/*
43437 + * Turn power on or off to the SCC and associated stuff
43438 + * (port drivers, modem, IR port, etc.)
43439 + * Returns the number of milliseconds we should wait before
43440 + * trying to use the port.
43441 + */
43442 +static int pmz_set_scc_power(struct uart_pmac_port *up, int state)
43443 +{
43444 +       int delay = 0;
43445 +
43446 +       if (state) {
43447 +               pmac_call_feature(
43448 +                       PMAC_FTR_SCC_ENABLE, up->node, up->port_type, 1);
43449 +               if (ZS_IS_INTMODEM(up)) {
43450 +                       pmac_call_feature(
43451 +                               PMAC_FTR_MODEM_ENABLE, up->node, 0, 1);
43452 +                       delay = 2500;   /* wait for 2.5s before using */
43453 +               } else if (ZS_IS_IRDA(up))
43454 +                       mdelay(50);     /* Do better here once the problems
43455 +                                        * with blocking have been ironed out
43456 +                                        */
43457 +       } else {
43458 +               /* TODO: Make that depend on a timer, don't power down
43459 +                * immediately
43460 +                */
43461 +               if (ZS_IS_INTMODEM(up)) {
43462 +                       pmac_call_feature(
43463 +                               PMAC_FTR_MODEM_ENABLE, up->node, 0, 0);
43464 +               }
43465 +               pmac_call_feature(
43466 +                       PMAC_FTR_SCC_ENABLE, up->node, up->port_type, 0);
43467 +       }
43468 +       return delay;
43469 +}
43470 +
43471 +/*
43472 + * FixZeroBug....Works around a bug in the SCC receving channel.
43473 + * Taken from Darwin code, 15 Sept. 2000  -DanM
43474 + *
43475 + * The following sequence prevents a problem that is seen with O'Hare ASICs
43476 + * (most versions -- also with some Heathrow and Hydra ASICs) where a zero
43477 + * at the input to the receiver becomes 'stuck' and locks up the receiver.
43478 + * This problem can occur as a result of a zero bit at the receiver input
43479 + * coincident with any of the following events:
43480 + *
43481 + *     The SCC is initialized (hardware or software).
43482 + *     A framing error is detected.
43483 + *     The clocking option changes from synchronous or X1 asynchronous
43484 + *             clocking to X16, X32, or X64 asynchronous clocking.
43485 + *     The decoding mode is changed among NRZ, NRZI, FM0, or FM1.
43486 + *
43487 + * This workaround attempts to recover from the lockup condition by placing
43488 + * the SCC in synchronous loopback mode with a fast clock before programming
43489 + * any of the asynchronous modes.
43490 + */
43491 +static void pmz_fix_zero_bug_scc(struct uart_pmac_port *up)
43492 +{
43493 +       write_zsreg(up, 9, ZS_IS_CHANNEL_A(up) ? CHRA : CHRB);
43494 +       zssync(up);
43495 +       udelay(10);
43496 +       write_zsreg(up, 9, (ZS_IS_CHANNEL_A(up) ? CHRA : CHRB) | NV);
43497 +       zssync(up);
43498 +
43499 +       write_zsreg(up, 4, (X1CLK | EXTSYNC));
43500 +
43501 +       /* I think this is wrong....but, I just copying code....
43502 +       */
43503 +       write_zsreg(up, 3, (8 & ~RxENABLE));
43504 +
43505 +       write_zsreg(up, 5, (8 & ~TxENABLE));
43506 +       write_zsreg(up, 9, NV); /* Didn't we already do this? */
43507 +       write_zsreg(up, 11, (RCBR | TCBR));
43508 +       write_zsreg(up, 12, 0);
43509 +       write_zsreg(up, 13, 0);
43510 +       write_zsreg(up, 14, (LOOPBAK | SSBR));
43511 +       write_zsreg(up, 14, (LOOPBAK | SSBR | BRENAB));
43512 +       write_zsreg(up, 3, (8 | RxENABLE));
43513 +       write_zsreg(up, 0, RES_EXT_INT);
43514 +       write_zsreg(up, 0, RES_EXT_INT);        /* to kill some time */
43515 +
43516 +       /* The channel should be OK now, but it is probably receiving
43517 +        * loopback garbage.
43518 +        * Switch to asynchronous mode, disable the receiver,
43519 +        * and discard everything in the receive buffer.
43520 +        */
43521 +       write_zsreg(up, 9, NV);
43522 +       write_zsreg(up, 4, PAR_ENAB);
43523 +       write_zsreg(up, 3, (8 & ~RxENABLE));
43524 +
43525 +       while (read_zsreg(up, 0) & Rx_CH_AV) {
43526 +               (void)read_zsreg(up, 8);
43527 +               write_zsreg(up, 0, RES_EXT_INT);
43528 +               write_zsreg(up, 0, ERR_RES);
43529 +       }
43530 +}
43531 +
43532 +/*
43533 + * Real startup routine, powers up the hardware and sets up
43534 + * the SCC. Returns a delay in ms where you need to wait before
43535 + * actually using the port, this is typically the internal modem
43536 + * powerup delay. This routine expect the lock to be taken.
43537 + */
43538 +static int __pmz_startup(struct uart_pmac_port *up)
43539 +{
43540 +       int pwr_delay = 0;
43541 +
43542 +       memset(&up->curregs, 0, sizeof(up->curregs));
43543 +
43544 +       /* Power up the SCC & underlying hardware (modem/irda) */
43545 +       pwr_delay = pmz_set_scc_power(up, 1);
43546 +
43547 +       /* Nice buggy HW ... */
43548 +       pmz_fix_zero_bug_scc(up);
43549 +
43550 +       /* Reset the chip */
43551 +       write_zsreg(up, 9, ZS_IS_CHANNEL_A(up) ? CHRA : CHRB);
43552 +       zssync(up);
43553 +       udelay(10);
43554 +       write_zsreg(up, 9, 0);
43555 +       zssync(up);
43556 +
43557 +       /* Clear the interrupt registers */
43558 +       write_zsreg(up, R1, 0);
43559 +       write_zsreg(up, R0, ERR_RES);
43560 +       write_zsreg(up, R0, ERR_RES);
43561 +       write_zsreg(up, R0, RES_H_IUS);
43562 +       write_zsreg(up, R0, RES_H_IUS);
43563 +
43564 +       /* Remember status for DCD/CTS changes */
43565 +       up->prev_status = read_zsreg(up, R0);
43566 +
43567 +       /* Enable receiver and transmitter.  */
43568 +       up->curregs[R3] |= RxENABLE;
43569 +       up->curregs[R5] |= TxENABLE | RTS | DTR;
43570 +
43571 +       /* Master interrupt enable */
43572 +       up->curregs[R9] |= NV | MIE;
43573 +
43574 +       up->curregs[R1] |= EXT_INT_ENAB | INT_ALL_Rx | TxINT_ENAB;
43575 +       //      pmz_maybe_update_regs(up);
43576 +
43577 +       return pwr_delay;
43578 +}
43579 +
43580 +/*
43581 + * This is the "normal" startup routine, using the above one
43582 + * wrapped with the lock and doing a schedule delay
43583 + */
43584 +static int pmz_startup(struct uart_port *port)
43585 +{
43586 +       struct uart_pmac_port *up = to_pmz(port);
43587 +       unsigned long flags;
43588 +       int pwr_delay = 0;
43589 +
43590 +       pr_debug("pmz: startup()\n");
43591 +
43592 +       /* A console is never powered down */
43593 +       if (!ZS_IS_CONS(up)) {
43594 +               spin_lock_irqsave(&port->lock, flags);
43595 +               pwr_delay = __pmz_startup(up);
43596 +               spin_unlock_irqrestore(&port->lock, flags);
43597 +       }
43598 +       
43599 +       if (request_irq(up->port.irq, pmz_interrupt, SA_SHIRQ, "PowerMac Zilog", up)) {
43600 +               printk(KERN_ERR "Unable to register zs interrupt handler.\n");
43601 +               pmz_set_scc_power(up, 0);
43602 +               return -ENXIO;
43603 +       }
43604 +
43605 +       /* Right now, we deal with delay by blocking here, I'll be
43606 +        * smarter later on
43607 +        */
43608 +       if (pwr_delay != 0) {
43609 +               pr_debug("pmz: delaying %d ms\n", pwr_delay);
43610 +               set_current_state(TASK_UNINTERRUPTIBLE);
43611 +               schedule_timeout((pwr_delay * HZ)/1000);
43612 +       }
43613 +
43614 +       pr_debug("pmz: startup() done.\n");
43615 +
43616 +       return 0;
43617 +}
43618 +
43619 +static void pmz_shutdown(struct uart_port *port)
43620 +{
43621 +       struct uart_pmac_port *up = to_pmz(port);
43622 +       unsigned long flags;
43623 +
43624 +       pr_debug("pmz: shutdown()\n");
43625 +
43626 +       /* Release interrupt handler */
43627 +               free_irq(up->port.irq, up);
43628 +
43629 +       if (ZS_IS_CONS(up))
43630 +               return;
43631 +
43632 +       spin_lock_irqsave(&port->lock, flags);
43633 +
43634 +       /* Disable receiver and transmitter.  */
43635 +       up->curregs[R3] &= ~RxENABLE;
43636 +       up->curregs[R5] &= ~TxENABLE;
43637 +
43638 +       /* Disable all interrupts and BRK assertion.  */
43639 +       up->curregs[R1] &= ~(EXT_INT_ENAB | TxINT_ENAB | RxINT_MASK);
43640 +       up->curregs[R5] &= ~SND_BRK;
43641 +       pmz_maybe_update_regs(up);
43642 +
43643 +       /* Shut the chip down */
43644 +       pmz_set_scc_power(up, 0);
43645 +
43646 +       spin_unlock_irqrestore(&port->lock, flags);
43647 +
43648 +       pr_debug("pmz: shutdown() done.\n");
43649 +}
43650 +
43651 +/* Shared by TTY driver and serial console setup.  The port lock is held
43652 + * and local interrupts are disabled.
43653 + */
43654 +static void
43655 +pmz_convert_to_zs(struct uart_pmac_port *up, unsigned int cflag,
43656 +                      unsigned int iflag, int baud)
43657 +{
43658 +       int brg;
43659 +
43660 +       switch (baud) {
43661 +       case ZS_CLOCK/16:       /* 230400 */
43662 +               up->curregs[R4] = X16CLK;
43663 +               up->curregs[R11] = 0;
43664 +               break;
43665 +       case ZS_CLOCK/32:       /* 115200 */
43666 +               up->curregs[R4] = X32CLK;
43667 +               up->curregs[R11] = 0;
43668 +               break;
43669 +       default:
43670 +               up->curregs[R4] = X16CLK;
43671 +               up->curregs[R11] = TCBR | RCBR;
43672 +               brg = BPS_TO_BRG(baud, ZS_CLOCK / 16);
43673 +               up->curregs[R12] = (brg & 255);
43674 +               up->curregs[R13] = ((brg >> 8) & 255);
43675 +               up->curregs[R14] = BRENAB;
43676 +       }
43677 +
43678 +       /* Character size, stop bits, and parity. */
43679 +       up->curregs[3] &= ~RxN_MASK;
43680 +       up->curregs[5] &= ~TxN_MASK;
43681 +
43682 +       switch (cflag & CSIZE) {
43683 +       case CS5:
43684 +               up->curregs[3] |= Rx5;
43685 +               up->curregs[5] |= Tx5;
43686 +               up->parity_mask = 0x1f;
43687 +               break;
43688 +       case CS6:
43689 +               up->curregs[3] |= Rx6;
43690 +               up->curregs[5] |= Tx6;
43691 +               up->parity_mask = 0x3f;
43692 +               break;
43693 +       case CS7:
43694 +               up->curregs[3] |= Rx7;
43695 +               up->curregs[5] |= Tx7;
43696 +               up->parity_mask = 0x7f;
43697 +               break;
43698 +       case CS8:
43699 +       default:
43700 +               up->curregs[3] |= Rx8;
43701 +               up->curregs[5] |= Tx8;
43702 +               up->parity_mask = 0xff;
43703 +               break;
43704 +       };
43705 +       up->curregs[4] &= ~(SB_MASK);
43706 +       if (cflag & CSTOPB)
43707 +               up->curregs[4] |= SB2;
43708 +       else
43709 +               up->curregs[4] |= SB1;
43710 +       if (cflag & PARENB)
43711 +               up->curregs[4] |= PAR_ENAB;
43712 +       else
43713 +               up->curregs[4] &= ~PAR_ENAB;
43714 +       if (!(cflag & PARODD))
43715 +               up->curregs[4] |= PAR_EVEN;
43716 +       else
43717 +               up->curregs[4] &= ~PAR_EVEN;
43718 +
43719 +       up->port.read_status_mask = Rx_OVR;
43720 +       if (iflag & INPCK)
43721 +               up->port.read_status_mask |= CRC_ERR | PAR_ERR;
43722 +       if (iflag & (BRKINT | PARMRK))
43723 +               up->port.read_status_mask |= BRK_ABRT;
43724 +
43725 +       up->port.ignore_status_mask = 0;
43726 +       if (iflag & IGNPAR)
43727 +               up->port.ignore_status_mask |= CRC_ERR | PAR_ERR;
43728 +       if (iflag & IGNBRK) {
43729 +               up->port.ignore_status_mask |= BRK_ABRT;
43730 +               if (iflag & IGNPAR)
43731 +                       up->port.ignore_status_mask |= Rx_OVR;
43732 +       }
43733 +
43734 +       if ((cflag & CREAD) == 0)
43735 +               up->port.ignore_status_mask = 0xff;
43736 +}
43737 +
43738 +static void pmz_irda_rts_pulses(struct uart_pmac_port *up, int w)
43739 +{
43740 +       udelay(w);
43741 +       write_zsreg(up, 5, Tx8 | TxENABLE);
43742 +       zssync(up);
43743 +       udelay(2);
43744 +       write_zsreg(up, 5, Tx8 | TxENABLE | RTS);
43745 +       zssync(up);
43746 +       udelay(8);
43747 +       write_zsreg(up, 5, Tx8 | TxENABLE);
43748 +       zssync(up);
43749 +       udelay(4);
43750 +       write_zsreg(up, 5, Tx8 | TxENABLE | RTS);
43751 +       zssync(up);
43752 +}
43753 +
43754 +/*
43755 + * Set the irda codec on the imac to the specified baud rate.
43756 + */
43757 +static void pmz_irda_setup(struct uart_pmac_port *up, int cflags)
43758 +{
43759 +       int code, speed, t;
43760 +
43761 +       speed = cflags & CBAUD;
43762 +       if (speed < B2400 || speed > B115200)
43763 +               return;
43764 +       code = 0x4d + B115200 - speed;
43765 +
43766 +       /* disable serial interrupts and receive DMA */
43767 +       write_zsreg(up, 1, up->curregs[1] & ~0x9f);
43768 +
43769 +       /* wait for transmitter to drain */
43770 +       t = 10000;
43771 +       while ((read_zsreg(up, R0) & Tx_BUF_EMP) == 0
43772 +              || (read_zsreg(up, R1) & ALL_SNT) == 0) {
43773 +               if (--t <= 0) {
43774 +                       printk(KERN_ERR "transmitter didn't drain\n");
43775 +                       return;
43776 +               }
43777 +               udelay(10);
43778 +       }
43779 +       udelay(100);
43780 +
43781 +       /* set to 8 bits, no parity, 19200 baud, RTS on, DTR off */
43782 +       write_zsreg(up, R4, X16CLK | SB1);
43783 +       write_zsreg(up, R11, TCBR | RCBR);
43784 +       t = BPS_TO_BRG(19200, ZS_CLOCK/16);
43785 +       write_zsreg(up, R12, t);
43786 +       write_zsreg(up, R13, t >> 8);
43787 +       write_zsreg(up, R14, BRENAB);
43788 +       write_zsreg(up, R3, Rx8 | RxENABLE);
43789 +       write_zsreg(up, R5, Tx8 | TxENABLE | RTS);
43790 +       zssync(up);
43791 +
43792 +       /* set TxD low for ~104us and pulse RTS */
43793 +       udelay(1000);
43794 +       write_zsdata(up, 0xfe);
43795 +       pmz_irda_rts_pulses(up, 150);
43796 +       pmz_irda_rts_pulses(up, 180);
43797 +       pmz_irda_rts_pulses(up, 50);
43798 +       udelay(100);
43799 +
43800 +       /* assert DTR, wait 30ms, talk to the chip */
43801 +       write_zsreg(up, R5, Tx8 | TxENABLE | RTS | DTR);
43802 +       zssync(up);
43803 +       mdelay(30);
43804 +       while (read_zsreg(up, R0) & Rx_CH_AV)
43805 +               read_zsdata(up);
43806 +
43807 +       write_zsdata(up, 1);
43808 +       t = 1000;
43809 +       while ((read_zsreg(up, R0) & Rx_CH_AV) == 0) {
43810 +               if (--t <= 0) {
43811 +                       printk(KERN_ERR "irda_setup timed out on 1st byte\n");
43812 +                       goto out;
43813 +               }
43814 +               udelay(10);
43815 +       }
43816 +       t = read_zsdata(up);
43817 +       if (t != 4)
43818 +               printk(KERN_ERR "irda_setup 1st byte = %x\n", t);
43819 +
43820 +       write_zsdata(up, code);
43821 +       t = 1000;
43822 +       while ((read_zsreg(up, R0) & Rx_CH_AV) == 0) {
43823 +               if (--t <= 0) {
43824 +                       printk(KERN_ERR "irda_setup timed out on 2nd byte\n");
43825 +                       goto out;
43826 +               }
43827 +               udelay(10);
43828 +       }
43829 +       t = read_zsdata(up);
43830 +       if (t != code)
43831 +               printk(KERN_ERR "irda_setup 2nd byte = %x (%x)\n", t, code);
43832 +
43833 +       /* Drop DTR again and do some more RTS pulses */
43834 + out:
43835 +       udelay(100);
43836 +       write_zsreg(up, R5, Tx8 | TxENABLE | RTS);
43837 +       pmz_irda_rts_pulses(up, 80);
43838 +
43839 +       /* We should be right to go now.  We assume that load_zsregs
43840 +          will get called soon to load up the correct baud rate etc. */
43841 +       up->curregs[R5] = (up->curregs[R5] | RTS) & ~DTR;
43842 +}
43843 +
43844 +/* The port lock is not held.  */
43845 +static void
43846 +pmz_set_termios(struct uart_port *port, struct termios *termios,
43847 +                    struct termios *old)
43848 +{
43849 +       struct uart_pmac_port *up = to_pmz(port);
43850 +       unsigned long flags;
43851 +       int baud;
43852 +
43853 +       pr_debug("pmz: set_termios()\n");
43854 +
43855 +       baud = uart_get_baud_rate(port, termios, old, 1200, 230400);
43856 +
43857 +       spin_lock_irqsave(&up->port.lock, flags);
43858 +
43859 +       pmz_convert_to_zs(up, termios->c_cflag, termios->c_iflag, baud);
43860 +
43861 +       if (UART_ENABLE_MS(&up->port, termios->c_cflag))
43862 +               up->flags |= PMACZILOG_FLAG_MODEM_STATUS;
43863 +       else
43864 +               up->flags &= ~PMACZILOG_FLAG_MODEM_STATUS;
43865 +
43866 +       /* set the irda codec to the right rate */
43867 +       if (ZS_IS_IRDA(up))
43868 +               pmz_irda_setup(up, termios->c_cflag);
43869 +
43870 +       /* Load registers to the chip */
43871 +       pmz_maybe_update_regs(up);
43872 +
43873 +       spin_unlock_irqrestore(&up->port.lock, flags);
43874 +
43875 +       pr_debug("pmz: set_termios() done.\n");
43876 +}
43877 +
43878 +static const char *pmz_type(struct uart_port *port)
43879 +{
43880 +       return "PowerMac Zilog";
43881 +}
43882 +
43883 +/* We do not request/release mappings of the registers here, this
43884 + * happens at early serial probe time.
43885 + */
43886 +static void pmz_release_port(struct uart_port *port)
43887 +{
43888 +}
43889 +
43890 +static int pmz_request_port(struct uart_port *port)
43891 +{
43892 +       return 0;
43893 +}
43894 +
43895 +/* These do not need to do anything interesting either.  */
43896 +static void pmz_config_port(struct uart_port *port, int flags)
43897 +{
43898 +}
43899 +
43900 +/* We do not support letting the user mess with the divisor, IRQ, etc. */
43901 +static int pmz_verify_port(struct uart_port *port, struct serial_struct *ser)
43902 +{
43903 +       return -EINVAL;
43904 +}
43905 +
43906 +static struct uart_ops pmz_pops = {
43907 +       .tx_empty       =       pmz_tx_empty,
43908 +       .set_mctrl      =       pmz_set_mctrl,
43909 +       .get_mctrl      =       pmz_get_mctrl,
43910 +       .stop_tx        =       pmz_stop_tx,
43911 +       .start_tx       =       pmz_start_tx,
43912 +       .stop_rx        =       pmz_stop_rx,
43913 +       .enable_ms      =       pmz_enable_ms,
43914 +       .break_ctl      =       pmz_break_ctl,
43915 +       .startup        =       pmz_startup,
43916 +       .shutdown       =       pmz_shutdown,
43917 +       .set_termios    =       pmz_set_termios,
43918 +       .type           =       pmz_type,
43919 +       .release_port   =       pmz_release_port,
43920 +       .request_port   =       pmz_request_port,
43921 +       .config_port    =       pmz_config_port,
43922 +       .verify_port    =       pmz_verify_port,
43923 +};
43924 +
43925 +/*
43926 + * Setup one port structure after probing, HW is down at this point,
43927 + * Unlike sunzilog, we don't need to pre-init the spinlock as we don't
43928 + * register our console before uart_add_one_port() is called
43929 + */
43930 +static int __init pmz_setup_port(struct uart_pmac_port *up, int early)
43931 +{
43932 +       struct device_node *np = up->node;
43933 +       char *conn;
43934 +       struct slot_names_prop {
43935 +               int     count;
43936 +               char    name[1];
43937 +       } *slots;
43938 +       int len;
43939 +
43940 +       /*
43941 +        * Request & map chip registers
43942 +        */
43943 +       if (!early && request_OF_resource(np, 0, NULL) == NULL) {
43944 +               printk("pmac_zilog: failed to request resources for %s\n",
43945 +                       np->full_name);
43946 +               return -EBUSY;
43947 +       }
43948 +       up->port.mapbase = np->addrs[0].address;
43949 +       up->port.membase = ioremap(up->port.mapbase, 0x1000);
43950 +      
43951 +       up->control_reg = (volatile u8 *)up->port.membase;
43952 +       up->data_reg = up->control_reg + 0x10;
43953 +       
43954 +       /*
43955 +        * Request & map DBDMA registers
43956 +        */
43957 +#ifdef HAS_DBDMA
43958 +       if (np->n_addrs >= 3 && np->n_intrs >= 3)
43959 +               up->flags |= PMACZILOG_FLAG_HAS_DMA;
43960 +#endif 
43961 +       if (ZS_HAS_DMA(up)) {
43962 +               if (!early && request_OF_resource(np, np->n_addrs - 2, " (tx dma)") == NULL) {
43963 +                       printk(KERN_ERR "pmac_zilog: can't request TX DMA resource !\n");
43964 +                       up->flags &= ~PMACZILOG_FLAG_HAS_DMA;
43965 +                       goto no_dma;
43966 +               }
43967 +               if (!early && request_OF_resource(np, np->n_addrs - 1, " (rx dma)") == NULL) {
43968 +                       release_OF_resource(np, np->n_addrs - 2);
43969 +                       printk(KERN_ERR "pmac_zilog: can't request RX DMA resource !\n");
43970 +                       up->flags &= ~PMACZILOG_FLAG_HAS_DMA;
43971 +                       goto no_dma;
43972 +               }
43973 +               up->tx_dma_regs = (volatile struct dbdma_regs *)
43974 +                       ioremap(np->addrs[np->n_addrs - 2].address, 0x1000);
43975 +               up->rx_dma_regs = (volatile struct dbdma_regs *)
43976 +                       ioremap(np->addrs[np->n_addrs - 1].address, 0x1000);
43977 +               up->tx_dma_irq = np->intrs[1].line;
43978 +               up->rx_dma_irq = np->intrs[2].line;
43979 +       }
43980 +no_dma:
43981 +       if (!early)
43982 +               up->flags |= PMACZILOG_FLAG_RSRC_REQUESTED;
43983 +
43984 +       /*
43985 +        * Detect port type
43986 +        */
43987 +       if (device_is_compatible(np, "cobalt"))
43988 +               up->flags |= PMACZILOG_FLAG_IS_INTMODEM;
43989 +       conn = get_property(np, "AAPL,connector", &len);
43990 +       if (conn && (strcmp(conn, "infrared") == 0))
43991 +               up->flags |= PMACZILOG_FLAG_IS_IRDA;
43992 +       up->port_type = PMAC_SCC_ASYNC;
43993 +       /* 1999 Powerbook G3 has slot-names property instead */
43994 +       slots = (struct slot_names_prop *)get_property(np, "slot-names", &len);
43995 +       if (slots && slots->count > 0) {
43996 +               if (strcmp(slots->name, "IrDA") == 0)
43997 +                       up->flags |= PMACZILOG_FLAG_IS_IRDA;
43998 +               else if (strcmp(slots->name, "Modem") == 0)
43999 +                       up->flags |= PMACZILOG_FLAG_IS_INTMODEM;
44000 +       }
44001 +       if (ZS_IS_IRDA(up))
44002 +               up->port_type = PMAC_SCC_IRDA;
44003 +       if (ZS_IS_INTMODEM(up)) {
44004 +               struct device_node* i2c_modem = find_devices("i2c-modem");
44005 +               if (i2c_modem) {
44006 +                       char* mid = get_property(i2c_modem, "modem-id", NULL);
44007 +                       if (mid) switch(*mid) {
44008 +                       case 0x04 :
44009 +                       case 0x05 :
44010 +                       case 0x07 :
44011 +                       case 0x08 :
44012 +                       case 0x0b :
44013 +                       case 0x0c :
44014 +                               up->port_type = PMAC_SCC_I2S1;
44015 +                       }
44016 +                       printk(KERN_INFO "pmac_zilog: i2c-modem detected, id: %d\n",
44017 +                               mid ? (*mid) : 0);
44018 +               } else {
44019 +                       printk(KERN_INFO "pmac_zilog: serial modem detected\n");
44020 +               }
44021 +       }
44022 +
44023 +       /*
44024 +        * Init remaining bits of "port" structure
44025 +        */
44026 +       up->port.iotype = SERIAL_IO_MEM;
44027 +       up->port.irq = np->intrs[0].line;
44028 +       up->port.uartclk = ZS_CLOCK;
44029 +       up->port.fifosize = 1;
44030 +       up->port.ops = &pmz_pops;
44031 +       up->port.type = PORT_PMAC_ZILOG;
44032 +       up->port.flags = 0;
44033 +
44034 +       return 0;
44035 +}
44036 +
44037 +/*
44038 + * Get rid of a port on module removal
44039 + */
44040 +static void pmz_dispose_port(struct uart_pmac_port *up)
44041 +{
44042 +       struct device_node *np;
44043 +
44044 +       if (up->flags & PMACZILOG_FLAG_RSRC_REQUESTED) {
44045 +               release_OF_resource(up->node, 0);
44046 +               if (ZS_HAS_DMA(up)) {
44047 +                       release_OF_resource(up->node, up->node->n_addrs - 2);
44048 +                       release_OF_resource(up->node, up->node->n_addrs - 1);
44049 +               }
44050 +       }
44051 +       iounmap((void *)up->control_reg);
44052 +       np = up->node;
44053 +       up->node = NULL;
44054 +       of_node_put(np);
44055 +}
44056 +
44057 +/*
44058 + * Called upon match with an escc node in the devive-tree.
44059 + */
44060 +static int pmz_attach(struct macio_dev *mdev, const struct of_match *match)
44061 +{
44062 +       int i;
44063 +       
44064 +       /* Iterate the pmz_ports array to find a matching entry
44065 +        */
44066 +       for (i = 0; i < MAX_ZS_PORTS; i++)
44067 +               if (pmz_ports[i].node == mdev->ofdev.node) {
44068 +                       pmz_ports[i].dev = mdev;
44069 +                       dev_set_drvdata(&mdev->ofdev.dev, &pmz_ports[i]);
44070 +                       return 0;
44071 +               }
44072 +       return -ENODEV;
44073 +}
44074 +
44075 +/*
44076 + * That one should not be called, macio isn't really a hotswap device,
44077 + * we don't expect one of those serial ports to go away...
44078 + */
44079 +static int pmz_detach(struct macio_dev *mdev)
44080 +{
44081 +       struct uart_pmac_port   *port = dev_get_drvdata(&mdev->ofdev.dev);
44082 +       
44083 +       if (!port)
44084 +               return -ENODEV;
44085 +
44086 +       dev_set_drvdata(&mdev->ofdev.dev, NULL);
44087 +       port->dev = NULL;
44088 +       
44089 +       return 0;
44090 +}
44091 +
44092 +/*
44093 + * Probe all ports in the system and build the ports array, we register
44094 + * with the serial layer at this point, the macio-type probing is only
44095 + * used later to "attach" to the sysfs tree so we get power management
44096 + * events
44097 + */
44098 +static int __init pmz_probe(int early)
44099 +{
44100 +       struct device_node      *node_p, *node_a, *node_b, *np;
44101 +       int                     count = 0;
44102 +       int                     rc;
44103 +
44104 +       /*
44105 +        * Find all escc chips in the system
44106 +        */
44107 +       node_p = of_find_node_by_name(NULL, "escc");
44108 +       while (node_p) {
44109 +               /*
44110 +                * First get channel A/B node pointers
44111 +                * 
44112 +                * TODO: Add routines with proper locking to do that...
44113 +                */
44114 +               node_a = node_b = NULL;
44115 +               for (np = NULL; (np = of_get_next_child(node_p, np)) != NULL;) {
44116 +                       if (strncmp(np->name, "ch-a", 4) == 0)
44117 +                               node_a = of_node_get(np);
44118 +                       else if (strncmp(np->name, "ch-b", 4) == 0)
44119 +                               node_b = of_node_get(np);
44120 +               }
44121 +               if (!node_a || !node_b) {
44122 +                       of_node_put(node_a);
44123 +                       of_node_put(node_b);
44124 +                       printk(KERN_ERR "pmac_zilog: missing node %c for escc %s\n",
44125 +                               (!node_a) ? 'a' : 'b', node_p->full_name);
44126 +                       goto next;
44127 +               }
44128 +
44129 +               /*
44130 +                * Fill basic fields in the port structures
44131 +                */
44132 +               pmz_ports[count].mate           = &pmz_ports[count+1];
44133 +               pmz_ports[count+1].mate         = &pmz_ports[count];
44134 +               pmz_ports[count].flags          = PMACZILOG_FLAG_IS_CHANNEL_A;
44135 +               pmz_ports[count].node           = node_a;
44136 +               pmz_ports[count+1].node         = node_b;
44137 +               pmz_ports[count].port.line      = count;
44138 +               pmz_ports[count+1].port.line    = count+1;
44139 +
44140 +               /*
44141 +                * Setup the ports for real
44142 +                */
44143 +               rc = pmz_setup_port(&pmz_ports[count], early);
44144 +               if (rc == 0)
44145 +                       rc = pmz_setup_port(&pmz_ports[count+1], early);
44146 +               if (rc != 0) {
44147 +                       of_node_put(node_a);
44148 +                       of_node_put(node_b);
44149 +                       memset(&pmz_ports[count], 0, sizeof(struct uart_pmac_port));
44150 +                       memset(&pmz_ports[count+1], 0, sizeof(struct uart_pmac_port));
44151 +                       goto next;
44152 +               }
44153 +               count += 2;
44154 +next:
44155 +               node_p = of_find_node_by_name(node_p, "escc");
44156 +       }
44157 +       pmz_ports_count = count;
44158 +
44159 +       return 0;
44160 +}
44161 +
44162 +static struct uart_driver pmz_uart_reg = {
44163 +       .owner          =       THIS_MODULE,
44164 +       .driver_name    =       "ttyS",
44165 +       .devfs_name     =       "tts/",
44166 +       .dev_name       =       "ttyS",
44167 +       .major          =       TTY_MAJOR,
44168 +};
44169 +
44170 +#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
44171 +
44172 +static void pmz_console_write(struct console *con, const char *s, unsigned int count);
44173 +static int __init pmz_console_setup(struct console *co, char *options);
44174 +
44175 +static struct console pmz_console = {
44176 +       .name   =       "ttyS",
44177 +       .write  =       pmz_console_write,
44178 +       .device =       uart_console_device,
44179 +       .setup  =       pmz_console_setup,
44180 +       .flags  =       CON_PRINTBUFFER,
44181 +       .index  =       -1,
44182 +       .data   =       &pmz_uart_reg,
44183 +};
44184 +
44185 +#define PMACZILOG_CONSOLE      &pmz_console
44186 +#else /* CONFIG_SERIAL_PMACZILOG_CONSOLE */
44187 +#define PMACZILOG_CONSOLE      (NULL)
44188 +#endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */
44189 +
44190 +/*
44191 + * Register the driver, console driver and ports with the serial
44192 + * core
44193 + */
44194 +static int __init pmz_register(void)
44195 +{
44196 +       int i, rc;
44197 +       
44198 +       pmz_uart_reg.nr = pmz_ports_count;
44199 +       pmz_uart_reg.cons = PMACZILOG_CONSOLE;
44200 +       pmz_uart_reg.minor = 64;
44201 +
44202 +       /*
44203 +        * Register this driver with the serial core
44204 +        */
44205 +       rc = uart_register_driver(&pmz_uart_reg);
44206 +       if (rc != 0)
44207 +               return rc;
44208 +
44209 +       /*
44210 +        * Register each port with the serial core
44211 +        */
44212 +       for (i = 0; i < pmz_ports_count; i++) {
44213 +               struct uart_pmac_port *uport = &pmz_ports[i];
44214 +               if (uport->node != NULL)
44215 +                       uart_add_one_port(&pmz_uart_reg, &uport->port);
44216 +       }
44217 +
44218 +       return 0;
44219 +}
44220 +
44221 +static struct of_match pmz_match[] = 
44222 +{
44223 +       {
44224 +       .name           = "ch-a",
44225 +       .type           = OF_ANY_MATCH,
44226 +       .compatible     = OF_ANY_MATCH
44227 +       },
44228 +       {
44229 +       .name           = "ch-b",
44230 +       .type           = OF_ANY_MATCH,
44231 +       .compatible     = OF_ANY_MATCH
44232 +       },
44233 +       {},
44234 +};
44235 +
44236 +static struct macio_driver pmz_driver = 
44237 +{
44238 +       .name           = "pmac_zilog",
44239 +       .match_table    = pmz_match,
44240 +       .probe          = pmz_attach,
44241 +       .remove         = pmz_detach,
44242 +//     .suspend        = pmz_suspend, *** NYI
44243 +//     .resume         = pmz_resume,  *** NYI
44244 +};
44245 +
44246 +static void pmz_fixup_resources(void)
44247 +{
44248 +       int i;
44249 +               for (i=0; i<pmz_ports_count; i++) {
44250 +                       struct uart_pmac_port *up = &pmz_ports[i];
44251 +
44252 +               if (up->node == NULL)
44253 +                       continue;
44254 +                       if (up->flags & PMACZILOG_FLAG_RSRC_REQUESTED)
44255 +                       continue;
44256 +               if (request_OF_resource(up->node, 0, NULL) == NULL)
44257 +                       printk(KERN_WARNING "%s: Failed to do late IO resource request, port still active\n",
44258 +                              up->node->name);
44259 +               up->flags |= PMACZILOG_FLAG_RSRC_REQUESTED;
44260 +               if (!ZS_HAS_DMA(up))
44261 +                       continue;
44262 +               if (request_OF_resource(up->node, up->node->n_addrs - 2, NULL) == NULL)
44263 +                       printk(KERN_WARNING "%s: Failed to do late DMA resource request, port still active\n",
44264 +                              up->node->name);
44265 +               if (request_OF_resource(up->node, up->node->n_addrs - 1, NULL) == NULL)
44266 +                       printk(KERN_WARNING "%s: Failed to do late DMA resource request, port still active\n",
44267 +                              up->node->name);
44268 +               }
44269 +
44270 +}
44271 +
44272 +static int __init init_pmz(void)
44273 +{
44274 +       printk(KERN_DEBUG "%s\n", version);
44275 +
44276 +       /*
44277 +        * If we had serial console, then we didn't request
44278 +        * resources yet. We fix that up now
44279 +        */
44280 +       if (pmz_ports_count > 0)
44281 +               pmz_fixup_resources();
44282 +
44283 +       /* 
44284 +        * First, we need to do a direct OF-based probe pass. We
44285 +        * do that because we want serial console up before the
44286 +        * macio stuffs calls us back, and since that makes it
44287 +        * easier to pass the proper number of channels to
44288 +        * uart_register_driver()
44289 +        */
44290 +       if (pmz_ports_count == 0)
44291 +               pmz_probe(0);
44292 +
44293 +       /*
44294 +        * Bail early if no port found
44295 +        */
44296 +       if (pmz_ports_count == 0)
44297 +               return -ENODEV;
44298 +
44299 +       /*
44300 +        * Now we register with the serial layer
44301 +        */
44302 +       pmz_register();
44303 +       
44304 +       /*
44305 +        * Then we register the macio driver itself
44306 +        */
44307 +       return macio_register_driver(&pmz_driver);
44308 +}
44309 +
44310 +static void __exit exit_pmz(void)
44311 +{
44312 +       int i;
44313 +
44314 +       /* Get rid of macio-driver (detach from macio) */
44315 +       macio_unregister_driver(&pmz_driver);
44316 +
44317 +       /* Unregister UART driver */
44318 +       uart_unregister_driver(&pmz_uart_reg);
44319 +
44320 +       for (i = 0; i < pmz_ports_count; i++) {
44321 +               struct uart_pmac_port *uport = &pmz_ports[i];
44322 +               if (uport->node != NULL) {
44323 +                       uart_remove_one_port(&pmz_uart_reg, &uport->port);
44324 +                       pmz_dispose_port(uport);
44325 +               }
44326 +       }
44327 +}
44328 +
44329 +#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
44330 +
44331 +/*
44332 + * Print a string to the serial port trying not to disturb
44333 + * any possible real use of the port...
44334 + */
44335 +static void pmz_console_write(struct console *con, const char *s, unsigned int count)
44336 +{
44337 +       struct uart_pmac_port *up = &pmz_ports[con->index];
44338 +       unsigned long flags;
44339 +       int i;
44340 +
44341 +       spin_lock_irqsave(&up->port.lock, flags);
44342 +
44343 +       /* Turn of interrupts and enable the transmitter. */
44344 +       write_zsreg(up, R1, up->curregs[1] & ~TxINT_ENAB);
44345 +       write_zsreg(up, R5, up->curregs[5] | TxENABLE | RTS | DTR);
44346 +
44347 +       for (i = 0; i < count; i++) {
44348 +               /* Wait for the transmit buffer to empty. */
44349 +               while ((read_zsreg(up, R0) & Tx_BUF_EMP) == 0)
44350 +                       udelay(5);
44351 +               write_zsdata(up, s[i]);
44352 +               if (s[i] == 10) {
44353 +                       while ((read_zsreg(up, R0) & Tx_BUF_EMP) == 0)
44354 +                               udelay(5);
44355 +                       write_zsdata(up, R13);
44356 +               }
44357 +       }
44358 +
44359 +       /* Restore the values in the registers. */
44360 +       write_zsreg(up, R1, up->curregs[1]);
44361 +       /* Don't disable the transmitter. */
44362 +
44363 +       spin_unlock_irqrestore(&up->port.lock, flags);
44364 +}
44365 +
44366 +/*
44367 + * Setup the serial console
44368 + */
44369 +static int __init pmz_console_setup(struct console *co, char *options)
44370 +{
44371 +       struct uart_port *port;
44372 +       int baud = 38400;
44373 +       int bits = 8;
44374 +       int parity = 'n';
44375 +       int flow = 'n';
44376 +       unsigned long pwr_delay;
44377 +
44378 +       /*
44379 +        * XServe's default to 57600 bps
44380 +        */
44381 +       if (machine_is_compatible("RackMac1,1")
44382 +        || machine_is_compatible("RackMac1,2"))
44383 +               baud = 57600;
44384 +
44385 +       /*
44386 +        * Check whether an invalid uart number has been specified, and
44387 +        * if so, search for the first available port that does have
44388 +        * console support.
44389 +        */
44390 +       if (co->index >= pmz_ports_count)
44391 +               co->index = 0;
44392 +       port = &pmz_ports[co->index].port;
44393 +
44394 +       /*
44395 +        * Mark port as beeing a console
44396 +        */
44397 +       port->flags |= PMACZILOG_FLAG_IS_CONS;
44398 +
44399 +       /*
44400 +        * Temporary fix for uart layer who didn't setup the spinlock yet
44401 +        */
44402 +       spin_lock_init(&port->lock);
44403 +
44404 +       /*
44405 +        * Enable the hardware
44406 +        */
44407 +       pwr_delay = __pmz_startup(&pmz_ports[co->index]);
44408 +       if (pwr_delay)
44409 +               mdelay(pwr_delay);
44410 +       
44411 +       if (options)
44412 +               uart_parse_options(options, &baud, &parity, &bits, &flow);
44413 +
44414 +       return uart_set_options(port, co, baud, parity, bits, flow);
44415 +}
44416 +
44417 +static int __init pmz_console_init(void)
44418 +{
44419 +       /* Probe ports */
44420 +       pmz_probe(1);
44421 +
44422 +       /* TODO: Autoprobe console based on OF */
44423 +       /* pmz_console.index = i; */
44424 +       register_console(&pmz_console);
44425 +
44426 +       return 0;
44427 +
44428 +}
44429 +console_initcall(pmz_console_init);
44430 +#endif /* CONFIG_SERIAL_PMACZILOG_CONSOLE */
44431 +
44432 +module_init(init_pmz);
44433 +module_exit(exit_pmz);
44434 diff -Nru a/drivers/serial/pmac_zilog.h b/drivers/serial/pmac_zilog.h
44435 --- /dev/null   Wed Dec 31 16:00:00 1969
44436 +++ b/drivers/serial/pmac_zilog.h       Sun Aug 24 08:05:54 2003
44437 @@ -0,0 +1,361 @@
44438 +#ifndef __PMAC_ZILOG_H__
44439 +#define __PMAC_ZILOG_H__
44440 +
44441 +/*
44442 + * At most 2 ESCCs with 2 ports each
44443 + */
44444 +#define MAX_ZS_PORTS   4
44445 +
44446 +/* 
44447 + * We wrap our port structure around the generic uart_port.
44448 + */
44449 +#define NUM_ZSREGS    16
44450 +
44451 +struct uart_pmac_port {
44452 +       struct uart_port                port;
44453 +       struct uart_pmac_port           *mate;
44454 +
44455 +       /* macio_dev for the escc holding this port (maybe be null on
44456 +        * early inited port)
44457 +        */
44458 +       struct macio_dev                *dev;
44459 +       /* device node to this port, this points to one of 2 childs
44460 +        * of "escc" node (ie. ch-a or ch-b)
44461 +        */
44462 +       struct device_node              *node;
44463 +
44464 +       /* Port type as obtained from device tree (IRDA, modem, ...) */
44465 +       int                             port_type;
44466 +       u8                              curregs[NUM_ZSREGS];
44467 +
44468 +       unsigned int                    flags;
44469 +#define PMACZILOG_FLAG_IS_CONS         0x00000001
44470 +#define PMACZILOG_FLAG_IS_KGDB         0x00000002
44471 +#define PMACZILOG_FLAG_MODEM_STATUS    0x00000004
44472 +#define PMACZILOG_FLAG_IS_CHANNEL_A    0x00000008
44473 +#define PMACZILOG_FLAG_REGS_HELD       0x00000010
44474 +#define PMACZILOG_FLAG_TX_STOPPED      0x00000020
44475 +#define PMACZILOG_FLAG_TX_ACTIVE       0x00000040
44476 +#define PMACZILOG_FLAG_ENABLED          0x00000080
44477 +#define PMACZILOG_FLAG_IS_IRDA         0x00000100
44478 +#define PMACZILOG_FLAG_IS_INTMODEM     0x00000200
44479 +#define PMACZILOG_FLAG_HAS_DMA         0x00000400
44480 +#define PMACZILOG_FLAG_RSRC_REQUESTED  0x00000800
44481 +
44482 +       unsigned char                   parity_mask;
44483 +       unsigned char                   prev_status;
44484 +
44485 +       volatile u8                     *control_reg;
44486 +       volatile u8                     *data_reg;
44487 +
44488 +       unsigned int                    tx_dma_irq;
44489 +       unsigned int                    rx_dma_irq;
44490 +       volatile struct dbdma_regs      *tx_dma_regs;
44491 +       volatile struct dbdma_regs      *rx_dma_regs;
44492 +};
44493 +
44494 +#define to_pmz(p) ((struct uart_pmac_port *)(p))
44495 +
44496 +/*
44497 + * Register acessors. Note that we don't need to enforce a recovery
44498 + * delay on PCI PowerMac hardware, it's dealt in HW by the MacIO chip,
44499 + * though if we try to use this driver on older machines, we might have
44500 + * to add it back
44501 + */
44502 +static inline u8 read_zsreg(struct uart_pmac_port *port, u8 reg)
44503 +{
44504 +       if (reg != 0)
44505 +               writeb(reg, port->control_reg);
44506 +       return readb(port->control_reg);
44507 +}
44508 +
44509 +static inline void write_zsreg(struct uart_pmac_port *port, u8 reg, u8 value)
44510 +{
44511 +       if (reg != 0)
44512 +               writeb(reg, port->control_reg);
44513 +       writeb(value, port->control_reg);
44514 +}
44515 +
44516 +static inline u8 read_zsdata(struct uart_pmac_port *port)
44517 +{
44518 +       return readb(port->data_reg);
44519 +}
44520 +
44521 +static inline void write_zsdata(struct uart_pmac_port *port, u8 data)
44522 +{
44523 +       writeb(data, port->data_reg);
44524 +}
44525 +
44526 +static inline void zssync(struct uart_pmac_port *port)
44527 +{
44528 +       (void)readb(port->control_reg);
44529 +}
44530 +
44531 +/* Conversion routines to/from brg time constants from/to bits
44532 + * per second.
44533 + */
44534 +#define BRG_TO_BPS(brg, freq) ((freq) / 2 / ((brg) + 2))
44535 +#define BPS_TO_BRG(bps, freq) ((((freq) + (bps)) / (2 * (bps))) - 2)
44536 +
44537 +#define ZS_CLOCK         3686400       /* Z8530 RTxC input clock rate */
44538 +
44539 +/* The Zilog register set */
44540 +
44541 +#define        FLAG    0x7e
44542 +
44543 +/* Write Register 0 */
44544 +#define        R0      0               /* Register selects */
44545 +#define        R1      1
44546 +#define        R2      2
44547 +#define        R3      3
44548 +#define        R4      4
44549 +#define        R5      5
44550 +#define        R6      6
44551 +#define        R7      7
44552 +#define        R8      8
44553 +#define        R9      9
44554 +#define        R10     10
44555 +#define        R11     11
44556 +#define        R12     12
44557 +#define        R13     13
44558 +#define        R14     14
44559 +#define        R15     15
44560 +
44561 +#define        NULLCODE        0       /* Null Code */
44562 +#define        POINT_HIGH      0x8     /* Select upper half of registers */
44563 +#define        RES_EXT_INT     0x10    /* Reset Ext. Status Interrupts */
44564 +#define        SEND_ABORT      0x18    /* HDLC Abort */
44565 +#define        RES_RxINT_FC    0x20    /* Reset RxINT on First Character */
44566 +#define        RES_Tx_P        0x28    /* Reset TxINT Pending */
44567 +#define        ERR_RES         0x30    /* Error Reset */
44568 +#define        RES_H_IUS       0x38    /* Reset highest IUS */
44569 +
44570 +#define        RES_Rx_CRC      0x40    /* Reset Rx CRC Checker */
44571 +#define        RES_Tx_CRC      0x80    /* Reset Tx CRC Checker */
44572 +#define        RES_EOM_L       0xC0    /* Reset EOM latch */
44573 +
44574 +/* Write Register 1 */
44575 +
44576 +#define        EXT_INT_ENAB    0x1     /* Ext Int Enable */
44577 +#define        TxINT_ENAB      0x2     /* Tx Int Enable */
44578 +#define        PAR_SPEC        0x4     /* Parity is special condition */
44579 +
44580 +#define        RxINT_DISAB     0       /* Rx Int Disable */
44581 +#define        RxINT_FCERR     0x8     /* Rx Int on First Character Only or Error */
44582 +#define        INT_ALL_Rx      0x10    /* Int on all Rx Characters or error */
44583 +#define        INT_ERR_Rx      0x18    /* Int on error only */
44584 +#define RxINT_MASK     0x18
44585 +
44586 +#define        WT_RDY_RT       0x20    /* W/Req reflects recv if 1, xmit if 0 */
44587 +#define        WT_FN_RDYFN     0x40    /* W/Req pin is DMA request if 1, wait if 0 */
44588 +#define        WT_RDY_ENAB     0x80    /* Enable W/Req pin */
44589 +
44590 +/* Write Register #2 (Interrupt Vector) */
44591 +
44592 +/* Write Register 3 */
44593 +
44594 +#define        RxENABLE        0x1     /* Rx Enable */
44595 +#define        SYNC_L_INH      0x2     /* Sync Character Load Inhibit */
44596 +#define        ADD_SM          0x4     /* Address Search Mode (SDLC) */
44597 +#define        RxCRC_ENAB      0x8     /* Rx CRC Enable */
44598 +#define        ENT_HM          0x10    /* Enter Hunt Mode */
44599 +#define        AUTO_ENAB       0x20    /* Auto Enables */
44600 +#define        Rx5             0x0     /* Rx 5 Bits/Character */
44601 +#define        Rx7             0x40    /* Rx 7 Bits/Character */
44602 +#define        Rx6             0x80    /* Rx 6 Bits/Character */
44603 +#define        Rx8             0xc0    /* Rx 8 Bits/Character */
44604 +#define RxN_MASK       0xc0
44605 +
44606 +/* Write Register 4 */
44607 +
44608 +#define        PAR_ENAB        0x1     /* Parity Enable */
44609 +#define        PAR_EVEN        0x2     /* Parity Even/Odd* */
44610 +
44611 +#define        SYNC_ENAB       0       /* Sync Modes Enable */
44612 +#define        SB1             0x4     /* 1 stop bit/char */
44613 +#define        SB15            0x8     /* 1.5 stop bits/char */
44614 +#define        SB2             0xc     /* 2 stop bits/char */
44615 +#define SB_MASK                0xc
44616 +
44617 +#define        MONSYNC         0       /* 8 Bit Sync character */
44618 +#define        BISYNC          0x10    /* 16 bit sync character */
44619 +#define        SDLC            0x20    /* SDLC Mode (01111110 Sync Flag) */
44620 +#define        EXTSYNC         0x30    /* External Sync Mode */
44621 +
44622 +#define        X1CLK           0x0     /* x1 clock mode */
44623 +#define        X16CLK          0x40    /* x16 clock mode */
44624 +#define        X32CLK          0x80    /* x32 clock mode */
44625 +#define        X64CLK          0xC0    /* x64 clock mode */
44626 +#define XCLK_MASK      0xC0
44627 +
44628 +/* Write Register 5 */
44629 +
44630 +#define        TxCRC_ENAB      0x1     /* Tx CRC Enable */
44631 +#define        RTS             0x2     /* RTS */
44632 +#define        SDLC_CRC        0x4     /* SDLC/CRC-16 */
44633 +#define        TxENABLE        0x8     /* Tx Enable */
44634 +#define        SND_BRK         0x10    /* Send Break */
44635 +#define        Tx5             0x0     /* Tx 5 bits (or less)/character */
44636 +#define        Tx7             0x20    /* Tx 7 bits/character */
44637 +#define        Tx6             0x40    /* Tx 6 bits/character */
44638 +#define        Tx8             0x60    /* Tx 8 bits/character */
44639 +#define TxN_MASK       0x60
44640 +#define        DTR             0x80    /* DTR */
44641 +
44642 +/* Write Register 6 (Sync bits 0-7/SDLC Address Field) */
44643 +
44644 +/* Write Register 7 (Sync bits 8-15/SDLC 01111110) */
44645 +
44646 +/* Write Register 7' (Some enhanced feature control) */
44647 +#define        ENEXREAD        0x40    /* Enable read of some write registers */
44648 +
44649 +/* Write Register 8 (transmit buffer) */
44650 +
44651 +/* Write Register 9 (Master interrupt control) */
44652 +#define        VIS     1       /* Vector Includes Status */
44653 +#define        NV      2       /* No Vector */
44654 +#define        DLC     4       /* Disable Lower Chain */
44655 +#define        MIE     8       /* Master Interrupt Enable */
44656 +#define        STATHI  0x10    /* Status high */
44657 +#define        NORESET 0       /* No reset on write to R9 */
44658 +#define        CHRB    0x40    /* Reset channel B */
44659 +#define        CHRA    0x80    /* Reset channel A */
44660 +#define        FHWRES  0xc0    /* Force hardware reset */
44661 +
44662 +/* Write Register 10 (misc control bits) */
44663 +#define        BIT6    1       /* 6 bit/8bit sync */
44664 +#define        LOOPMODE 2      /* SDLC Loop mode */
44665 +#define        ABUNDER 4       /* Abort/flag on SDLC xmit underrun */
44666 +#define        MARKIDLE 8      /* Mark/flag on idle */
44667 +#define        GAOP    0x10    /* Go active on poll */
44668 +#define        NRZ     0       /* NRZ mode */
44669 +#define        NRZI    0x20    /* NRZI mode */
44670 +#define        FM1     0x40    /* FM1 (transition = 1) */
44671 +#define        FM0     0x60    /* FM0 (transition = 0) */
44672 +#define        CRCPS   0x80    /* CRC Preset I/O */
44673 +
44674 +/* Write Register 11 (Clock Mode control) */
44675 +#define        TRxCXT  0       /* TRxC = Xtal output */
44676 +#define        TRxCTC  1       /* TRxC = Transmit clock */
44677 +#define        TRxCBR  2       /* TRxC = BR Generator Output */
44678 +#define        TRxCDP  3       /* TRxC = DPLL output */
44679 +#define        TRxCOI  4       /* TRxC O/I */
44680 +#define        TCRTxCP 0       /* Transmit clock = RTxC pin */
44681 +#define        TCTRxCP 8       /* Transmit clock = TRxC pin */
44682 +#define        TCBR    0x10    /* Transmit clock = BR Generator output */
44683 +#define        TCDPLL  0x18    /* Transmit clock = DPLL output */
44684 +#define        RCRTxCP 0       /* Receive clock = RTxC pin */
44685 +#define        RCTRxCP 0x20    /* Receive clock = TRxC pin */
44686 +#define        RCBR    0x40    /* Receive clock = BR Generator output */
44687 +#define        RCDPLL  0x60    /* Receive clock = DPLL output */
44688 +#define        RTxCX   0x80    /* RTxC Xtal/No Xtal */
44689 +
44690 +/* Write Register 12 (lower byte of baud rate generator time constant) */
44691 +
44692 +/* Write Register 13 (upper byte of baud rate generator time constant) */
44693 +
44694 +/* Write Register 14 (Misc control bits) */
44695 +#define        BRENAB  1       /* Baud rate generator enable */
44696 +#define        BRSRC   2       /* Baud rate generator source */
44697 +#define        DTRREQ  4       /* DTR/Request function */
44698 +#define        AUTOECHO 8      /* Auto Echo */
44699 +#define        LOOPBAK 0x10    /* Local loopback */
44700 +#define        SEARCH  0x20    /* Enter search mode */
44701 +#define        RMC     0x40    /* Reset missing clock */
44702 +#define        DISDPLL 0x60    /* Disable DPLL */
44703 +#define        SSBR    0x80    /* Set DPLL source = BR generator */
44704 +#define        SSRTxC  0xa0    /* Set DPLL source = RTxC */
44705 +#define        SFMM    0xc0    /* Set FM mode */
44706 +#define        SNRZI   0xe0    /* Set NRZI mode */
44707 +
44708 +/* Write Register 15 (external/status interrupt control) */
44709 +#define        EN85C30 1       /* Enable some 85c30-enhanced registers */
44710 +#define        ZCIE    2       /* Zero count IE */
44711 +#define        ENSTFIFO 4      /* Enable status FIFO (SDLC) */
44712 +#define        DCDIE   8       /* DCD IE */
44713 +#define        SYNCIE  0x10    /* Sync/hunt IE */
44714 +#define        CTSIE   0x20    /* CTS IE */
44715 +#define        TxUIE   0x40    /* Tx Underrun/EOM IE */
44716 +#define        BRKIE   0x80    /* Break/Abort IE */
44717 +
44718 +
44719 +/* Read Register 0 */
44720 +#define        Rx_CH_AV        0x1     /* Rx Character Available */
44721 +#define        ZCOUNT          0x2     /* Zero count */
44722 +#define        Tx_BUF_EMP      0x4     /* Tx Buffer empty */
44723 +#define        DCD             0x8     /* DCD */
44724 +#define        SYNC_HUNT       0x10    /* Sync/hunt */
44725 +#define        CTS             0x20    /* CTS */
44726 +#define        TxEOM           0x40    /* Tx underrun */
44727 +#define        BRK_ABRT        0x80    /* Break/Abort */
44728 +
44729 +/* Read Register 1 */
44730 +#define        ALL_SNT         0x1     /* All sent */
44731 +/* Residue Data for 8 Rx bits/char programmed */
44732 +#define        RES3            0x8     /* 0/3 */
44733 +#define        RES4            0x4     /* 0/4 */
44734 +#define        RES5            0xc     /* 0/5 */
44735 +#define        RES6            0x2     /* 0/6 */
44736 +#define        RES7            0xa     /* 0/7 */
44737 +#define        RES8            0x6     /* 0/8 */
44738 +#define        RES18           0xe     /* 1/8 */
44739 +#define        RES28           0x0     /* 2/8 */
44740 +/* Special Rx Condition Interrupts */
44741 +#define        PAR_ERR         0x10    /* Parity error */
44742 +#define        Rx_OVR          0x20    /* Rx Overrun Error */
44743 +#define        CRC_ERR         0x40    /* CRC/Framing Error */
44744 +#define        END_FR          0x80    /* End of Frame (SDLC) */
44745 +
44746 +/* Read Register 2 (channel b only) - Interrupt vector */
44747 +#define        CHB_Tx_EMPTY    0x00
44748 +#define        CHB_EXT_STAT    0x02
44749 +#define        CHB_Rx_AVAIL    0x04
44750 +#define        CHB_SPECIAL     0x06
44751 +#define        CHA_Tx_EMPTY    0x08
44752 +#define        CHA_EXT_STAT    0x0a
44753 +#define        CHA_Rx_AVAIL    0x0c
44754 +#define        CHA_SPECIAL     0x0e
44755 +#define        STATUS_MASK     0x06
44756 +
44757 +/* Read Register 3 (interrupt pending register) ch a only */
44758 +#define        CHBEXT  0x1             /* Channel B Ext/Stat IP */
44759 +#define        CHBTxIP 0x2             /* Channel B Tx IP */
44760 +#define        CHBRxIP 0x4             /* Channel B Rx IP */
44761 +#define        CHAEXT  0x8             /* Channel A Ext/Stat IP */
44762 +#define        CHATxIP 0x10            /* Channel A Tx IP */
44763 +#define        CHARxIP 0x20            /* Channel A Rx IP */
44764 +
44765 +/* Read Register 8 (receive data register) */
44766 +
44767 +/* Read Register 10  (misc status bits) */
44768 +#define        ONLOOP  2               /* On loop */
44769 +#define        LOOPSEND 0x10           /* Loop sending */
44770 +#define        CLK2MIS 0x40            /* Two clocks missing */
44771 +#define        CLK1MIS 0x80            /* One clock missing */
44772 +
44773 +/* Read Register 12 (lower byte of baud rate generator constant) */
44774 +
44775 +/* Read Register 13 (upper byte of baud rate generator constant) */
44776 +
44777 +/* Read Register 15 (value of WR 15) */
44778 +
44779 +/* Misc macros */
44780 +#define ZS_CLEARERR(port)    (write_zsreg(port, 0, ERR_RES))
44781 +#define ZS_CLEARFIFO(port)   do { volatile unsigned char garbage; \
44782 +                                    garbage = read_zsdata(port); \
44783 +                                    garbage = read_zsdata(port); \
44784 +                                    garbage = read_zsdata(port); \
44785 +                               } while(0)
44786 +
44787 +#define ZS_IS_CONS(UP)                 ((UP)->flags & PMACZILOG_FLAG_IS_CONS)
44788 +#define ZS_IS_KGDB(UP)                 ((UP)->flags & PMACZILOG_FLAG_IS_KGDB)
44789 +#define ZS_IS_CHANNEL_A(UP)            ((UP)->flags & PMACZILOG_FLAG_IS_CHANNEL_A)
44790 +#define ZS_REGS_HELD(UP)               ((UP)->flags & PMACZILOG_FLAG_REGS_HELD)
44791 +#define ZS_TX_STOPPED(UP)              ((UP)->flags & PMACZILOG_FLAG_TX_STOPPED)
44792 +#define ZS_TX_ACTIVE(UP)               ((UP)->flags & PMACZILOG_FLAG_TX_ACTIVE)
44793 +#define ZS_WANTS_MODEM_STATUS(UP)      ((UP)->flags & PMACZILOG_FLAG_MODEM_STATUS)
44794 +#define ZS_IS_IRDA(UP)                 ((UP)->flags & PMACZILOG_FLAG_IS_IRDA)
44795 +#define ZS_IS_INTMODEM(UP)             ((UP)->flags & PMACZILOG_FLAG_IS_INTMODEM)
44796 +#define ZS_HAS_DMA(UP)                 ((UP)->flags & PMACZILOG_FLAG_HAS_DMA)
44797 +
44798 +#endif /* __PMAC_ZILOG_H__ */
44799 diff -Nru a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c
44800 --- a/drivers/telephony/ixj.c   Sun Jul 27 12:29:47 2003
44801 +++ b/drivers/telephony/ixj.c   Tue Aug 26 09:25:41 2003
44802 @@ -278,8 +278,8 @@
44803  
44804  #include "ixj.h"
44805  
44806 -#define TYPE(dev) (minor(dev) >> 4)
44807 -#define NUM(dev) (minor(dev) & 0xf)
44808 +#define TYPE(inode) (iminor(inode) >> 4)
44809 +#define NUM(inode) (iminor(inode) & 0xf)
44810  
44811  static int ixjdebug;
44812  static int hertz = HZ;
44813 @@ -2273,7 +2273,7 @@
44814                 schedule_timeout(1);
44815         }
44816         if (ixjdebug & 0x0002)
44817 -               printk(KERN_INFO "Closing board %d\n", NUM(inode->i_rdev));
44818 +               printk(KERN_INFO "Closing board %d\n", NUM(inode));
44819  
44820         if (j->cardtype == QTI_PHONECARD)
44821                 ixj_set_port(j, PORT_SPEAKER);
44822 @@ -2858,7 +2858,7 @@
44823  static ssize_t ixj_read(struct file * file_p, char *buf, size_t length, loff_t * ppos)
44824  {
44825         unsigned long i = *ppos;
44826 -       IXJ * j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
44827 +       IXJ * j = get_ixj(NUM(file_p->f_dentry->d_inode));
44828  
44829         DECLARE_WAITQUEUE(wait, current);
44830  
44831 @@ -2915,7 +2915,7 @@
44832  {
44833         int pre_retval;
44834         ssize_t read_retval = 0;
44835 -       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
44836 +       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
44837  
44838         pre_retval = ixj_PreRead(j, 0L);
44839         switch (pre_retval) {
44840 @@ -2994,7 +2994,7 @@
44841         int pre_retval;
44842         ssize_t write_retval = 0;
44843  
44844 -       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
44845 +       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
44846  
44847         pre_retval = ixj_PreWrite(j, 0L);
44848         switch (pre_retval) {
44849 @@ -4707,7 +4707,7 @@
44850  {
44851         unsigned int mask = 0;
44852  
44853 -       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
44854 +       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
44855  
44856         poll_wait(file_p, &(j->poll_q), wait);
44857         if (j->read_buffer_ready > 0)
44858 @@ -6208,10 +6208,10 @@
44859         IXJ_FILTER_RAW jfr;
44860  
44861         unsigned int raise, mant;
44862 -       unsigned int minor = minor(inode->i_rdev);
44863 -       int board = NUM(inode->i_rdev);
44864 +       unsigned int minor = iminor(inode);
44865 +       int board = NUM(inode);
44866  
44867 -       IXJ *j = get_ixj(NUM(inode->i_rdev));
44868 +       IXJ *j = get_ixj(NUM(inode));
44869  
44870         int retval = 0;
44871  
44872 @@ -6764,7 +6764,7 @@
44873  
44874  static int ixj_fasync(int fd, struct file *file_p, int mode)
44875  {
44876 -       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
44877 +       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
44878  
44879         return fasync_helper(fd, file_p, mode, &j->async_queue);
44880  }
44881 diff -Nru a/drivers/telephony/phonedev.c b/drivers/telephony/phonedev.c
44882 --- a/drivers/telephony/phonedev.c      Mon Jul 14 09:05:52 2003
44883 +++ b/drivers/telephony/phonedev.c      Tue Aug 26 09:25:41 2003
44884 @@ -46,7 +46,7 @@
44885  
44886  static int phone_open(struct inode *inode, struct file *file)
44887  {
44888 -       unsigned int minor = minor(inode->i_rdev);
44889 +       unsigned int minor = iminor(inode);
44890         int err = 0;
44891         struct phone_device *p;
44892         struct file_operations *old_fops, *new_fops = NULL;
44893 diff -Nru a/drivers/usb/class/audio.c b/drivers/usb/class/audio.c
44894 --- a/drivers/usb/class/audio.c Wed Jul 30 11:00:01 2003
44895 +++ b/drivers/usb/class/audio.c Tue Aug 26 09:25:41 2003
44896 @@ -1955,7 +1955,7 @@
44897  
44898  static int usb_audio_open_mixdev(struct inode *inode, struct file *file)
44899  {
44900 -       unsigned int minor = minor(inode->i_rdev);
44901 +       unsigned int minor = iminor(inode);
44902         struct list_head *devs, *mdevs;
44903         struct usb_mixerdev *ms;
44904         struct usb_audio_state *s;
44905 @@ -2633,7 +2633,7 @@
44906  
44907  static int usb_audio_open(struct inode *inode, struct file *file)
44908  {
44909 -       unsigned int minor = minor(inode->i_rdev);
44910 +       unsigned int minor = iminor(inode);
44911         DECLARE_WAITQUEUE(wait, current);
44912         struct list_head *devs, *adevs;
44913         struct usb_audiodev *as;
44914 diff -Nru a/drivers/usb/class/usb-midi.c b/drivers/usb/class/usb-midi.c
44915 --- a/drivers/usb/class/usb-midi.c      Tue Jul 29 04:28:54 2003
44916 +++ b/drivers/usb/class/usb-midi.c      Tue Aug 26 09:25:41 2003
44917 @@ -812,7 +812,7 @@
44918  
44919  static int usb_midi_open(struct inode *inode, struct file *file)
44920  {
44921 -       int minor = minor(inode->i_rdev);
44922 +       int minor = iminor(inode);
44923         DECLARE_WAITQUEUE(wait, current);
44924         struct list_head      *devs, *mdevs;
44925         struct usb_midi_state *s;
44926 diff -Nru a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
44927 --- a/drivers/usb/class/usblp.c Sun Aug 10 02:01:53 2003
44928 +++ b/drivers/usb/class/usblp.c Tue Aug 26 09:25:41 2003
44929 @@ -318,7 +318,7 @@
44930  
44931  static int usblp_open(struct inode *inode, struct file *file)
44932  {
44933 -       int minor = minor(inode->i_rdev);
44934 +       int minor = iminor(inode);
44935         struct usblp *usblp;
44936         struct usb_interface *intf;
44937         int retval;
44938 diff -Nru a/drivers/usb/core/file.c b/drivers/usb/core/file.c
44939 --- a/drivers/usb/core/file.c   Wed Aug 13 06:35:23 2003
44940 +++ b/drivers/usb/core/file.c   Tue Aug 26 09:25:41 2003
44941 @@ -34,7 +34,7 @@
44942  
44943  static int usb_open(struct inode * inode, struct file * file)
44944  {
44945 -       int minor = minor(inode->i_rdev);
44946 +       int minor = iminor(inode);
44947         struct file_operations *c;
44948         int err = -ENODEV;
44949         struct file_operations *old_fops, *new_fops = NULL;
44950 diff -Nru a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c
44951 --- a/drivers/usb/host/ohci-sa1111.c    Thu Jul 31 13:51:23 2003
44952 +++ b/drivers/usb/host/ohci-sa1111.c    Sun Aug 24 07:45:05 2003
44953 @@ -352,9 +352,8 @@
44954  
44955  /*-------------------------------------------------------------------------*/
44956  
44957 -static int ohci_hcd_sa1111_drv_probe(struct device *_dev)
44958 +static int ohci_hcd_sa1111_drv_probe(struct sa1111_dev *dev)
44959  {
44960 -       struct sa1111_dev *dev = SA1111_DEV(_dev);
44961         struct usb_hcd *hcd = NULL;
44962         int ret;
44963  
44964 @@ -364,43 +363,29 @@
44965         ret = usb_hcd_sa1111_probe(&ohci_sa1111_hc_driver, &hcd, dev);
44966  
44967         if (ret == 0)
44968 -               dev->dev.driver_data = hcd;
44969 +               sa1111_set_drvdata(dev, hcd);
44970  
44971         return ret;
44972  }
44973  
44974 -static int ohci_hcd_sa1111_drv_remove(struct device *_dev)
44975 +static int ohci_hcd_sa1111_drv_remove(struct sa1111_dev *dev)
44976  {
44977 -       struct sa1111_dev *dev = SA1111_DEV(_dev);
44978 -       struct usb_hcd *hcd = dev->dev.driver_data;
44979 +       struct usb_hcd *hcd = sa1111_get_drvdata(dev);
44980  
44981         usb_hcd_sa1111_remove(hcd, dev);
44982  
44983 -       dev->dev.driver_data = NULL;
44984 +       sa1111_set_drvdata(dev, NULL);
44985  
44986         return 0;
44987  }
44988  
44989 -static int ohci_hcd_sa1111_drv_suspend(struct device *dev, u32 state, u32 level)
44990 -{
44991 -       return 0;
44992 -}
44993 -
44994 -static int ohci_hcd_sa1111_drv_resume(struct device *dev, u32 level)
44995 -{
44996 -       return 0;
44997 -}
44998 -
44999  static struct sa1111_driver ohci_hcd_sa1111_driver = {
45000         .drv = {
45001 -               .name           = "sa1111-ohci",
45002 -               .bus            = &sa1111_bus_type,
45003 -               .probe          = ohci_hcd_sa1111_drv_probe,
45004 -               .remove         = ohci_hcd_sa1111_drv_remove,
45005 -               .suspend        = ohci_hcd_sa1111_drv_suspend,
45006 -               .resume         = ohci_hcd_sa1111_drv_resume,
45007 +               .name   = "sa1111-ohci",
45008         },
45009 -       .devid                  = SA1111_DEVID_USB,
45010 +       .devid          = SA1111_DEVID_USB,
45011 +       .probe          = ohci_hcd_sa1111_drv_probe,
45012 +       .remove         = ohci_hcd_sa1111_drv_remove,
45013  };
45014  
45015  static int __init ohci_hcd_sa1111_init (void)
45016 @@ -409,12 +394,12 @@
45017         dbg ("block sizes: ed %d td %d",
45018                 sizeof (struct ed), sizeof (struct td));
45019  
45020 -       return driver_register(&ohci_hcd_sa1111_driver.drv);
45021 +       return sa1111_driver_register(&ohci_hcd_sa1111_driver);
45022  }
45023  
45024  static void __exit ohci_hcd_sa1111_cleanup (void)
45025  {
45026 -       driver_unregister(&ohci_hcd_sa1111_driver.drv);
45027 +       sa1111_driver_unregister(&ohci_hcd_sa1111_driver);
45028  }
45029  
45030  module_init (ohci_hcd_sa1111_init);
45031 diff -Nru a/drivers/usb/image/scanner.h b/drivers/usb/image/scanner.h
45032 --- a/drivers/usb/image/scanner.h       Tue Jul 15 02:37:52 2003
45033 +++ b/drivers/usb/image/scanner.h       Tue Aug 26 09:25:41 2003
45034 @@ -313,7 +313,7 @@
45035  #define IS_EP_BULK_OUT(ep) (IS_EP_BULK(ep) && ((ep)->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT)
45036  #define IS_EP_INTR(ep) ((ep)->bmAttributes == USB_ENDPOINT_XFER_INT ? 1 : 0)
45037  
45038 -#define USB_SCN_MINOR(X) minor((X)->i_rdev)
45039 +#define USB_SCN_MINOR(X) iminor(X)
45040  
45041  #ifdef DEBUG
45042  #define SCN_DEBUG(X) X
45043 diff -Nru a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c
45044 --- a/drivers/usb/input/hiddev.c        Wed Jun 11 07:58:27 2003
45045 +++ b/drivers/usb/input/hiddev.c        Tue Aug 26 09:25:41 2003
45046 @@ -271,7 +271,7 @@
45047  static int hiddev_open(struct inode * inode, struct file * file) {
45048         struct hiddev_list *list;
45049  
45050 -       int i = minor(inode->i_rdev) - HIDDEV_MINOR_BASE;
45051 +       int i = iminor(inode) - HIDDEV_MINOR_BASE;
45052  
45053         if (i >= HIDDEV_MINORS || !hiddev_table[i])
45054                 return -ENODEV;
45055 diff -Nru a/drivers/usb/media/dabusb.c b/drivers/usb/media/dabusb.c
45056 --- a/drivers/usb/media/dabusb.c        Mon Aug 11 07:56:25 2003
45057 +++ b/drivers/usb/media/dabusb.c        Tue Aug 26 09:25:41 2003
45058 @@ -583,7 +583,7 @@
45059  
45060  static int dabusb_open (struct inode *inode, struct file *file)
45061  {
45062 -       int devnum = minor (inode->i_rdev);
45063 +       int devnum = iminor(inode);
45064         pdabusb_t s;
45065  
45066         if (devnum < DABUSB_MINOR || devnum >= (DABUSB_MINOR + NRDABUSB))
45067 diff -Nru a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
45068 --- a/drivers/usb/misc/auerswald.c      Wed Jul 30 06:14:48 2003
45069 +++ b/drivers/usb/misc/auerswald.c      Tue Aug 26 09:25:41 2003
45070 @@ -1380,7 +1380,7 @@
45071  /* Open a new character device */
45072  static int auerchar_open (struct inode *inode, struct file *file)
45073  {
45074 -       int dtindex = minor(inode->i_rdev);
45075 +       int dtindex = iminor(inode);
45076         pauerswald_t cp = NULL;
45077         pauerchar_t ccp = NULL;
45078         struct usb_interface *intf;
45079 diff -Nru a/drivers/usb/misc/brlvger.c b/drivers/usb/misc/brlvger.c
45080 --- a/drivers/usb/misc/brlvger.c        Tue Jul 29 04:28:54 2003
45081 +++ b/drivers/usb/misc/brlvger.c        Tue Aug 26 09:25:41 2003
45082 @@ -432,7 +432,7 @@
45083  static int
45084  brlvger_open(struct inode *inode, struct file *file)
45085  {
45086 -       int devnum = minor (inode->i_rdev);
45087 +       int devnum = iminor(inode);
45088         struct usb_interface *intf = NULL;
45089         struct brlvger_priv *priv = NULL;
45090         int n, ret;
45091 diff -Nru a/drivers/usb/misc/tiglusb.c b/drivers/usb/misc/tiglusb.c
45092 --- a/drivers/usb/misc/tiglusb.c        Mon Aug 11 07:56:25 2003
45093 +++ b/drivers/usb/misc/tiglusb.c        Tue Aug 26 09:25:41 2003
45094 @@ -93,7 +93,7 @@
45095  static int
45096  tiglusb_open (struct inode *inode, struct file *filp)
45097  {
45098 -       int devnum = minor (inode->i_rdev);
45099 +       int devnum = iminor(inode);
45100         ptiglusb_t s;
45101  
45102         if (devnum < TIUSB_MINOR || devnum >= (TIUSB_MINOR + MAXTIGL))
45103 diff -Nru a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
45104 --- a/drivers/usb/serial/digi_acceleport.c      Wed Aug 13 03:06:57 2003
45105 +++ b/drivers/usb/serial/digi_acceleport.c      Sun Aug 31 16:14:01 2003
45106 @@ -218,7 +218,7 @@
45107  *    interrupt time.
45108  *  - digi_write_bulk_callback() and digi_read_bulk_callback() are
45109  *    called directly from interrupts.  Hence spin_lock_irqsave()
45110 -*    and spin_lock_irqrestore() are used in the rest of the code
45111 +*    and spin_unlock_irqrestore() are used in the rest of the code
45112  *    for any locks they acquire.
45113  *  - digi_write_bulk_callback() gets the port lock before waking up
45114  *    processes sleeping on the port write_wait.  It also schedules
45115 @@ -571,7 +571,7 @@
45116  *
45117  *  Do spin_unlock_irqrestore and interruptible_sleep_on_timeout
45118  *  so that wake ups are not lost if they occur between the unlock
45119 -*  and the sleep.  In other words, spin_lock_irqrestore and
45120 +*  and the sleep.  In other words, spin_unlock_irqrestore and
45121  *  interruptible_sleep_on_timeout are "atomic" with respect to
45122  *  wake ups.  This is used to implement condition variables.
45123  */
45124 diff -Nru a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
45125 --- a/drivers/usb/usb-skeleton.c        Wed Aug  6 02:20:34 2003
45126 +++ b/drivers/usb/usb-skeleton.c        Tue Aug 26 09:25:41 2003
45127 @@ -229,7 +229,7 @@
45128  
45129         dbg("%s", __FUNCTION__);
45130  
45131 -       subminor = minor (inode->i_rdev);
45132 +       subminor = iminor(inode);
45133  
45134         /* prevent disconnects */
45135         down (&disconnect_sem);
45136 diff -Nru a/drivers/video/68328fb.c b/drivers/video/68328fb.c
45137 --- a/drivers/video/68328fb.c   Fri Dec  6 12:36:20 2002
45138 +++ b/drivers/video/68328fb.c   Sun Aug 31 16:14:08 2003
45139 @@ -401,12 +401,12 @@
45140                                                ((1<<(width))-1)) : 0))
45141  
45142  static struct fb_ops mc68328_fb_ops = {
45143 -       .owner:         THIS_MODULE,
45144 -       .fb_setcolreg:  mc68328fb_setcolreg,
45145 -       .fb_fillrect:   cfbfillrect,
45146 -       .fb_copyarea:   cfbcopyarea,
45147 -       .fb_imageblit:  cfbimgblt,
45148 -       .fb_cursor:     softcursor,
45149 +       .owner          = THIS_MODULE,
45150 +       .fb_setcolreg   = mc68328fb_setcolreg,
45151 +       .fb_fillrect    = cfbfillrect,
45152 +       .fb_copyarea    = cfbcopyarea,
45153 +       .fb_imageblit   = cfbimgblt,
45154 +       .fb_cursor      = softcursor,
45155  };
45156  
45157  
45158 diff -Nru a/drivers/video/Makefile b/drivers/video/Makefile
45159 --- a/drivers/video/Makefile    Sun May 25 08:40:39 2003
45160 +++ b/drivers/video/Makefile    Sun Aug 24 08:05:27 2003
45161 @@ -24,8 +24,8 @@
45162  obj-$(CONFIG_FB_RADEON)                  += radeonfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
45163  obj-$(CONFIG_FB_NEOMAGIC)         += neofb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
45164  obj-$(CONFIG_FB_IGA)              += igafb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
45165 -obj-$(CONFIG_FB_CONTROL)          += controlfb.o
45166 -obj-$(CONFIG_FB_PLATINUM)         += platinumfb.o
45167 +obj-$(CONFIG_FB_CONTROL)          += controlfb.o macmodes.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
45168 +obj-$(CONFIG_FB_PLATINUM)         += platinumfb.o macmodes.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
45169  obj-$(CONFIG_FB_VALKYRIE)         += valkyriefb.o macmodes.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
45170  obj-$(CONFIG_FB_CT65550)          += chipsfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
45171  obj-$(CONFIG_FB_ANAKIN)           += anakinfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
45172 diff -Nru a/drivers/video/controlfb.c b/drivers/video/controlfb.c
45173 --- a/drivers/video/controlfb.c Thu Apr 24 03:30:41 2003
45174 +++ b/drivers/video/controlfb.c Sun Aug 24 06:15:21 2003
45175 @@ -475,7 +475,7 @@
45176  
45177         /* Apply default var */
45178         var.activate = FB_ACTIVATE_NOW;
45179 -       rc = fb_set_var(&var, &p->info);
45180 +       rc = fb_set_var(&p->info, &var);
45181         if (rc && (vmode != VMODE_640_480_60 || cmode != CMODE_8))
45182                 goto try_again;
45183  
45184 diff -Nru a/drivers/video/fbmem.c b/drivers/video/fbmem.c
45185 --- a/drivers/video/fbmem.c     Wed Jul 23 07:45:30 2003
45186 +++ b/drivers/video/fbmem.c     Tue Aug 26 09:25:41 2003
45187 @@ -768,7 +768,7 @@
45188  {
45189         unsigned long p = *ppos;
45190         struct inode *inode = file->f_dentry->d_inode;
45191 -       int fbidx = minor(inode->i_rdev);
45192 +       int fbidx = iminor(inode);
45193         struct fb_info *info = registered_fb[fbidx];
45194  
45195         if (!info || ! info->screen_base)
45196 @@ -802,7 +802,7 @@
45197  {
45198         unsigned long p = *ppos;
45199         struct inode *inode = file->f_dentry->d_inode;
45200 -       int fbidx = minor(inode->i_rdev);
45201 +       int fbidx = iminor(inode);
45202         struct fb_info *info = registered_fb[fbidx];
45203         int err;
45204  
45205 @@ -964,7 +964,7 @@
45206  fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
45207          unsigned long arg)
45208  {
45209 -       int fbidx = minor(inode->i_rdev);
45210 +       int fbidx = iminor(inode);
45211         struct fb_info *info = registered_fb[fbidx];
45212         struct fb_ops *fb = info->fbops;
45213         struct fb_var_screeninfo var;
45214 @@ -1050,7 +1050,7 @@
45215  static int 
45216  fb_mmap(struct file *file, struct vm_area_struct * vma)
45217  {
45218 -       int fbidx = minor(file->f_dentry->d_inode->i_rdev);
45219 +       int fbidx = iminor(file->f_dentry->d_inode);
45220         struct fb_info *info = registered_fb[fbidx];
45221         struct fb_ops *fb = info->fbops;
45222         unsigned long off;
45223 @@ -1149,7 +1149,7 @@
45224  static int
45225  fb_open(struct inode *inode, struct file *file)
45226  {
45227 -       int fbidx = minor(inode->i_rdev);
45228 +       int fbidx = iminor(inode);
45229         struct fb_info *info;
45230         int res = 0;
45231  
45232 @@ -1174,7 +1174,7 @@
45233  static int 
45234  fb_release(struct inode *inode, struct file *file)
45235  {
45236 -       int fbidx = minor(inode->i_rdev);
45237 +       int fbidx = iminor(inode);
45238         struct fb_info *info;
45239  
45240         lock_kernel();
45241 diff -Nru a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
45242 --- a/drivers/video/platinumfb.c        Thu Apr 24 03:30:41 2003
45243 +++ b/drivers/video/platinumfb.c        Sun Aug 24 07:51:47 2003
45244 @@ -35,6 +35,7 @@
45245  #include <asm/io.h>
45246  #include <asm/prom.h>
45247  #include <asm/pgtable.h>
45248 +#include <asm/of_device.h>
45249  
45250  #include "macmodes.h"
45251  #include "platinumfb.h"
45252 @@ -87,7 +88,6 @@
45253   * internal functions
45254   */
45255  
45256 -static void platinum_of_init(struct device_node *dp);
45257  static inline int platinum_vram_reqd(int video_mode, int color_mode);
45258  static int read_platinum_sense(struct fb_info_platinum *info);
45259  static void set_platinum_clock(struct fb_info_platinum *info);
45260 @@ -323,7 +323,7 @@
45261  /*
45262   * Set misc info vars for this driver
45263   */
45264 -static void __init platinum_init_info(struct fb_info *info, struct fb_info_platinum *p)
45265 +static void __devinit platinum_init_info(struct fb_info *info, struct fb_info_platinum *p)
45266  {
45267         /* Fill fb_info */
45268         info->par = &p->par;
45269 @@ -349,7 +349,7 @@
45270  }
45271  
45272  
45273 -static int __init init_platinum(struct fb_info_platinum *p)
45274 +static int __devinit platinum_init_fb(struct fb_info_platinum *p)
45275  {
45276         struct fb_var_screeninfo var;
45277         int sense, rc;
45278 @@ -399,126 +399,21 @@
45279         /* Apply default var */
45280         p->info.var = var;
45281         var.activate = FB_ACTIVATE_NOW;
45282 -       rc = fb_set_var(&var, &p->info);
45283 +       rc = fb_set_var(&p->info, &var);
45284         if (rc && (default_vmode != VMODE_640_480_60 || default_cmode != CMODE_8))
45285                 goto try_again;
45286  
45287         /* Register with fbdev layer */
45288 -       if (register_framebuffer(&p->info) < 0)
45289 -               return 0;
45290 +       rc = register_framebuffer(&p->info);
45291 +       if (rc < 0)
45292 +               return rc;
45293  
45294         printk(KERN_INFO "fb%d: platinum frame buffer device\n",
45295                p->info.node);
45296  
45297 -       return 1;
45298 -}
45299 -
45300 -int __init platinum_init(void)
45301 -{
45302 -       struct device_node *dp;
45303 -
45304 -       dp = find_devices("platinum");
45305 -       if (dp != 0)
45306 -               platinum_of_init(dp);
45307         return 0;
45308  }
45309  
45310 -#ifdef __powerpc__
45311 -#define invalidate_cache(addr) \
45312 -       asm volatile("eieio; dcbf 0,%1" \
45313 -       : "=m" (*(addr)) : "r" (addr) : "memory");
45314 -#else
45315 -#define invalidate_cache(addr)
45316 -#endif
45317 -
45318 -static void __init platinum_of_init(struct device_node *dp)
45319 -{
45320 -       struct fb_info_platinum *info;
45321 -       unsigned long           addr, size;
45322 -       volatile __u8           *fbuffer;
45323 -       int                     i, bank0, bank1, bank2, bank3;
45324 -
45325 -       if(dp->n_addrs != 2) {
45326 -               printk(KERN_ERR "expecting 2 address for platinum (got %d)", dp->n_addrs);
45327 -               return;
45328 -       }
45329 -
45330 -       info = kmalloc(sizeof(*info), GFP_ATOMIC);
45331 -       if (info == 0)
45332 -               return;
45333 -       memset(info, 0, sizeof(*info));
45334 -
45335 -       /* Map in frame buffer and registers */
45336 -       for (i = 0; i < dp->n_addrs; ++i) {
45337 -               addr = dp->addrs[i].address;
45338 -               size = dp->addrs[i].size;
45339 -               /* Let's assume we can request either all or nothing */
45340 -               if (!request_mem_region(addr, size, "platinumfb")) {
45341 -                       kfree(info);
45342 -                       return;
45343 -               }
45344 -               if (size >= 0x400000) {
45345 -                       /* frame buffer - map only 4MB */
45346 -                       info->frame_buffer_phys = addr;
45347 -                       info->frame_buffer = __ioremap(addr, 0x400000, _PAGE_WRITETHRU);
45348 -                       info->base_frame_buffer = info->frame_buffer;
45349 -               } else {
45350 -                       /* registers */
45351 -                       info->platinum_regs_phys = addr;
45352 -                       info->platinum_regs = ioremap(addr, size);
45353 -               }
45354 -       }
45355 -
45356 -       info->cmap_regs_phys = 0xf301b000;      /* XXX not in prom? */
45357 -       request_mem_region(info->cmap_regs_phys, 0x1000, "platinumfb cmap");
45358 -       info->cmap_regs = ioremap(info->cmap_regs_phys, 0x1000);
45359 -
45360 -       /* Grok total video ram */
45361 -       out_be32(&info->platinum_regs->reg[16].r, (unsigned)info->frame_buffer_phys);
45362 -       out_be32(&info->platinum_regs->reg[20].r, 0x1011);      /* select max vram */
45363 -       out_be32(&info->platinum_regs->reg[24].r, 0);   /* switch in vram */
45364 -
45365 -       fbuffer = info->base_frame_buffer;
45366 -       fbuffer[0x100000] = 0x34;
45367 -       fbuffer[0x100008] = 0x0;
45368 -       invalidate_cache(&fbuffer[0x100000]);
45369 -       fbuffer[0x200000] = 0x56;
45370 -       fbuffer[0x200008] = 0x0;
45371 -       invalidate_cache(&fbuffer[0x200000]);
45372 -       fbuffer[0x300000] = 0x78;
45373 -       fbuffer[0x300008] = 0x0;
45374 -       invalidate_cache(&fbuffer[0x300000]);
45375 -       bank0 = 1; /* builtin 1MB vram, always there */
45376 -       bank1 = fbuffer[0x100000] == 0x34;
45377 -       bank2 = fbuffer[0x200000] == 0x56;
45378 -       bank3 = fbuffer[0x300000] == 0x78;
45379 -       info->total_vram = (bank0 + bank1 + bank2 + bank3) * 0x100000;
45380 -       printk(KERN_INFO "Total VRAM = %dMB %d%d%d%d\n", (int) (info->total_vram / 1024 / 1024), bank3, bank2, bank1, bank0);
45381 -
45382 -       /*
45383 -        * Try to determine whether we have an old or a new DACula.
45384 -        */
45385 -       out_8(&info->cmap_regs->addr, 0x40);
45386 -       info->dactype = in_8(&info->cmap_regs->d2);
45387 -       switch (info->dactype) {
45388 -       case 0x3c:
45389 -               info->clktype = 1;
45390 -               break;
45391 -       case 0x84:
45392 -               info->clktype = 0;
45393 -               break;
45394 -       default:
45395 -               info->clktype = 0;
45396 -               printk(KERN_INFO "Unknown DACula type: %x\n", info->dactype);
45397 -               break;
45398 -       }
45399 -
45400 -       if (!init_platinum(info)) {
45401 -               kfree(info);
45402 -               return;
45403 -       }
45404 -}
45405 -
45406  /*
45407   * Get the monitor sense value.
45408   * Note that this can be called before calibrate_delay,
45409 @@ -630,4 +525,169 @@
45410         return 0;
45411  }
45412  
45413 +#ifdef __powerpc__
45414 +#define invalidate_cache(addr) \
45415 +       asm volatile("eieio; dcbf 0,%1" \
45416 +       : "=m" (*(addr)) : "r" (addr) : "memory");
45417 +#else
45418 +#define invalidate_cache(addr)
45419 +#endif
45420 +
45421 +static int __devinit platinumfb_probe(struct of_device* odev, const struct of_match *match)
45422 +{
45423 +       struct device_node      *dp = odev->node;
45424 +       struct fb_info_platinum *info;
45425 +       unsigned long           addr, size;
45426 +       volatile __u8           *fbuffer;
45427 +       int                     i, bank0, bank1, bank2, bank3, rc;
45428 +
45429 +       if (dp->n_addrs != 2) {
45430 +               printk(KERN_ERR "expecting 2 address for platinum (got %d)", dp->n_addrs);
45431 +               return -ENXIO;
45432 +       }
45433 +
45434 +       info = kmalloc(sizeof(*info), GFP_ATOMIC);
45435 +       if (info == 0)
45436 +               return -ENOMEM;
45437 +       memset(info, 0, sizeof(*info));
45438 +
45439 +       /* Map in frame buffer and registers */
45440 +       for (i = 0; i < dp->n_addrs; ++i) {
45441 +               addr = dp->addrs[i].address;
45442 +               size = dp->addrs[i].size;
45443 +               /* Let's assume we can request either all or nothing */
45444 +               if (!request_mem_region(addr, size, "platinumfb")) {
45445 +                       kfree(info);
45446 +                       return -ENXIO;
45447 +               }
45448 +               if (size >= 0x400000) {
45449 +                       /* frame buffer - map only 4MB */
45450 +                       info->frame_buffer_phys = addr;
45451 +                       info->frame_buffer = __ioremap(addr, 0x400000, _PAGE_WRITETHRU);
45452 +                       info->base_frame_buffer = info->frame_buffer;
45453 +               } else {
45454 +                       /* registers */
45455 +                       info->platinum_regs_phys = addr;
45456 +                       info->platinum_regs = ioremap(addr, size);
45457 +               }
45458 +       }
45459 +
45460 +       info->cmap_regs_phys = 0xf301b000;      /* XXX not in prom? */
45461 +       request_mem_region(info->cmap_regs_phys, 0x1000, "platinumfb cmap");
45462 +       info->cmap_regs = ioremap(info->cmap_regs_phys, 0x1000);
45463 +
45464 +       /* Grok total video ram */
45465 +       out_be32(&info->platinum_regs->reg[16].r, (unsigned)info->frame_buffer_phys);
45466 +       out_be32(&info->platinum_regs->reg[20].r, 0x1011);      /* select max vram */
45467 +       out_be32(&info->platinum_regs->reg[24].r, 0);   /* switch in vram */
45468 +
45469 +       fbuffer = info->base_frame_buffer;
45470 +       fbuffer[0x100000] = 0x34;
45471 +       fbuffer[0x100008] = 0x0;
45472 +       invalidate_cache(&fbuffer[0x100000]);
45473 +       fbuffer[0x200000] = 0x56;
45474 +       fbuffer[0x200008] = 0x0;
45475 +       invalidate_cache(&fbuffer[0x200000]);
45476 +       fbuffer[0x300000] = 0x78;
45477 +       fbuffer[0x300008] = 0x0;
45478 +       invalidate_cache(&fbuffer[0x300000]);
45479 +       bank0 = 1; /* builtin 1MB vram, always there */
45480 +       bank1 = fbuffer[0x100000] == 0x34;
45481 +       bank2 = fbuffer[0x200000] == 0x56;
45482 +       bank3 = fbuffer[0x300000] == 0x78;
45483 +       info->total_vram = (bank0 + bank1 + bank2 + bank3) * 0x100000;
45484 +       printk(KERN_INFO "Total VRAM = %dMB %d%d%d%d\n", (int) (info->total_vram / 1024 / 1024), bank3, bank2, bank1, bank0);
45485 +
45486 +       /*
45487 +        * Try to determine whether we have an old or a new DACula.
45488 +        */
45489 +       out_8(&info->cmap_regs->addr, 0x40);
45490 +       info->dactype = in_8(&info->cmap_regs->d2);
45491 +       switch (info->dactype) {
45492 +       case 0x3c:
45493 +               info->clktype = 1;
45494 +               break;
45495 +       case 0x84:
45496 +               info->clktype = 0;
45497 +               break;
45498 +       default:
45499 +               info->clktype = 0;
45500 +               printk(KERN_INFO "Unknown DACula type: %x\n", info->dactype);
45501 +               break;
45502 +       }
45503 +       dev_set_drvdata(&odev->dev, info);
45504 +       
45505 +       rc = platinum_init_fb(info);
45506 +       if (rc != 0) {
45507 +               dev_set_drvdata(&odev->dev, NULL);
45508 +               kfree(info);
45509 +       }
45510 +
45511 +       return rc;
45512 +}
45513 +
45514 +static int __devexit platinumfb_remove(struct of_device* odev)
45515 +{
45516 +       struct fb_info_platinum *pinfo = dev_get_drvdata(&odev->dev);
45517 +       struct device_node *dp = odev->node;
45518 +       unsigned long addr, size;
45519 +       int i;
45520 +       
45521 +       if (!pinfo)
45522 +               return 0;
45523 +
45524 +        unregister_framebuffer (&pinfo->info);
45525 +       
45526 +       /* Unmap frame buffer and registers */
45527 +       for (i = 0; i < dp->n_addrs; ++i) {
45528 +               addr = dp->addrs[i].address;
45529 +               size = dp->addrs[i].size;
45530 +               release_mem_region(addr, size);
45531 +       }
45532 +       iounmap((void *)pinfo->frame_buffer);
45533 +       iounmap((void *)pinfo->platinum_regs);
45534 +       release_mem_region(pinfo->cmap_regs_phys, 0x1000);
45535 +       iounmap((void *)pinfo->cmap_regs);
45536 +
45537 +       kfree(pinfo);
45538 +
45539 +       return 0;
45540 +}
45541 +
45542 +static struct of_match platinumfb_match[] = 
45543 +{
45544 +       {
45545 +       .name           = "platinum",
45546 +       .type           = OF_ANY_MATCH,
45547 +       .compatible     = OF_ANY_MATCH,
45548 +       },
45549 +       {},
45550 +};
45551 +
45552 +static struct of_platform_driver platinum_driver = 
45553 +{
45554 +       .name           = "platinumfb",
45555 +       .match_table    = platinumfb_match,
45556 +       .probe          = platinumfb_probe,
45557 +       .remove         = platinumfb_remove,
45558 +};
45559 +
45560 +int __init platinum_init(void)
45561 +{
45562 +       of_register_driver(&platinum_driver);
45563 +
45564 +       return 0;
45565 +}
45566 +
45567 +void __exit platinum_exit(void)
45568 +{
45569 +       of_unregister_driver(&platinum_driver); 
45570 +}
45571 +
45572  MODULE_LICENSE("GPL");
45573 +MODULE_DESCRIPTION("framebuffer driver for Apple Platinum video");
45574 +
45575 +#ifdef MODULE
45576 +module_init(platinum_init);
45577 +module_exit(platinum_exit);
45578 +#endif
45579 diff -Nru a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c
45580 --- a/drivers/video/riva/fbdev.c        Thu Jul 31 08:58:45 2003
45581 +++ b/drivers/video/riva/fbdev.c        Sun Aug 31 16:14:08 2003
45582 @@ -297,34 +297,34 @@
45583  #endif
45584  
45585  static struct fb_fix_screeninfo rivafb_fix = {
45586 -       id:             "nVidia",
45587 -       type:           FB_TYPE_PACKED_PIXELS,
45588 -       xpanstep:       1,
45589 -       ypanstep:       1,
45590 +       .id             = "nVidia",
45591 +       .type           = FB_TYPE_PACKED_PIXELS,
45592 +       .xpanstep       = 1,
45593 +       .ypanstep       = 1,
45594  };
45595  
45596  static struct fb_var_screeninfo rivafb_default_var = {
45597 -       xres:           640,
45598 -       yres:           480,
45599 -       xres_virtual:   640,
45600 -       yres_virtual:   480,
45601 -       bits_per_pixel: 8,
45602 -       red:            {0, 8, 0},
45603 -       green:          {0, 8, 0},
45604 -       blue:           {0, 8, 0},
45605 -       transp:         {0, 0, 0},
45606 -       activate:       FB_ACTIVATE_NOW,
45607 -       height:         -1,
45608 -       width:          -1,
45609 -       accel_flags:    FB_ACCELF_TEXT,
45610 -       pixclock:       39721,
45611 -       left_margin:    40,
45612 -       right_margin:   24,
45613 -       upper_margin:   32,
45614 -       lower_margin:   11,
45615 -       hsync_len:      96,
45616 -       vsync_len:      2,
45617 -       vmode:          FB_VMODE_NONINTERLACED
45618 +       .xres           = 640,
45619 +       .yres           = 480,
45620 +       .xres_virtual   = 640,
45621 +       .yres_virtual   = 480,
45622 +       .bits_per_pixel = 8,
45623 +       .red            = {0, 8, 0},
45624 +       .green          = {0, 8, 0},
45625 +       .blue           = {0, 8, 0},
45626 +       .transp         = {0, 0, 0},
45627 +       .activate       = FB_ACTIVATE_NOW,
45628 +       .height         = -1,
45629 +       .width          = -1,
45630 +       .accel_flags    = FB_ACCELF_TEXT,
45631 +       .pixclock       = 39721,
45632 +       .left_margin    = 40,
45633 +       .right_margin   = 24,
45634 +       .upper_margin   = 32,
45635 +       .lower_margin   = 11,
45636 +       .hsync_len      = 96,
45637 +       .vsync_len      = 2,
45638 +       .vmode          = FB_VMODE_NONINTERLACED
45639  };
45640  
45641  /* from GGI */
45642 @@ -1977,10 +1977,10 @@
45643  #endif /* !MODULE */
45644  
45645  static struct pci_driver rivafb_driver = {
45646 -       name:           "rivafb",
45647 -       id_table:       rivafb_pci_tbl,
45648 -       probe:          rivafb_probe,
45649 -       remove:         __exit_p(rivafb_remove),
45650 +       .name           = "rivafb",
45651 +       .id_table       = rivafb_pci_tbl,
45652 +       .probe          = rivafb_probe,
45653 +       .remove         = __exit_p(rivafb_remove),
45654  };
45655  
45656  
45657 diff -Nru a/drivers/video/stifb.c b/drivers/video/stifb.c
45658 --- a/drivers/video/stifb.c     Sat May 31 23:26:17 2003
45659 +++ b/drivers/video/stifb.c     Tue Aug 26 09:25:41 2003
45660 @@ -890,7 +890,7 @@
45661  {
45662         unsigned long p = *ppos;
45663         struct inode *inode = file->f_dentry->d_inode;
45664 -       int fbidx = minor(inode->i_rdev);
45665 +       int fbidx = iminor(inode);
45666         struct fb_info *info = registered_fb[fbidx];
45667         char tmpbuf[TMPBUFLEN];
45668  
45669 @@ -922,7 +922,7 @@
45670  stifb_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
45671  {
45672         struct inode *inode = file->f_dentry->d_inode;
45673 -       int fbidx = minor(inode->i_rdev);
45674 +       int fbidx = iminor(inode);
45675         struct fb_info *info = registered_fb[fbidx];
45676         unsigned long p = *ppos;
45677         size_t c;
45678 diff -Nru a/fs/affs/file.c b/fs/affs/file.c
45679 --- a/fs/affs/file.c    Sat Dec 14 09:42:09 2002
45680 +++ b/fs/affs/file.c    Sun Aug 31 16:14:08 2003
45681 @@ -793,8 +793,8 @@
45682  
45683  struct address_space_operations affs_aops_ofs = {
45684         .readpage = affs_readpage_ofs,
45685 -       //writepage: affs_writepage_ofs,
45686 -       //sync_page: affs_sync_page_ofs,
45687 +       //.writepage = affs_writepage_ofs,
45688 +       //.sync_page = affs_sync_page_ofs,
45689         .prepare_write = affs_prepare_write_ofs,
45690         .commit_write = affs_commit_write_ofs
45691  };
45692 diff -Nru a/fs/afs/callback.c b/fs/afs/callback.c
45693 --- a/fs/afs/callback.c Tue Oct  8 01:00:44 2002
45694 +++ b/fs/afs/callback.c Tue Aug 26 09:37:39 2003
45695 @@ -146,7 +146,7 @@
45696                         spin_unlock(&vnode->lock);
45697  
45698                         if (valid) {
45699 -                               invalidate_inode_pages(inode->i_mapping);
45700 +                               invalidate_remote_inode(inode);
45701                                 afs_put_server(server);
45702                         }
45703                         iput(inode);
45704 diff -Nru a/fs/afs/dir.c b/fs/afs/dir.c
45705 --- a/fs/afs/dir.c      Thu Jul  3 06:36:44 2003
45706 +++ b/fs/afs/dir.c      Tue Aug 26 09:37:39 2003
45707 @@ -569,7 +569,7 @@
45708                         spin_lock(&AFS_FS_I(inode)->lock);
45709                         AFS_FS_I(inode)->flags |= AFS_VNODE_DELETED;
45710                         spin_unlock(&AFS_FS_I(inode)->lock);
45711 -                       invalidate_inode_pages(inode->i_mapping);
45712 +                       invalidate_remote_inode(inode);
45713                         goto out_bad;
45714                 }
45715  
45716 diff -Nru a/fs/bad_inode.c b/fs/bad_inode.c
45717 --- a/fs/bad_inode.c    Tue Dec  3 11:20:54 2002
45718 +++ b/fs/bad_inode.c    Sun Aug 31 16:14:21 2003
45719 @@ -4,6 +4,8 @@
45720   *  Copyright (C) 1997, Stephen Tweedie
45721   *
45722   *  Provide stub functions for unreadable inodes
45723 + *
45724 + *  Fabian Frederick : August 2003 - All file operations assigned to EIO
45725   */
45726  
45727  #include <linux/fs.h>
45728 @@ -31,8 +33,10 @@
45729  static struct file_operations bad_file_ops =
45730  {
45731         .llseek         = EIO_ERROR,
45732 +       .aio_read       = EIO_ERROR,
45733         .read           = EIO_ERROR,
45734         .write          = EIO_ERROR,
45735 +       .aio_write      = EIO_ERROR,
45736         .readdir        = EIO_ERROR,
45737         .poll           = EIO_ERROR,
45738         .ioctl          = EIO_ERROR,
45739 @@ -41,8 +45,14 @@
45740         .flush          = EIO_ERROR,
45741         .release        = EIO_ERROR,
45742         .fsync          = EIO_ERROR,
45743 +       .aio_fsync      = EIO_ERROR,
45744         .fasync         = EIO_ERROR,
45745         .lock           = EIO_ERROR,
45746 +       .readv          = EIO_ERROR,
45747 +       .writev         = EIO_ERROR,
45748 +       .sendfile       = EIO_ERROR,
45749 +       .sendpage       = EIO_ERROR,
45750 +       .get_unmapped_area = EIO_ERROR,
45751  };
45752  
45753  struct inode_operations bad_inode_ops =
45754 @@ -61,6 +71,11 @@
45755         .truncate       = EIO_ERROR,
45756         .permission     = EIO_ERROR,
45757         .getattr        = EIO_ERROR,
45758 +       .setattr        = EIO_ERROR,
45759 +       .setxattr       = EIO_ERROR,
45760 +       .getxattr       = EIO_ERROR,
45761 +       .listxattr      = EIO_ERROR,
45762 +       .removexattr    = EIO_ERROR,
45763  };
45764  
45765  
45766 diff -Nru a/fs/bio.c b/fs/bio.c
45767 --- a/fs/bio.c  Fri May  2 11:30:24 2003
45768 +++ b/fs/bio.c  Thu Aug 21 07:58:40 2003
45769 @@ -793,10 +793,6 @@
45770                                         mempool_free_slab, bp->slab);
45771                 if (!bp->pool)
45772                         panic("biovec: can't init mempool\n");
45773 -
45774 -               printk("biovec pool[%d]: %3d bvecs: %3d entries (%d bytes)\n",
45775 -                                               i, bp->nr_vecs, pool_entries,
45776 -                                               size);
45777         }
45778  }
45779  
45780 @@ -809,8 +805,6 @@
45781         bio_pool = mempool_create(BIO_POOL_SIZE, mempool_alloc_slab, mempool_free_slab, bio_slab);
45782         if (!bio_pool)
45783                 panic("bio: can't create mempool\n");
45784 -
45785 -       printk("BIO: pool of %d setup, %ZuKb (%Zd bytes/bio)\n", BIO_POOL_SIZE, BIO_POOL_SIZE * sizeof(struct bio) >> 10, sizeof(struct bio));
45786  
45787         biovec_init_pools();
45788  
45789 diff -Nru a/fs/block_dev.c b/fs/block_dev.c
45790 --- a/fs/block_dev.c    Wed Aug 20 22:31:51 2003
45791 +++ b/fs/block_dev.c    Tue Aug 26 12:06:15 2003
45792 @@ -197,40 +197,36 @@
45793   * pseudo-fs
45794   */
45795  
45796 -static struct super_block *bd_get_sb(struct file_system_type *fs_type,
45797 -       int flags, const char *dev_name, void *data)
45798 -{
45799 -       return get_sb_pseudo(fs_type, "bdev:", NULL, 0x62646576);
45800 -}
45801 +static spinlock_t bdev_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
45802 +static kmem_cache_t * bdev_cachep;
45803  
45804 -static struct file_system_type bd_type = {
45805 -       .name           = "bdev",
45806 -       .get_sb         = bd_get_sb,
45807 -       .kill_sb        = kill_anon_super,
45808 +struct bdev_inode {
45809 +       struct block_device bdev;
45810 +       struct inode vfs_inode;
45811  };
45812  
45813 -static struct vfsmount *bd_mnt;
45814 -struct super_block *blockdev_superblock;
45815 -
45816 -/*
45817 - * bdev cache handling - shamelessly stolen from inode.c
45818 - * We use smaller hashtable, though.
45819 - */
45820 +static inline struct bdev_inode *BDEV_I(struct inode *inode)
45821 +{
45822 +       return container_of(inode, struct bdev_inode, vfs_inode);
45823 +}
45824  
45825 -#define HASH_BITS      6
45826 -#define HASH_SIZE      (1UL << HASH_BITS)
45827 -#define HASH_MASK      (HASH_SIZE-1)
45828 -static struct list_head bdev_hashtable[HASH_SIZE];
45829 -static spinlock_t bdev_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
45830 -static kmem_cache_t * bdev_cachep;
45831 +static struct inode *bdev_alloc_inode(struct super_block *sb)
45832 +{
45833 +       struct bdev_inode *ei = kmem_cache_alloc(bdev_cachep, SLAB_KERNEL);
45834 +       if (!ei)
45835 +               return NULL;
45836 +       return &ei->vfs_inode;
45837 +}
45838  
45839 -#define alloc_bdev() \
45840 -        ((struct block_device *) kmem_cache_alloc(bdev_cachep, SLAB_KERNEL))
45841 -#define destroy_bdev(bdev) kmem_cache_free(bdev_cachep, (bdev))
45842 +static void bdev_destroy_inode(struct inode *inode)
45843 +{
45844 +       kmem_cache_free(bdev_cachep, BDEV_I(inode));
45845 +}
45846  
45847  static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
45848  {
45849 -       struct block_device * bdev = (struct block_device *) foo;
45850 +       struct bdev_inode *ei = (struct bdev_inode *) foo;
45851 +       struct block_device *bdev = &ei->bdev;
45852  
45853         if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
45854             SLAB_CTOR_CONSTRUCTOR)
45855 @@ -238,25 +234,62 @@
45856                 memset(bdev, 0, sizeof(*bdev));
45857                 sema_init(&bdev->bd_sem, 1);
45858                 INIT_LIST_HEAD(&bdev->bd_inodes);
45859 +               INIT_LIST_HEAD(&bdev->bd_list);
45860 +               inode_init_once(&ei->vfs_inode);
45861         }
45862  }
45863  
45864 -void __init bdev_cache_init(void)
45865 +static inline void __bd_forget(struct inode *inode)
45866 +{
45867 +       list_del_init(&inode->i_devices);
45868 +       inode->i_bdev = NULL;
45869 +       inode->i_mapping = &inode->i_data;
45870 +}
45871 +
45872 +static void bdev_clear_inode(struct inode *inode)
45873 +{
45874 +       struct block_device *bdev = &BDEV_I(inode)->bdev;
45875 +       struct list_head *p;
45876 +       spin_lock(&bdev_lock);
45877 +       while ( (p = bdev->bd_inodes.next) != &bdev->bd_inodes ) {
45878 +               __bd_forget(list_entry(p, struct inode, i_devices));
45879 +       }
45880 +       list_del_init(&bdev->bd_list);
45881 +       spin_unlock(&bdev_lock);
45882 +}
45883 +
45884 +static struct super_operations bdev_sops = {
45885 +       .statfs = simple_statfs,
45886 +       .alloc_inode = bdev_alloc_inode,
45887 +       .destroy_inode = bdev_destroy_inode,
45888 +       .drop_inode = generic_delete_inode,
45889 +       .clear_inode = bdev_clear_inode,
45890 +};
45891 +
45892 +static struct super_block *bd_get_sb(struct file_system_type *fs_type,
45893 +       int flags, const char *dev_name, void *data)
45894  {
45895 -       int i, err;
45896 -       struct list_head *head = bdev_hashtable;
45897 +       return get_sb_pseudo(fs_type, "bdev:", &bdev_sops, 0x62646576);
45898 +}
45899 +
45900 +static struct file_system_type bd_type = {
45901 +       .name           = "bdev",
45902 +       .get_sb         = bd_get_sb,
45903 +       .kill_sb        = kill_anon_super,
45904 +};
45905  
45906 -       i = HASH_SIZE;
45907 -       do {
45908 -               INIT_LIST_HEAD(head);
45909 -               head++;
45910 -               i--;
45911 -       } while (i);
45912 +static struct vfsmount *bd_mnt;
45913 +struct super_block *blockdev_superblock;
45914  
45915 +void __init bdev_cache_init(void)
45916 +{
45917 +       int err;
45918         bdev_cachep = kmem_cache_create("bdev_cache",
45919 -                                        sizeof(struct block_device),
45920 -                                        0, SLAB_HWCACHE_ALIGN, init_once,
45921 -                                        NULL);
45922 +                                       sizeof(struct bdev_inode),
45923 +                                       0,
45924 +                                       SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
45925 +                                       init_once,
45926 +                                       NULL);
45927         if (!bdev_cachep)
45928                 panic("Cannot create bdev_cache SLAB cache");
45929         err = register_filesystem(&bd_type);
45930 @@ -272,123 +305,83 @@
45931  /*
45932   * Most likely _very_ bad one - but then it's hardly critical for small
45933   * /dev and can be fixed when somebody will need really large one.
45934 + * Keep in mind that it will be fed through icache hash function too.
45935   */
45936  static inline unsigned long hash(dev_t dev)
45937  {
45938 -       unsigned long tmp = dev;
45939 -       tmp = tmp + (tmp >> HASH_BITS) + (tmp >> HASH_BITS*2);
45940 -       return tmp & HASH_MASK;
45941 +       return MAJOR(dev)+MINOR(dev);
45942  }
45943  
45944 -static struct block_device *bdfind(dev_t dev, struct list_head *head)
45945 +static int bdev_test(struct inode *inode, void *data)
45946  {
45947 -       struct list_head *p;
45948 -       struct block_device *bdev;
45949 -       list_for_each(p, head) {
45950 -               bdev = list_entry(p, struct block_device, bd_hash);
45951 -               if (bdev->bd_dev != dev)
45952 -                       continue;
45953 -               atomic_inc(&bdev->bd_count);
45954 -               return bdev;
45955 -       }
45956 -       return NULL;
45957 +       return BDEV_I(inode)->bdev.bd_dev == *(dev_t *)data;
45958  }
45959  
45960 +static int bdev_set(struct inode *inode, void *data)
45961 +{
45962 +       BDEV_I(inode)->bdev.bd_dev = *(dev_t *)data;
45963 +       return 0;
45964 +}
45965 +
45966 +static LIST_HEAD(all_bdevs);
45967 +
45968  struct block_device *bdget(dev_t dev)
45969  {
45970 -       struct list_head * head = bdev_hashtable + hash(dev);
45971 -       struct block_device *bdev, *new_bdev;
45972 -       spin_lock(&bdev_lock);
45973 -       bdev = bdfind(dev, head);
45974 -       spin_unlock(&bdev_lock);
45975 -       if (bdev)
45976 -               return bdev;
45977 -       new_bdev = alloc_bdev();
45978 -       if (new_bdev) {
45979 -               struct inode *inode = new_inode(bd_mnt->mnt_sb);
45980 -               if (inode) {
45981 -                       kdev_t kdev = to_kdev_t(dev);
45982 -
45983 -                       atomic_set(&new_bdev->bd_count,1);
45984 -                       new_bdev->bd_dev = dev;
45985 -                       new_bdev->bd_contains = NULL;
45986 -                       new_bdev->bd_inode = inode;
45987 -                       new_bdev->bd_block_size = (1 << inode->i_blkbits);
45988 -                       new_bdev->bd_part_count = 0;
45989 -                       new_bdev->bd_invalidated = 0;
45990 -                       inode->i_mode = S_IFBLK;
45991 -                       inode->i_rdev = kdev;
45992 -                       inode->i_bdev = new_bdev;
45993 -                       inode->i_data.a_ops = &def_blk_aops;
45994 -                       mapping_set_gfp_mask(&inode->i_data, GFP_USER);
45995 -                       inode->i_data.backing_dev_info = &default_backing_dev_info;
45996 -                       spin_lock(&bdev_lock);
45997 -                       bdev = bdfind(dev, head);
45998 -                       if (!bdev) {
45999 -                               list_add(&new_bdev->bd_hash, head);
46000 -                               spin_unlock(&bdev_lock);
46001 -                               return new_bdev;
46002 -                       }
46003 -                       spin_unlock(&bdev_lock);
46004 -                       iput(new_bdev->bd_inode);
46005 -               }
46006 -               destroy_bdev(new_bdev);
46007 +       struct block_device *bdev;
46008 +       struct inode *inode;
46009 +
46010 +       inode = iget5_locked(bd_mnt->mnt_sb, hash(dev),
46011 +                       bdev_test, bdev_set, &dev);
46012 +
46013 +       if (!inode)
46014 +               return NULL;
46015 +
46016 +       bdev = &BDEV_I(inode)->bdev;
46017 +
46018 +       if (inode->i_state & I_NEW) {
46019 +               bdev->bd_contains = NULL;
46020 +               bdev->bd_inode = inode;
46021 +               bdev->bd_block_size = (1 << inode->i_blkbits);
46022 +               bdev->bd_part_count = 0;
46023 +               bdev->bd_invalidated = 0;
46024 +               inode->i_mode = S_IFBLK;
46025 +               inode->i_rdev = to_kdev_t(dev);
46026 +               inode->i_bdev = bdev;
46027 +               inode->i_data.a_ops = &def_blk_aops;
46028 +               mapping_set_gfp_mask(&inode->i_data, GFP_USER);
46029 +               inode->i_data.backing_dev_info = &default_backing_dev_info;
46030 +               spin_lock(&bdev_lock);
46031 +               list_add(&bdev->bd_list, &all_bdevs);
46032 +               spin_unlock(&bdev_lock);
46033 +               unlock_new_inode(inode);
46034         }
46035         return bdev;
46036  }
46037  
46038  long nr_blockdev_pages(void)
46039  {
46040 +       struct list_head *p;
46041         long ret = 0;
46042 -       int i;
46043 -
46044         spin_lock(&bdev_lock);
46045 -       for (i = 0; i < ARRAY_SIZE(bdev_hashtable); i++) {
46046 -               struct list_head *head = &bdev_hashtable[i];
46047 -               struct list_head *lh;
46048 -
46049 -               if (head == NULL)
46050 -                       continue;
46051 -               list_for_each(lh, head) {
46052 -                       struct block_device *bdev;
46053 -
46054 -                       bdev = list_entry(lh, struct block_device, bd_hash);
46055 -                       ret += bdev->bd_inode->i_mapping->nrpages;
46056 -               }
46057 +       list_for_each(p, &all_bdevs) {
46058 +               struct block_device *bdev;
46059 +               bdev = list_entry(p, struct block_device, bd_list);
46060 +               ret += bdev->bd_inode->i_mapping->nrpages;
46061         }
46062         spin_unlock(&bdev_lock);
46063         return ret;
46064  }
46065  
46066 -static inline void __bd_forget(struct inode *inode)
46067 -{
46068 -       list_del_init(&inode->i_devices);
46069 -       inode->i_bdev = NULL;
46070 -       inode->i_mapping = &inode->i_data;
46071 -}
46072 -
46073  void bdput(struct block_device *bdev)
46074  {
46075 -       if (atomic_dec_and_lock(&bdev->bd_count, &bdev_lock)) {
46076 -               struct list_head *p;
46077 -               if (bdev->bd_openers)
46078 -                       BUG();
46079 -               list_del(&bdev->bd_hash);
46080 -               while ( (p = bdev->bd_inodes.next) != &bdev->bd_inodes ) {
46081 -                       __bd_forget(list_entry(p, struct inode, i_devices));
46082 -               }
46083 -               spin_unlock(&bdev_lock);
46084 -               iput(bdev->bd_inode);
46085 -               destroy_bdev(bdev);
46086 -       }
46087 +       iput(bdev->bd_inode);
46088  }
46089   
46090  int bd_acquire(struct inode *inode)
46091  {
46092         struct block_device *bdev;
46093         spin_lock(&bdev_lock);
46094 -       if (inode->i_bdev) {
46095 -               atomic_inc(&inode->i_bdev->bd_count);
46096 +       if (inode->i_bdev && igrab(inode->i_bdev->bd_inode)) {
46097                 spin_unlock(&bdev_lock);
46098                 return 0;
46099         }
46100 @@ -397,12 +390,11 @@
46101         if (!bdev)
46102                 return -ENOMEM;
46103         spin_lock(&bdev_lock);
46104 -       if (!inode->i_bdev) {
46105 -               inode->i_bdev = bdev;
46106 -               inode->i_mapping = bdev->bd_inode->i_mapping;
46107 -               list_add(&inode->i_devices, &bdev->bd_inodes);
46108 -       } else if (inode->i_bdev != bdev)
46109 -               BUG();
46110 +       if (inode->i_bdev)
46111 +               __bd_forget(inode);
46112 +       inode->i_bdev = bdev;
46113 +       inode->i_mapping = bdev->bd_inode->i_mapping;
46114 +       list_add(&inode->i_devices, &bdev->bd_inodes);
46115         spin_unlock(&bdev_lock);
46116         return 0;
46117  }
46118 @@ -548,7 +540,6 @@
46119                                 if (ret)
46120                                         goto out_first;
46121                         }
46122 -                       bdev->bd_offset = 0;
46123                         if (!bdev->bd_openers) {
46124                                 bd_set_size(bdev,(loff_t)get_capacity(disk)<<9);
46125                                 bdi = blk_get_backing_dev_info(bdev);
46126 @@ -580,7 +571,8 @@
46127                                 ret = -ENXIO;
46128                                 goto out_first;
46129                         }
46130 -                       bdev->bd_offset = p->start_sect;
46131 +                       kobject_get(&p->kobj);
46132 +                       bdev->bd_part = p;
46133                         bd_set_size(bdev, (loff_t) p->nr_sects << 9);
46134                         up(&whole->bd_sem);
46135                 }
46136 @@ -701,6 +693,10 @@
46137                 put_disk(disk);
46138                 module_put(owner);
46139  
46140 +               if (bdev->bd_contains != bdev) {
46141 +                       kobject_put(&bdev->bd_part->kobj);
46142 +                       bdev->bd_part = NULL;
46143 +               }
46144                 bdev->bd_disk = NULL;
46145                 bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info;
46146                 if (bdev != bdev->bd_contains) {
46147 diff -Nru a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
46148 --- a/fs/cifs/cifsfs.c  Sun Aug 10 22:50:41 2003
46149 +++ b/fs/cifs/cifsfs.c  Tue Aug 26 09:37:39 2003
46150 @@ -598,10 +598,12 @@
46151                                 netfid = oplock_item->netfid;
46152                                 DeleteOplockQEntry(oplock_item);
46153                                 write_unlock(&GlobalMid_Lock);
46154 -                               rc = filemap_fdatawrite(inode->i_mapping);
46155 -                               if(rc)
46156 -                                       CIFS_I(inode)->write_behind_rc 
46157 -                                               = rc;
46158 +                               if (S_ISREG(inode->i_mode))
46159 +                                       rc = filemap_fdatawrite(inode->i_mapping);
46160 +                               else
46161 +                                       rc = 0;
46162 +                               if (rc)
46163 +                                       CIFS_I(inode)->write_behind_rc = rc;
46164                                 cFYI(1,("Oplock flush inode %p rc %d",inode,rc));
46165                                 rc = CIFSSMBLock(0, pTcon, netfid,
46166                                         0 /* len */ , 0 /* offset */, 0, 
46167 diff -Nru a/fs/coda/inode.c b/fs/coda/inode.c
46168 --- a/fs/coda/inode.c   Fri Jun 20 13:16:06 2003
46169 +++ b/fs/coda/inode.c   Tue Aug 26 09:25:41 2003
46170 @@ -115,7 +115,7 @@
46171                 inode = file->f_dentry->d_inode;
46172         
46173         if(!inode || !S_ISCHR(inode->i_mode) ||
46174 -          major(inode->i_rdev) != CODA_PSDEV_MAJOR) {
46175 +          imajor(inode) != CODA_PSDEV_MAJOR) {
46176                 if(file)
46177                         fput(file);
46178  
46179 @@ -123,7 +123,7 @@
46180                 return -1;
46181         }
46182  
46183 -       idx = minor(inode->i_rdev);
46184 +       idx = iminor(inode);
46185         fput(file);
46186  
46187         if(idx < 0 || idx >= MAX_CODADEVS) {
46188 diff -Nru a/fs/coda/psdev.c b/fs/coda/psdev.c
46189 --- a/fs/coda/psdev.c   Wed May  7 08:47:30 2003
46190 +++ b/fs/coda/psdev.c   Tue Aug 26 09:25:41 2003
46191 @@ -279,7 +279,7 @@
46192         int idx;
46193  
46194         lock_kernel();
46195 -       idx = minor(inode->i_rdev);
46196 +       idx = iminor(inode);
46197         if(idx >= MAX_CODADEVS) {
46198                 unlock_kernel();
46199                 return -ENODEV;
46200 diff -Nru a/fs/compat.c b/fs/compat.c
46201 --- a/fs/compat.c       Sun Jul 13 14:26:23 2003
46202 +++ b/fs/compat.c       Sun Aug 31 16:14:44 2003
46203 @@ -227,7 +227,8 @@
46204  #define IOCTL_HASHSIZE 256
46205  struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE];
46206  
46207 -extern struct ioctl_trans ioctl_start[], ioctl_end[]; 
46208 +extern struct ioctl_trans ioctl_start[];
46209 +extern int ioctl_table_size;
46210  
46211  static inline unsigned long ioctl32_hash(unsigned long cmd)
46212  {
46213 @@ -255,7 +256,7 @@
46214  {
46215         int i;
46216  
46217 -       for (i = 0; &ioctl_start[i] < &ioctl_end[0]; i++) {
46218 +       for (i = 0; i < ioctl_table_size; i++) {
46219                 if (ioctl_start[i].next != 0) { 
46220                         printk("ioctl translation %d bad\n",i); 
46221                         return -1;
46222 @@ -318,8 +319,7 @@
46223  
46224  static inline int builtin_ioctl(struct ioctl_trans *t)
46225  { 
46226 -       return t >= (struct ioctl_trans *)ioctl_start &&
46227 -              t < (struct ioctl_trans *)ioctl_end; 
46228 +       return t >= ioctl_start && t < (ioctl_start + ioctl_table_size);
46229  } 
46230  
46231  /* Problem: 
46232 diff -Nru a/fs/compat_ioctl.c b/fs/compat_ioctl.c
46233 --- a/fs/compat_ioctl.c Thu Jul  3 15:19:48 2003
46234 +++ b/fs/compat_ioctl.c Tue Aug 26 09:25:40 2003
46235 @@ -1573,7 +1573,7 @@
46236                 return -EINVAL;
46237                         
46238         tty = (struct tty_struct *)file->private_data;
46239 -       if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
46240 +       if (tty_paranoia_check(tty, inode, "tty_ioctl"))
46241                 return -EINVAL;
46242                                                         
46243         if (tty->driver->ioctl != vt_ioctl)
46244 diff -Nru a/fs/dnotify.c b/fs/dnotify.c
46245 --- a/fs/dnotify.c      Wed Apr  2 22:51:32 2003
46246 +++ b/fs/dnotify.c      Sun Aug 31 16:14:42 2003
46247 @@ -20,8 +20,6 @@
46248  #include <linux/spinlock.h>
46249  #include <linux/slab.h>
46250  
46251 -extern void send_sigio(struct fown_struct *fown, int fd, int band);
46252 -
46253  int dir_notify_enable = 1;
46254  
46255  static rwlock_t dn_lock = RW_LOCK_UNLOCKED;
46256 @@ -94,7 +92,7 @@
46257                 prev = &odn->dn_next;
46258         }
46259  
46260 -       error = f_setown(filp, current->pid, 1);
46261 +       error = f_setown(filp, current->tgid, 1);
46262         if (error)
46263                 goto out_free;
46264  
46265 diff -Nru a/fs/ext2/namei.c b/fs/ext2/namei.c
46266 --- a/fs/ext2/namei.c   Sun Jun 29 23:49:04 2003
46267 +++ b/fs/ext2/namei.c   Sun Aug 31 16:14:21 2003
46268 @@ -143,7 +143,7 @@
46269         int err = PTR_ERR(inode);
46270         if (!IS_ERR(inode)) {
46271                 init_special_inode(inode, inode->i_mode, rdev);
46272 -#ifdef CONFIG_EXT2_FS_EXT_ATTR
46273 +#ifdef CONFIG_EXT2_FS_XATTR
46274                 inode->i_op = &ext2_special_inode_operations;
46275  #endif
46276                 mark_inode_dirty(inode);
46277 diff -Nru a/fs/ext3/namei.c b/fs/ext3/namei.c
46278 --- a/fs/ext3/namei.c   Wed Aug 20 22:32:02 2003
46279 +++ b/fs/ext3/namei.c   Sun Aug 31 16:14:18 2003
46280 @@ -1306,7 +1306,7 @@
46281  
46282         /* The 0th block becomes the root, move the dirents out */
46283         fde = &root->dotdot;
46284 -       de = (struct ext3_dir_entry_2 *)((char *)fde + fde->rec_len);
46285 +       de = (struct ext3_dir_entry_2 *)((char *)fde + le16_to_cpu(fde->rec_len));
46286         len = ((char *) root) + blocksize - (char *) de;
46287         memcpy (data1, de, len);
46288         de = (struct ext3_dir_entry_2 *) data1;
46289 diff -Nru a/fs/ext3/xattr.c b/fs/ext3/xattr.c
46290 --- a/fs/ext3/xattr.c   Thu Jul 17 22:30:42 2003
46291 +++ b/fs/ext3/xattr.c   Sun Aug 31 16:15:47 2003
46292 @@ -873,17 +873,22 @@
46293                const void *value, size_t value_len, int flags)
46294  {
46295         handle_t *handle;
46296 -       int error, error2;
46297 +       int error;
46298  
46299         handle = ext3_journal_start(inode, EXT3_DATA_TRANS_BLOCKS);
46300 -       if (IS_ERR(handle))
46301 +       if (IS_ERR(handle)) {
46302                 error = PTR_ERR(handle);
46303 -       else
46304 +       } else {
46305 +               int error2;
46306 +
46307                 error = ext3_xattr_set_handle(handle, inode, name_index, name,
46308                                               value, value_len, flags);
46309 -       error2 = ext3_journal_stop(handle);
46310 +               error2 = ext3_journal_stop(handle);
46311 +               if (error == 0)
46312 +                       error = error2;
46313 +       }
46314  
46315 -       return error ? error : error2;
46316 +       return error;
46317  }
46318  
46319  /*
46320 diff -Nru a/fs/fcntl.c b/fs/fcntl.c
46321 --- a/fs/fcntl.c        Thu Jun  5 23:36:40 2003
46322 +++ b/fs/fcntl.c        Sun Aug 31 16:14:42 2003
46323 @@ -6,6 +6,7 @@
46324  
46325  #include <linux/init.h>
46326  #include <linux/mm.h>
46327 +#include <linux/fs.h>
46328  #include <linux/file.h>
46329  #include <linux/dnotify.h>
46330  #include <linux/smp_lock.h>
46331 @@ -17,9 +18,6 @@
46332  #include <asm/poll.h>
46333  #include <asm/siginfo.h>
46334  #include <asm/uaccess.h>
46335 -
46336 -extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
46337 -extern int fcntl_getlease(struct file *filp);
46338  
46339  void set_close_on_exec(unsigned int fd, int flag)
46340  {
46341 diff -Nru a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c
46342 --- a/fs/freevxfs/vxfs_inode.c  Sun Nov 17 11:53:57 2002
46343 +++ b/fs/freevxfs/vxfs_inode.c  Sun Aug 31 16:14:27 2003
46344 @@ -171,7 +171,7 @@
46345         return NULL;
46346  
46347  fail:
46348 -       printk(KERN_WARNING "vxfs: unable to read inode %ld\n", ino);
46349 +       printk(KERN_WARNING "vxfs: unable to read inode %ld\n", (unsigned long)ino);
46350         vxfs_put_page(pp);
46351         return NULL;
46352  }
46353 diff -Nru a/fs/hpfs/namei.c b/fs/hpfs/namei.c
46354 --- a/fs/hpfs/namei.c   Sun Jun 29 23:49:25 2003
46355 +++ b/fs/hpfs/namei.c   Tue Aug 26 09:37:39 2003
46356 @@ -375,6 +375,7 @@
46357                 spin_lock(&dentry->d_lock);
46358                 if (atomic_read(&dentry->d_count) > 1 ||
46359                     permission(inode, MAY_WRITE, NULL) ||
46360 +                   !S_ISREG(inode->i_mode) ||
46361                     get_write_access(inode)) {
46362                         spin_unlock(&dentry->d_lock);
46363                         d_rehash(dentry);
46364 diff -Nru a/fs/intermezzo/presto.c b/fs/intermezzo/presto.c
46365 --- a/fs/intermezzo/presto.c    Fri Dec 13 17:27:19 2002
46366 +++ b/fs/intermezzo/presto.c    Tue Aug 26 09:33:56 2003
46367 @@ -66,8 +66,8 @@
46368          cache = presto_get_cache(inode);
46369          CDEBUG(D_PSDEV, "\n");
46370          if ( !cache ) {
46371 -                CERROR("PRESTO: BAD: cannot find cache for dev %d, ino %ld\n",
46372 -                       inode->i_sb->s_dev, inode->i_ino);
46373 +                CERROR("PRESTO: BAD: cannot find cache for dev %s, ino %ld\n",
46374 +                       inode->i_sb->s_id, inode->i_ino);
46375                  EXIT;
46376                  return -1;
46377          }
46378 diff -Nru a/fs/intermezzo/vfs.c b/fs/intermezzo/vfs.c
46379 --- a/fs/intermezzo/vfs.c       Thu Aug  7 10:29:14 2003
46380 +++ b/fs/intermezzo/vfs.c       Tue Aug 26 09:33:56 2003
46381 @@ -743,7 +743,7 @@
46382                  goto exit_lock;
46383  
46384          error = -EXDEV;
46385 -        if (dir->d_inode->i_sb->s_dev != inode->i_sb->s_dev)
46386 +        if (dir->d_inode->i_sb != inode->i_sb)
46387                  goto exit_lock;
46388  
46389          /*
46390 @@ -1800,7 +1800,7 @@
46391          if (error)
46392                  return error;
46393  
46394 -        if (new_dir->i_sb->s_dev != old_dir->i_sb->s_dev)
46395 +        if (new_dir->i_sb != old_dir->i_sb)
46396                  return -EXDEV;
46397  
46398          if (!new_dentry->d_inode)
46399 @@ -1881,7 +1881,7 @@
46400          if (error)
46401                  return error;
46402  
46403 -        if (new_dir->i_sb->s_dev != old_dir->i_sb->s_dev)
46404 +        if (new_dir->i_sb != old_dir->i_sb)
46405                  return -EXDEV;
46406  
46407          if (!new_dentry->d_inode)
46408 diff -Nru a/fs/jbd/journal.c b/fs/jbd/journal.c
46409 --- a/fs/jbd/journal.c  Sat Aug 16 11:46:50 2003
46410 +++ b/fs/jbd/journal.c  Sun Aug 31 16:14:25 2003
46411 @@ -1890,7 +1890,6 @@
46412  {
46413         int ret;
46414  
46415 -       printk(KERN_INFO "Journalled Block Device driver loaded\n");
46416         ret = journal_init_caches();
46417         if (ret != 0)
46418                 journal_destroy_caches();
46419 diff -Nru a/fs/jffs/inode-v23.c b/fs/jffs/inode-v23.c
46420 --- a/fs/jffs/inode-v23.c       Thu Aug 14 18:17:32 2003
46421 +++ b/fs/jffs/inode-v23.c       Sun Aug 31 16:13:59 2003
46422 @@ -1080,9 +1080,11 @@
46423         struct jffs_control *c;
46424         struct inode *inode;
46425         int result = 0;
46426 -       kdev_t dev = to_kdev_t(rdev);
46427 +       u16 data;
46428         int err;
46429  
46430 +       data = (MAJOR(rdev) << 8) | MINOR(rdev);
46431 +
46432         D1(printk("***jffs_mknod()\n"));
46433  
46434         lock_kernel();
46435 @@ -1114,7 +1116,7 @@
46436         raw_inode.mtime = raw_inode.atime;
46437         raw_inode.ctime = raw_inode.atime;
46438         raw_inode.offset = 0;
46439 -       raw_inode.dsize = sizeof(kdev_t);
46440 +       raw_inode.dsize = 2;
46441         raw_inode.rsize = 0;
46442         raw_inode.nsize = dentry->d_name.len;
46443         raw_inode.nlink = 1;
46444 @@ -1124,7 +1126,7 @@
46445  
46446         /* Write the new node to the flash.  */
46447         if ((err = jffs_write_node(c, node, &raw_inode, dentry->d_name.name,
46448 -                                  (unsigned char *)&dev, 0, NULL)) < 0) {
46449 +                                  (unsigned char *)&data, 0, NULL)) < 0) {
46450                 D(printk("jffs_mknod(): jffs_write_node() failed.\n"));
46451                 result = err;
46452                 goto jffs_mknod_err;
46453 @@ -1530,7 +1532,7 @@
46454         return err;
46455  } /* jffs_file_write()  */
46456  
46457 -static ssize_t
46458 +static int
46459  jffs_prepare_write(struct file *filp, struct page *page,
46460                    unsigned from, unsigned to)
46461  {
46462 @@ -1543,7 +1545,7 @@
46463         return 0;
46464  } /* jffs_prepare_write() */
46465  
46466 -static ssize_t
46467 +static int
46468  jffs_commit_write(struct file *filp, struct page *page,
46469                   unsigned from, unsigned to)
46470  {
46471 @@ -1732,9 +1734,10 @@
46472                 /* If the node is a device of some sort, then the number of
46473                    the device should be read from the flash memory and then
46474                    added to the inode's i_rdev member.  */
46475 -               kdev_t rdev;
46476 -               jffs_read_data(f, (char *)&rdev, 0, sizeof(kdev_t));
46477 -               init_special_inode(inode, inode->i_mode, kdev_t_to_nr(rdev));
46478 +               u16 val;
46479 +               jffs_read_data(f, (char *)val, 0, 2);
46480 +               init_special_inode(inode, inode->i_mode,
46481 +                       MKDEV((val >> 8) & 255, val & 255));
46482         }
46483  
46484         D3(printk (KERN_NOTICE "read_inode(): up biglock\n"));
46485 diff -Nru a/fs/jffs2/file.c b/fs/jffs2/file.c
46486 --- a/fs/jffs2/file.c   Wed May 28 08:01:06 2003
46487 +++ b/fs/jffs2/file.c   Tue Aug 26 09:25:41 2003
46488 @@ -103,8 +103,8 @@
46489            it out again with the appropriate data attached */
46490         if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) {
46491                 /* For these, we don't actually need to read the old node */
46492 -               dev =  (major(dentry->d_inode->i_rdev) << 8) | 
46493 -                       minor(dentry->d_inode->i_rdev);
46494 +               dev =  (imajor(dentry->d_inode) << 8) | 
46495 +                       iminor(dentry->d_inode);
46496                 mdata = (char *)&dev;
46497                 mdatalen = sizeof(dev);
46498                 D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of kdev_t\n", mdatalen));
46499 diff -Nru a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
46500 --- a/fs/jffs2/os-linux.h       Mon Jun 23 06:03:50 2003
46501 +++ b/fs/jffs2/os-linux.h       Tue Aug 26 09:25:41 2003
46502 @@ -44,8 +44,8 @@
46503  #define JFFS2_F_I_GID(f) (OFNI_EDONI_2SFFJ(f)->i_gid)
46504  
46505  #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,1)
46506 -#define JFFS2_F_I_RDEV_MIN(f) (minor(OFNI_EDONI_2SFFJ(f)->i_rdev))
46507 -#define JFFS2_F_I_RDEV_MAJ(f) (major(OFNI_EDONI_2SFFJ(f)->i_rdev))
46508 +#define JFFS2_F_I_RDEV_MIN(f) (iminor(OFNI_EDONI_2SFFJ(f)))
46509 +#define JFFS2_F_I_RDEV_MAJ(f) (imajor(OFNI_EDONI_2SFFJ(f)))
46510  #else
46511  #define JFFS2_F_I_RDEV_MIN(f) (MINOR(to_kdev_t(OFNI_EDONI_2SFFJ(f)->i_rdev)))
46512  #define JFFS2_F_I_RDEV_MAJ(f) (MAJOR(to_kdev_t(OFNI_EDONI_2SFFJ(f)->i_rdev)))
46513 diff -Nru a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
46514 --- a/fs/jffs2/wbuf.c   Wed May 28 08:01:07 2003
46515 +++ b/fs/jffs2/wbuf.c   Sun Aug 31 16:14:08 2003
46516 @@ -37,8 +37,8 @@
46517  #define NAND_JFFS2_OOB16_FSDALEN       8
46518  
46519  struct nand_oobinfo jffs2_oobinfo = {
46520 -       useecc: 1,
46521 -       eccpos: {JFFS2_OOB_ECCPOS0, JFFS2_OOB_ECCPOS1, JFFS2_OOB_ECCPOS2, JFFS2_OOB_ECCPOS3, JFFS2_OOB_ECCPOS4, JFFS2_OOB_ECCPOS5}
46522 +       .useecc = 1,
46523 +       .eccpos = {JFFS2_OOB_ECCPOS0, JFFS2_OOB_ECCPOS1, JFFS2_OOB_ECCPOS2, JFFS2_OOB_ECCPOS3, JFFS2_OOB_ECCPOS4, JFFS2_OOB_ECCPOS5}
46524  };
46525  
46526  static inline void jffs2_refile_wbuf_blocks(struct jffs2_sb_info *c)
46527 diff -Nru a/fs/nfs/inode.c b/fs/nfs/inode.c
46528 --- a/fs/nfs/inode.c    Fri Jul 11 10:32:02 2003
46529 +++ b/fs/nfs/inode.c    Tue Aug 26 09:37:39 2003
46530 @@ -620,7 +620,7 @@
46531         NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode);
46532         NFS_ATTRTIMEO_UPDATE(inode) = jiffies;
46533  
46534 -       invalidate_inode_pages(inode->i_mapping);
46535 +       invalidate_remote_inode(inode);
46536  
46537         memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode)));
46538         NFS_CACHEINV(inode);
46539 @@ -823,14 +823,15 @@
46540                 goto out;
46541         }
46542  
46543 -       if (!S_ISREG(inode->i_mode))
46544 +       if (!S_ISREG(inode->i_mode)) {
46545                 attr->ia_valid &= ~ATTR_SIZE;
46546 -
46547 -       filemap_fdatawrite(inode->i_mapping);
46548 -       error = nfs_wb_all(inode);
46549 -       filemap_fdatawait(inode->i_mapping);
46550 -       if (error)
46551 -               goto out;
46552 +       } else {
46553 +               filemap_fdatawrite(inode->i_mapping);
46554 +               error = nfs_wb_all(inode);
46555 +               filemap_fdatawait(inode->i_mapping);
46556 +               if (error)
46557 +                       goto out;
46558 +       }
46559  
46560         error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr);
46561         if (error)
46562 @@ -1205,7 +1206,7 @@
46563         if (invalid) {
46564                 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
46565                 nfsi->attrtimeo_timestamp = jiffies;
46566 -               invalidate_inode_pages(inode->i_mapping);
46567 +               invalidate_remote_inode(inode);
46568                 memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode)));
46569         } else if (time_after(jiffies, nfsi->attrtimeo_timestamp+nfsi->attrtimeo)) {
46570                 if ((nfsi->attrtimeo <<= 1) > NFS_MAXATTRTIMEO(inode))
46571 diff -Nru a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
46572 --- a/fs/nfsd/nfs4proc.c        Thu Jun 26 21:26:02 2003
46573 +++ b/fs/nfsd/nfs4proc.c        Sun Aug 31 16:14:23 2003
46574 @@ -106,7 +106,8 @@
46575  nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
46576  {
46577         int status;
46578 -       dprintk("NFSD: nfsd4_open filename %.*s\n",open->op_fname.len, open->op_fname.data);
46579 +       dprintk("NFSD: nfsd4_open filename %.*s\n",
46580 +               (int)open->op_fname.len, open->op_fname.data);
46581  
46582         /* This check required by spec. */
46583         if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL)
46584 diff -Nru a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
46585 --- a/fs/nfsd/nfs4state.c       Thu Jul 31 16:53:11 2003
46586 +++ b/fs/nfsd/nfs4state.c       Sun Aug 31 16:14:23 2003
46587 @@ -688,7 +688,7 @@
46588  #define OPENSTATEID_HASH_MASK              (OPENSTATEID_HASH_SIZE - 1)
46589  
46590  #define file_hashval(x) \
46591 -        ((unsigned int)((x)->dev + (x)->ino + (x)->generation) & FILE_HASH_MASK)
46592 +        hash_ptr(x, FILE_HASH_BITS)
46593  #define openstateid_hashval(owner_id, file_id)  \
46594          (((owner_id) + (file_id)) & OPENSTATEID_HASH_MASK)
46595  
46596 @@ -697,13 +697,13 @@
46597  
46598  /* OPEN Share state helper functions */
46599  static inline struct nfs4_file *
46600 -alloc_init_file(unsigned int hashval, nfs4_ino_desc_t *ino) {
46601 +alloc_init_file(unsigned int hashval, struct inode *ino) {
46602         struct nfs4_file *fp;
46603         if ((fp = kmalloc(sizeof(struct nfs4_file),GFP_KERNEL))) {
46604                 INIT_LIST_HEAD(&fp->fi_hash);
46605                 INIT_LIST_HEAD(&fp->fi_perfile);
46606                 list_add(&fp->fi_hash, &file_hashtbl[hashval]);
46607 -               memcpy(&fp->fi_ino, ino, sizeof(nfs4_ino_desc_t));
46608 +               fp->fi_inode = igrab(ino);
46609                 fp->fi_id = current_fileid++;
46610                 alloc_file++;
46611                 return fp;
46612 @@ -841,11 +841,12 @@
46613  {
46614         free_file++;
46615         list_del_init(&fp->fi_hash);
46616 +       iput(fp->fi_inode);
46617         kfree(fp);
46618  }      
46619  
46620  void
46621 -release_open_state(struct nfs4_stateid *stp)
46622 +release_open_state(struct nfs4_stateid *stp, struct nfsd4_close *cl)
46623  {
46624         struct nfs4_stateowner *sop = stp->st_stateowner;
46625         struct nfs4_file *fp = stp->st_file;
46626 @@ -860,6 +861,7 @@
46627          */
46628         if (sop->so_confirmed && list_empty(&sop->so_peropenstate)) {
46629                 release_stateowner(sop);
46630 +               cl->cl_stateowner = NULL;
46631         }
46632         /* unused nfs4_file's are releseed. XXX slab cache? */
46633         if (list_empty(&fp->fi_perfile)) {
46634 @@ -911,13 +913,13 @@
46635  
46636  /* search file_hashtbl[] for file */
46637  static int
46638 -find_file(unsigned int hashval, nfs4_ino_desc_t *ino, struct nfs4_file **fp) {
46639 +find_file(unsigned int hashval, struct inode *ino, struct nfs4_file **fp) {
46640         struct list_head *pos, *next;
46641         struct nfs4_file *local = NULL;
46642  
46643         list_for_each_safe(pos, next, &file_hashtbl[hashval]) {
46644                 local = list_entry(pos, struct nfs4_file, fi_hash);
46645 -               if(!memcmp(&local->fi_ino, ino, sizeof(nfs4_ino_desc_t))) {
46646 +               if (local->fi_inode == ino) {
46647                         *fp = local;
46648                         return(1);
46649                 }
46650 @@ -934,24 +936,10 @@
46651         return 1;
46652  }
46653  
46654 -static inline void
46655 -nfs4_init_ino(nfs4_ino_desc_t *ino, struct svc_fh *fhp)
46656 -{
46657 -       struct inode *inode;
46658 -       if (!fhp->fh_dentry)
46659 -               BUG();
46660 -       inode = fhp->fh_dentry->d_inode;
46661 -       if (!inode)
46662 -               BUG();
46663 -       ino->dev = inode->i_sb->s_dev;
46664 -       ino->ino = inode->i_ino;
46665 -       ino->generation = inode->i_generation;
46666 -}
46667 -
46668  int
46669  nfs4_share_conflict(struct svc_fh *current_fh, unsigned int deny_type)
46670  {
46671 -       nfs4_ino_desc_t ino;
46672 +       struct inode *ino = current_fh->fh_dentry->d_inode;
46673         unsigned int fi_hashval;
46674         struct nfs4_file *fp;
46675         struct nfs4_stateid *stp;
46676 @@ -959,9 +947,8 @@
46677  
46678         dprintk("NFSD: nfs4_share_conflict\n");
46679  
46680 -       nfs4_init_ino(&ino, current_fh);
46681 -       fi_hashval = file_hashval(&ino);
46682 -       if (find_file(fi_hashval, &ino, &fp)) {
46683 +       fi_hashval = file_hashval(ino);
46684 +       if (find_file(fi_hashval, ino, &fp)) {
46685         /* Search for conflicting share reservations */
46686                 list_for_each_safe(pos, next, &fp->fi_perfile) {
46687                         stp = list_entry(pos, struct nfs4_stateid, st_perfile);
46688 @@ -1084,7 +1071,7 @@
46689         struct iattr iattr;
46690         struct nfs4_stateowner *sop = open->op_stateowner;
46691         struct nfs4_file *fp;
46692 -       nfs4_ino_desc_t ino;
46693 +       struct inode *ino;
46694         unsigned int fi_hashval;
46695         struct list_head *pos, *next;
46696         struct nfs4_stateid *stq, *stp = NULL;
46697 @@ -1094,11 +1081,11 @@
46698         if (!sop)
46699                 goto out;
46700  
46701 -       nfs4_init_ino(&ino, current_fh);
46702 +       ino = current_fh->fh_dentry->d_inode;
46703  
46704         down(&client_sema); /*XXX need finer grained locking */
46705 -       fi_hashval = file_hashval(&ino);
46706 -       if (find_file(fi_hashval, &ino, &fp)) {
46707 +       fi_hashval = file_hashval(ino);
46708 +       if (find_file(fi_hashval, ino, &fp)) {
46709                 /* Search for conflicting share reservations */
46710                 status = nfserr_share_denied;
46711                 list_for_each_safe(pos, next, &fp->fi_perfile) {
46712 @@ -1113,7 +1100,7 @@
46713         } else {
46714         /* No nfs4_file found; allocate and init a new one */
46715                 status = nfserr_resource;
46716 -               if ((fp = alloc_init_file(fi_hashval, &ino)) == NULL)
46717 +               if ((fp = alloc_init_file(fi_hashval, ino)) == NULL)
46718                         goto out;
46719         }
46720  
46721 @@ -1172,6 +1159,9 @@
46722         open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE;
46723         status = nfs_ok;
46724  out:
46725 +       if (fp && list_empty(&fp->fi_perfile))
46726 +               release_file(fp);
46727 +
46728         /*
46729         * To finish the open response, we just need to set the rflags.
46730         */
46731 @@ -1494,7 +1484,7 @@
46732         struct nfs4_stateid *stp;
46733  
46734         dprintk("NFSD: nfsd4_open_confirm on file %.*s\n",
46735 -                       current_fh->fh_dentry->d_name.len,
46736 +                       (int)current_fh->fh_dentry->d_name.len,
46737                         current_fh->fh_dentry->d_name.name);
46738         oc->oc_stateowner = NULL;
46739         down(&client_sema); /* XXX need finer grained locking */
46740 @@ -1528,7 +1518,7 @@
46741         struct nfs4_stateid *stp;
46742  
46743         dprintk("NFSD: nfsd4_open_downgrade on file %.*s\n", 
46744 -                       current_fh->fh_dentry->d_name.len, 
46745 +                       (int)current_fh->fh_dentry->d_name.len,
46746                         current_fh->fh_dentry->d_name.name);
46747  
46748         down(&client_sema); /* XXX need finer grained locking */
46749 @@ -1567,7 +1557,7 @@
46750         struct nfs4_stateid *stp;
46751  
46752         dprintk("NFSD: nfsd4_close on file %.*s\n", 
46753 -                       current_fh->fh_dentry->d_name.len, 
46754 +                       (int)current_fh->fh_dentry->d_name.len,
46755                         current_fh->fh_dentry->d_name.name);
46756  
46757         down(&client_sema); /* XXX need finer grained locking */
46758 @@ -1584,7 +1574,7 @@
46759         memcpy(&close->cl_stateid, &stp->st_stateid, sizeof(stateid_t));
46760  
46761         /* release_open_state() calls nfsd_close() if needed */
46762 -       release_open_state(stp);
46763 +       release_open_state(stp,close);
46764  out:
46765         up(&client_sema);
46766         return status;
46767 diff -Nru a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
46768 --- a/fs/nfsd/nfs4xdr.c Sun Aug  3 21:42:17 2003
46769 +++ b/fs/nfsd/nfs4xdr.c Sat Aug 23 15:07:47 2003
46770 @@ -1631,6 +1631,8 @@
46771                 WRITEMEM(&close->cl_stateid.si_opaque, sizeof(stateid_opaque_t));
46772                 ADJUST_ARGS();
46773         }
46774 +       if ((close->cl_stateowner) && (close->cl_stateowner->so_confirmed))
46775 +               close->cl_stateowner->so_seqid++;
46776  }
46777  
46778  
46779 @@ -1767,6 +1769,8 @@
46780         default:
46781                 BUG();
46782         }
46783 +
46784 +       ENCODE_SEQID_OP_TAIL(open->op_stateowner);
46785  }
46786  
46787  static int
46788 diff -Nru a/fs/open.c b/fs/open.c
46789 --- a/fs/open.c Mon Aug 18 22:38:39 2003
46790 +++ b/fs/open.c Sun Aug 31 16:14:00 2003
46791 @@ -945,20 +945,12 @@
46792   */
46793  int filp_close(struct file *filp, fl_owner_t id)
46794  {
46795 -       struct address_space *mapping = filp->f_dentry->d_inode->i_mapping;
46796 -       int retval = 0, err;
46797 +       int retval;
46798  
46799         /* Report and clear outstanding errors */
46800 -       err = filp->f_error;
46801 -       if (err) {
46802 +       retval = filp->f_error;
46803 +       if (retval)
46804                 filp->f_error = 0;
46805 -               retval = err;
46806 -       }
46807 -
46808 -       if (test_and_clear_bit(AS_ENOSPC, &mapping->flags))
46809 -               retval = -ENOSPC;
46810 -       if (test_and_clear_bit(AS_EIO, &mapping->flags))
46811 -               retval = -EIO;
46812  
46813         if (!file_count(filp)) {
46814                 printk(KERN_ERR "VFS: Close: file count is 0\n");
46815 @@ -966,7 +958,7 @@
46816         }
46817  
46818         if (filp->f_op && filp->f_op->flush) {
46819 -               err = filp->f_op->flush(filp);
46820 +               int err = filp->f_op->flush(filp);
46821                 if (!retval)
46822                         retval = err;
46823         }
46824 diff -Nru a/fs/partitions/check.c b/fs/partitions/check.c
46825 --- a/fs/partitions/check.c     Tue Aug 12 06:46:16 2003
46826 +++ b/fs/partitions/check.c     Tue Aug 26 12:06:15 2003
46827 @@ -267,7 +267,14 @@
46828  
46829  extern struct subsystem block_subsys;
46830  
46831 +static void part_release(struct kobject *kobj)
46832 +{
46833 +       struct hd_struct * p = container_of(kobj,struct hd_struct,kobj);
46834 +       kfree(p);
46835 +}
46836 +
46837  struct kobj_type ktype_part = {
46838 +       .release        = part_release,
46839         .default_attrs  = default_attrs,
46840         .sysfs_ops      = &part_sysfs_ops,
46841  };
46842 @@ -279,13 +286,12 @@
46843                 return;
46844         if (!p->nr_sects)
46845                 return;
46846 +       disk->part[part-1] = NULL;
46847         p->start_sect = 0;
46848         p->nr_sects = 0;
46849         p->reads = p->writes = p->read_sectors = p->write_sectors = 0;
46850         devfs_remove("%s/part%d", disk->devfs_name, part);
46851         kobject_unregister(&p->kobj);
46852 -       disk->part[part-1] = NULL;
46853 -       kfree(p);
46854  }
46855  
46856  void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len)
46857 @@ -300,7 +306,6 @@
46858         p->start_sect = start;
46859         p->nr_sects = len;
46860         p->partno = part;
46861 -       disk->part[part-1] = p;
46862  
46863         devfs_mk_bdev(MKDEV(disk->major, disk->first_minor + part),
46864                         S_IFBLK|S_IRUSR|S_IWUSR,
46865 @@ -310,6 +315,7 @@
46866         p->kobj.parent = &disk->kobj;
46867         p->kobj.ktype = &ktype_part;
46868         kobject_register(&p->kobj);
46869 +       disk->part[part-1] = p;
46870  }
46871  
46872  static void disk_sysfs_symlinks(struct gendisk *disk)
46873 diff -Nru a/fs/proc/base.c b/fs/proc/base.c
46874 --- a/fs/proc/base.c    Thu Jul 10 22:23:45 2003
46875 +++ b/fs/proc/base.c    Sun Aug 31 16:13:56 2003
46876 @@ -864,19 +864,34 @@
46877   *     Exceptional case: normally we are not allowed to unhash a busy
46878   * directory. In this case, however, we can do it - no aliasing problems
46879   * due to the way we treat inodes.
46880 + *
46881 + * Rewrite the inode's ownerships here because the owning task may have
46882 + * performed a setuid(), etc.
46883   */
46884 -static int pid_revalidate(struct dentry * dentry, struct nameidata *nd)
46885 +static int pid_revalidate(struct dentry *dentry, struct nameidata *nd)
46886  {
46887 -       if (pid_alive(proc_task(dentry->d_inode)))
46888 +       struct inode *inode = dentry->d_inode;
46889 +       struct task_struct *task = proc_task(inode);
46890 +       if (pid_alive(task)) {
46891 +               if (proc_type(inode) == PROC_PID_INO || task_dumpable(task)) {
46892 +                       inode->i_uid = task->euid;
46893 +                       inode->i_gid = task->egid;
46894 +               } else {
46895 +                       inode->i_uid = 0;
46896 +                       inode->i_gid = 0;
46897 +               }
46898 +               security_task_to_inode(task, inode);
46899                 return 1;
46900 +       }
46901         d_drop(dentry);
46902         return 0;
46903  }
46904  
46905 -static int pid_fd_revalidate(struct dentry * dentry, struct nameidata *nd)
46906 +static int pid_fd_revalidate(struct dentry *dentry, struct nameidata *nd)
46907  {
46908 -       struct task_struct *task = proc_task(dentry->d_inode);
46909 -       int fd = proc_type(dentry->d_inode) - PROC_PID_FD_DIR;
46910 +       struct inode *inode = dentry->d_inode;
46911 +       struct task_struct *task = proc_task(inode);
46912 +       int fd = proc_type(inode) - PROC_PID_FD_DIR;
46913         struct files_struct *files;
46914  
46915         task_lock(task);
46916 @@ -889,6 +904,14 @@
46917                 if (fcheck_files(files, fd)) {
46918                         spin_unlock(&files->file_lock);
46919                         put_files_struct(files);
46920 +                       if (task_dumpable(task)) {
46921 +                               inode->i_uid = task->euid;
46922 +                               inode->i_gid = task->egid;
46923 +                       } else {
46924 +                               inode->i_uid = 0;
46925 +                               inode->i_gid = 0;
46926 +                       }
46927 +                       security_task_to_inode(task, inode);
46928                         return 1;
46929                 }
46930                 spin_unlock(&files->file_lock);
46931 diff -Nru a/fs/proc/kcore.c b/fs/proc/kcore.c
46932 --- a/fs/proc/kcore.c   Fri Jun 20 13:16:05 2003
46933 +++ b/fs/proc/kcore.c   Sun Aug 31 16:14:22 2003
46934 @@ -1,5 +1,5 @@
46935  /*
46936 - *     fs/proc/kcore.c kernel ELF/AOUT core dumper
46937 + *     fs/proc/kcore.c kernel ELF core dumper
46938   *
46939   *     Modelled on fs/exec.c:aout_core_dump()
46940   *     Jeremy Fitzhardinge <jeremy@sw.oz.au>
46941 @@ -34,71 +34,6 @@
46942         .open           = open_kcore,
46943  };
46944  
46945 -#ifdef CONFIG_KCORE_AOUT
46946 -static ssize_t read_kcore(struct file *file, char *buf, size_t count, loff_t *ppos)
46947 -{
46948 -       unsigned long long p = *ppos, memsize;
46949 -       ssize_t read;
46950 -       ssize_t count1;
46951 -       char * pnt;
46952 -       struct user dump;
46953 -#if defined (__i386__) || defined (__mc68000__) || defined(__x86_64__)
46954 -#      define FIRST_MAPPED     PAGE_SIZE       /* we don't have page 0 mapped on x86.. */
46955 -#else
46956 -#      define FIRST_MAPPED     0
46957 -#endif
46958 -
46959 -       memset(&dump, 0, sizeof(struct user));
46960 -       dump.magic = CMAGIC;
46961 -       dump.u_dsize = (virt_to_phys(high_memory) >> PAGE_SHIFT);
46962 -#if defined (__i386__) || defined(__x86_64__)
46963 -       dump.start_code = PAGE_OFFSET;
46964 -#endif
46965 -#ifdef __alpha__
46966 -       dump.start_data = PAGE_OFFSET;
46967 -#endif
46968 -
46969 -       memsize = virt_to_phys(high_memory);
46970 -       if (p >= memsize)
46971 -               return 0;
46972 -       if (count > memsize - p)
46973 -               count = memsize - p;
46974 -       read = 0;
46975 -
46976 -       if (p < sizeof(struct user) && count > 0) {
46977 -               count1 = count;
46978 -               if (p + count1 > sizeof(struct user))
46979 -                       count1 = sizeof(struct user)-p;
46980 -               pnt = (char *) &dump + p;
46981 -               if (copy_to_user(buf,(void *) pnt, count1))
46982 -                       return -EFAULT;
46983 -               buf += count1;
46984 -               p += count1;
46985 -               count -= count1;
46986 -               read += count1;
46987 -       }
46988 -
46989 -       if (count > 0 && p < PAGE_SIZE + FIRST_MAPPED) {
46990 -               count1 = PAGE_SIZE + FIRST_MAPPED - p;
46991 -               if (count1 > count)
46992 -                       count1 = count;
46993 -               if (clear_user(buf, count1))
46994 -                       return -EFAULT;
46995 -               buf += count1;
46996 -               p += count1;
46997 -               count -= count1;
46998 -               read += count1;
46999 -       }
47000 -       if (count > 0) {
47001 -               if (copy_to_user(buf, (void *) (PAGE_OFFSET+p-PAGE_SIZE), count))
47002 -                       return -EFAULT;
47003 -               read += count;
47004 -       }
47005 -       *ppos += read;
47006 -       return read;
47007 -}
47008 -#else /* CONFIG_KCORE_AOUT */
47009 -
47010  #ifndef kc_vaddr_to_offset
47011  #define        kc_vaddr_to_offset(v) ((v) - PAGE_OFFSET)
47012  #endif
47013 @@ -480,4 +415,3 @@
47014  
47015         return acc;
47016  }
47017 -#endif /* CONFIG_KCORE_AOUT */
47018 diff -Nru a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
47019 --- a/fs/proc/task_mmu.c        Thu Jun 19 16:57:39 2003
47020 +++ b/fs/proc/task_mmu.c        Sat Aug 23 05:08:00 2003
47021 @@ -90,14 +90,14 @@
47022                 ino = inode->i_ino;
47023         }
47024  
47025 -       seq_printf(m, "%0*lx-%0*lx %c%c%c%c %0*lx %02x:%02x %lu %n",
47026 -                       (int) (2*sizeof(void*)), map->vm_start,
47027 -                       (int) (2*sizeof(void*)), map->vm_end,
47028 +       seq_printf(m, "%08lx-%08lx %c%c%c%c %08lx %02x:%02x %lu %n",
47029 +                       map->vm_start,
47030 +                       map->vm_end,
47031                         flags & VM_READ ? 'r' : '-',
47032                         flags & VM_WRITE ? 'w' : '-',
47033                         flags & VM_EXEC ? 'x' : '-',
47034                         flags & VM_MAYSHARE ? 's' : 'p',
47035 -                       (int) (2*sizeof(void*)), map->vm_pgoff << PAGE_SHIFT,
47036 +                       map->vm_pgoff << PAGE_SHIFT,
47037                         MAJOR(dev), MINOR(dev), ino, &len);
47038  
47039         if (map->vm_file) {
47040 diff -Nru a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
47041 --- a/fs/reiserfs/inode.c       Mon Aug 18 22:42:17 2003
47042 +++ b/fs/reiserfs/inode.c       Sun Aug 31 16:14:17 2003
47043 @@ -2048,8 +2048,8 @@
47044          last_offset = inode->i_size & (PAGE_CACHE_SIZE - 1) ;
47045         /* no file contents in this page */
47046         if (page->index >= end_index + 1 || !last_offset) {
47047 -           error = 0 ;
47048 -           goto done ;
47049 +           unlock_page(page);
47050 +           return 0;
47051         }
47052         kaddr = kmap_atomic(page, KM_USER0);
47053         memset(kaddr + last_offset, 0, PAGE_CACHE_SIZE-last_offset) ;
47054 diff -Nru a/fs/smbfs/inode.c b/fs/smbfs/inode.c
47055 --- a/fs/smbfs/inode.c  Wed Jun 25 16:30:54 2003
47056 +++ b/fs/smbfs/inode.c  Tue Aug 26 09:37:39 2003
47057 @@ -212,7 +212,7 @@
47058                         (long) last_sz, (long) inode->i_size);
47059  
47060                 if (!S_ISDIR(inode->i_mode))
47061 -                       invalidate_inode_pages(inode->i_mapping);
47062 +                       invalidate_remote_inode(inode);
47063         }
47064  }
47065  
47066 @@ -276,7 +276,7 @@
47067                          * But we do want to invalidate the caches ...
47068                          */
47069                         if (!S_ISDIR(inode->i_mode))
47070 -                               invalidate_inode_pages(inode->i_mapping);
47071 +                               invalidate_remote_inode(inode);
47072                         else
47073                                 smb_invalid_dir_cache(inode);
47074                         error = -EIO;
47075 diff -Nru a/fs/vfat/namei.c b/fs/vfat/namei.c
47076 --- a/fs/vfat/namei.c   Sat Aug  2 15:10:30 2003
47077 +++ b/fs/vfat/namei.c   Mon Sep  1 08:45:36 2003
47078 @@ -200,20 +200,6 @@
47079         return 1;
47080  }
47081  
47082 -/* MS-DOS "device special files" */
47083 -
47084 -static const unsigned char *reserved3_names[] = {
47085 -       "con     ", "prn     ", "nul     ", "aux     ", NULL
47086 -};
47087 -
47088 -static const unsigned char *reserved4_names[] = {
47089 -       "com1    ", "com2    ", "com3    ", "com4    ", "com5    ",
47090 -       "com6    ", "com7    ", "com8    ", "com9    ",
47091 -       "lpt1    ", "lpt2    ", "lpt3    ", "lpt4    ", "lpt5    ",
47092 -       "lpt6    ", "lpt7    ", "lpt8    ", "lpt9    ",
47093 -       NULL };
47094 -
47095 -
47096  /* Characters that are undesirable in an MS-DOS file name */
47097  
47098  static wchar_t bad_chars[] = {
47099 @@ -255,38 +241,31 @@
47100         return 0;
47101  }
47102  
47103 -/* Checks the validity of a long MS-DOS filename */
47104 -/* Returns negative number on error, 0 for a normal
47105 - * return, and 1 for . or .. */
47106 -
47107 -static int vfat_valid_longname(const unsigned char *name, int len, int xlate)
47108 +static int vfat_valid_longname(const unsigned char *name, unsigned int len)
47109  {
47110 -       const unsigned char **reserved, *walk;
47111 -       int baselen;
47112 -
47113         if (len && name[len-1] == ' ')
47114 -               return -EINVAL;
47115 +               return 0;
47116         if (len >= 256)
47117 -               return -EINVAL;
47118 -       if (len < 3)
47119                 return 0;
47120  
47121 -       for (walk = name; *walk != 0 && *walk != '.'; walk++)
47122 -               ;
47123 -       baselen = walk - name;
47124 -
47125 -       if (baselen == 3) {
47126 -               for (reserved = reserved3_names; *reserved; reserved++) {
47127 -                       if (!strnicmp(name,*reserved,baselen))
47128 -                               return -EINVAL;
47129 -               }
47130 -       } else if (baselen == 4) {
47131 -               for (reserved = reserved4_names; *reserved; reserved++) {
47132 -                       if (!strnicmp(name,*reserved,baselen))
47133 -                               return -EINVAL;
47134 +       /* MS-DOS "device special files" */
47135 +       if (len == 3 || (len > 3 && name[3] == '.')) {  /* basename == 3 */
47136 +               if (!strnicmp(name, "aux", 3) ||
47137 +                   !strnicmp(name, "con", 3) ||
47138 +                   !strnicmp(name, "nul", 3) ||
47139 +                   !strnicmp(name, "prn", 3))
47140 +                       return 0;
47141 +       }
47142 +       if (len == 4 || (len > 4 && name[4] == '.')) {  /* basename == 4 */
47143 +               /* "com1", "com2", ... */
47144 +               if ('1' <= name[3] && name[3] <= '9') {
47145 +                       if (!strnicmp(name, "com", 3) ||
47146 +                           !strnicmp(name, "lpt", 3))
47147 +                               return 0;
47148                 }
47149         }
47150 -       return 0;
47151 +
47152 +       return 1;
47153  }
47154  
47155  static int vfat_find_form(struct inode *dir, unsigned char *name)
47156 @@ -684,9 +663,8 @@
47157         loff_t offset;
47158  
47159         *slots = 0;
47160 -       res = vfat_valid_longname(name, len, opts->unicode_xlate);
47161 -       if (res < 0)
47162 -               return res;
47163 +       if (!vfat_valid_longname(name, len))
47164 +               return -EINVAL;
47165  
47166         if(!(page = __get_free_page(GFP_KERNEL)))
47167                 return -ENOMEM;
47168 diff -Nru a/include/asm-arm/apm.h b/include/asm-arm/apm.h
47169 --- /dev/null   Wed Dec 31 16:00:00 1969
47170 +++ b/include/asm-arm/apm.h     Thu Aug  7 11:38:41 2003
47171 @@ -0,0 +1,56 @@
47172 +/* -*- linux-c -*-
47173 + *
47174 + * (C) 2003 zecke@handhelds.org
47175 + *
47176 + * GPL version 2
47177 + *
47178 + * based on arch/arm/kernel/apm.c
47179 + * factor out the information needed by architectures to provide
47180 + * apm status
47181 + *
47182 + *
47183 + */
47184 +#ifndef ARM_ASM_SA1100_APM_H
47185 +#define ARM_ASM_SA1100_APM_H
47186 +
47187 +#include <linux/config.h>
47188 +
47189 +#ifdef CONFIG_APM
47190 +
47191 +
47192 +#define APM_AC_OFFLINE 0
47193 +#define APM_AC_ONLINE 1
47194 +#define APM_AC_BACKUP 2
47195 +#define APM_AC_UNKNOWN 0xFF
47196 +
47197 +#define APM_BATTERY_STATUS_HIGH 0
47198 +#define APM_BATTERY_STATUS_LOW  1
47199 +#define APM_BATTERY_STATUS_CRITICAL 2
47200 +#define APM_BATTERY_STATUS_CHARGING 3
47201 +#define APM_BATTERY_STATUS_UNKNOWN 0xFF
47202 +
47203 +#define APM_BATTERY_LIFE_UNKNOWN 0xFFFF
47204 +#define APM_BATTERY_LIFE_MINUTES 0x8000
47205 +#define APM_BATTERY_LIFE_VALUE_MASK 0x7FFF
47206 +
47207 +/*
47208 + * This structure gets filled in by the machine specific 'get_power_status'
47209 + * implementation.  Any fields which are not set default to a safe value.
47210 + */
47211 +struct apm_power_info {
47212 +       unsigned char   ac_line_status;
47213 +       unsigned char   battery_status;
47214 +       unsigned char   battery_flag;
47215 +       unsigned char   battery_life;
47216 +       int             time;
47217 +       int             units;
47218 +};
47219 +
47220 +/*
47221 + * This allows machines to provide their own "apm get power status" function.
47222 + */
47223 +extern void (*apm_get_power_status)(struct apm_power_info *);
47224 +#endif
47225 +
47226 +
47227 +#endif
47228 diff -Nru a/include/asm-arm/arch-ebsa285/time.h b/include/asm-arm/arch-ebsa285/time.h
47229 --- a/include/asm-arm/arch-ebsa285/time.h       Tue May 13 08:20:50 2003
47230 +++ b/include/asm-arm/arch-ebsa285/time.h       Sun Aug 24 07:55:20 2003
47231 @@ -181,12 +181,13 @@
47232  }
47233  
47234  
47235 +static unsigned long timer1_latch;
47236  
47237  static unsigned long timer1_gettimeoffset (void)
47238  {
47239 -       unsigned long value = LATCH - *CSR_TIMER1_VALUE;
47240 +       unsigned long value = timer1_latch - *CSR_TIMER1_VALUE;
47241  
47242 -       return ((tick_nsec / 1000) * value) / LATCH;
47243 +       return ((tick_nsec / 1000) * value) / timer1_latch;
47244  }
47245  
47246  static irqreturn_t
47247 @@ -260,8 +261,10 @@
47248             machine_is_personal_server()) {
47249                 gettimeoffset = timer1_gettimeoffset;
47250  
47251 +               timer1_latch = (mem_fclk_21285 + 8 * HZ) / (16 * HZ);
47252 +
47253                 *CSR_TIMER1_CLR  = 0;
47254 -               *CSR_TIMER1_LOAD = LATCH;
47255 +               *CSR_TIMER1_LOAD = timer1_latch;
47256                 *CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV16;
47257  
47258                 timer_irq.handler = timer1_interrupt;
47259 diff -Nru a/include/asm-arm/arch-ebsa285/timex.h b/include/asm-arm/arch-ebsa285/timex.h
47260 --- a/include/asm-arm/arch-ebsa285/timex.h      Tue Feb  5 09:39:51 2002
47261 +++ b/include/asm-arm/arch-ebsa285/timex.h      Sun Aug 24 07:55:20 2003
47262 @@ -11,8 +11,8 @@
47263   */
47264  
47265  /*
47266 - * On EBSA285 boards, the clock runs at 50MHz and is
47267 - * divided by a 4-bit prescaler.  Other boards use an
47268 - * ISA derived timer, and this is unused.
47269 + * We assume a constant here; this satisfies the maths in linux/timex.h
47270 + * and linux/time.h.  CLOCK_TICK_RATE is actually system dependent, but
47271 + * this must be a constant.
47272   */
47273 -#define CLOCK_TICK_RATE                (mem_fclk_21285 / 16)
47274 +#define CLOCK_TICK_RATE                (50000000/16)
47275 diff -Nru a/include/asm-arm/arch-iop3xx/iop310.h b/include/asm-arm/arch-iop3xx/iop310.h
47276 --- a/include/asm-arm/arch-iop3xx/iop310.h      Mon Apr 21 15:43:42 2003
47277 +++ b/include/asm-arm/arch-iop3xx/iop310.h      Wed Aug 13 16:46:20 2003
47278 @@ -12,6 +12,14 @@
47279  #define _IOP310_HW_H_
47280  
47281  /*
47282 + * This is needed for mixed drivers that need to work on all
47283 + * IOP3xx variants but behave slightly differently on each.
47284 + */
47285 +#ifndef __ASSEMBLY__
47286 +#define iop_is_310() ((processor_id & 0xffffe3f0) == 0x69052000)
47287 +#endif
47288 +
47289 +/*
47290   * IOP310 I/O and Mem space regions for PCI autoconfiguration
47291   */
47292  #define IOP310_PCISEC_LOWER_IO         0x90010000
47293 diff -Nru a/include/asm-arm/arch-iop3xx/iop321.h b/include/asm-arm/arch-iop3xx/iop321.h
47294 --- a/include/asm-arm/arch-iop3xx/iop321.h      Fri May 30 07:09:39 2003
47295 +++ b/include/asm-arm/arch-iop3xx/iop321.h      Wed Aug 13 16:46:20 2003
47296 @@ -15,6 +15,10 @@
47297  #define _IOP321_HW_H_
47298  
47299  
47300 +/*
47301 + * This is needed for mixed drivers that need to work on all
47302 + * IOP3xx variants but behave slightly differently on each.
47303 + */
47304  #ifndef __ASSEMBLY__
47305  #define iop_is_321() ((processor_id & 0xfffff7e0) == 0x69052420)
47306  #endif
47307 diff -Nru a/include/asm-arm/arch-iop3xx/memory.h b/include/asm-arm/arch-iop3xx/memory.h
47308 --- a/include/asm-arm/arch-iop3xx/memory.h      Tue Apr 15 08:12:47 2003
47309 +++ b/include/asm-arm/arch-iop3xx/memory.h      Wed Aug 13 16:46:20 2003
47310 @@ -66,4 +66,6 @@
47311  extern void *mu_mem;
47312  #endif
47313  
47314 +#define PFN_TO_NID(addr)       (0)
47315 +
47316  #endif
47317 diff -Nru a/include/asm-arm/arch-pxa/pxa-regs.h b/include/asm-arm/arch-pxa/pxa-regs.h
47318 --- a/include/asm-arm/arch-pxa/pxa-regs.h       Mon Apr 21 15:43:42 2003
47319 +++ b/include/asm-arm/arch-pxa/pxa-regs.h       Mon Jun 30 04:20:34 2003
47320 @@ -836,7 +836,7 @@
47321  
47322  #define GPIO1_RST              1       /* reset */
47323  #define GPIO6_MMCCLK           6       /* MMC Clock */
47324 -#define GPIO8_48MHz            7       /* 48 MHz clock output */
47325 +#define GPIO7_48MHz            7       /* 48 MHz clock output */
47326  #define GPIO8_MMCCS0           8       /* MMC Chip Select 0 */
47327  #define GPIO9_MMCCS1           9       /* MMC Chip Select 1 */
47328  #define GPIO10_RTCCLK          10      /* real time clock (1 Hz) */
47329 @@ -939,7 +939,7 @@
47330  
47331  #define GPIO1_RTS_MD           ( 1 | GPIO_ALT_FN_1_IN)
47332  #define GPIO6_MMCCLK_MD                ( 6 | GPIO_ALT_FN_1_OUT)
47333 -#define GPIO8_48MHz_MD         ( 8 | GPIO_ALT_FN_1_OUT)
47334 +#define GPIO7_48MHz_MD         ( 7 | GPIO_ALT_FN_1_OUT)
47335  #define GPIO8_MMCCS0_MD                ( 8 | GPIO_ALT_FN_1_OUT)
47336  #define GPIO9_MMCCS1_MD                ( 9 | GPIO_ALT_FN_1_OUT)
47337  #define GPIO10_RTCCLK_MD       (10 | GPIO_ALT_FN_1_OUT)
47338 diff -Nru a/include/asm-arm/arch-sa1100/simpad.h b/include/asm-arm/arch-sa1100/simpad.h
47339 --- a/include/asm-arm/arch-sa1100/simpad.h      Mon Feb 24 10:29:41 2003
47340 +++ b/include/asm-arm/arch-sa1100/simpad.h      Thu Aug  7 11:49:10 2003
47341 @@ -5,17 +5,13 @@
47342   *
47343   * This file contains the hardware specific definitions for SIMpad
47344   *
47345 - * 2001/05/14 Juergen Messerer <juergen.messerer@siemens.ch>
47346 + * 2001/05/14 Juergen Messerer <juergen.messerer@freesurf.ch>
47347   */
47348  
47349 -#ifndef SIMPAD_H
47350 -#define SIMPAD_H
47351 +#ifndef __ASM_ARCH_SIMPAD_H
47352 +#define __ASM_ARCH_SIMPAD_H
47353  
47354  
47355 -#ifndef __ASM_ARCH_HARDWARE_H
47356 -#error "include <asm/hardware.h> instead"
47357 -#endif
47358 -
47359  #define GPIO_UART1_RTS GPIO_GPIO14
47360  #define GPIO_UART1_DTR GPIO_GPIO7
47361  #define GPIO_UART1_CTS GPIO_GPIO8
47362 @@ -28,7 +24,8 @@
47363  #define GPIO_UART3_DCD GPIO_GPIO18
47364  #define GPIO_UART3_DSR GPIO_GPIO17
47365  
47366 -#define GPIO_UCB1300_IRQ       GPIO_GPIO (22)  /* UCB GPIO and touchscreen */
47367 +#define GPIO_POWER_BUTTON      GPIO_GPIO0
47368 +#define GPIO_UCB1300_IRQ       GPIO_GPIO22     /* UCB GPIO and touchscreen */
47369  
47370  #define IRQ_UART1_CTS  IRQ_GPIO15
47371  #define IRQ_UART1_DCD  GPIO_GPIO23
47372 @@ -37,21 +34,26 @@
47373  #define IRQ_UART3_DCD  GPIO_GPIO18
47374  #define IRQ_UART3_DSR  GPIO_GPIO17
47375  
47376 -#define IRQ_GPIO_UCB1300_IRQ IRQ_GPIO22 
47377 +#define IRQ_GPIO_UCB1300_IRQ IRQ_GPIO22
47378 +#define IRQ_GPIO_POWER_BUTTON IRQ_GPIO0
47379  
47380  
47381  /*---  PCMCIA  ---*/
47382  #define GPIO_CF_CD              GPIO_GPIO24
47383 -#define GPIO_CF_IRQ             GPIO_GPIO1          
47384 +#define GPIO_CF_IRQ             GPIO_GPIO1
47385  #define IRQ_GPIO_CF_IRQ         IRQ_GPIO1
47386 -#define IRQ_GPIO_CF_CD          IRQ_GPIO24      
47387 +#define IRQ_GPIO_CF_CD          IRQ_GPIO24
47388 +
47389 +/*--- SmartCard ---*/
47390 +#define GPIO_SMART_CARD                GPIO_GPIO10
47391 +#define IRQ_GPIO_SMARD_CARD    IRQ_GPIO10
47392  
47393 -// CS3 Latch is write only, a shadow is necessary 
47394 +// CS3 Latch is write only, a shadow is necessary
47395  
47396 -#define CS3BUSTYPE unsigned volatile long           
47397 +#define CS3BUSTYPE unsigned volatile long
47398  #define CS3_BASE        0xf1000000
47399  
47400 -#define VCC_5V_EN       0x0001 // For 5V PCMCIA 
47401 +#define VCC_5V_EN       0x0001 // For 5V PCMCIA
47402  #define VCC_3V_EN       0x0002 // FOR 3.3V PCMCIA
47403  #define EN1             0x0004 // This is only for EPROM's
47404  #define EN0             0x0008 // Both should be enable for 3.3V or 5V
47405 @@ -63,15 +65,43 @@
47406  #define IRDA_SD         0x0200 // Shutdown for powersave
47407  #define RS232_ON        0x0400
47408  #define SD_MEDIAQ       0x0800 // Shutdown for powersave
47409 -#define LED2_ON         0x1000 
47410 +#define LED2_ON         0x1000
47411  #define IRDA_MODE       0x2000 // Fast/Slow IrDA mode
47412  #define ENABLE_5V       0x4000 // Enable 5V circuit
47413  #define RESET_SIMCARD   0x8000
47414  
47415  #define RS232_ENABLE    0x0440
47416 -#define PCMCIAMASK      0x402f   
47417 +#define PCMCIAMASK      0x402f
47418 +
47419 +
47420 +struct simpad_battery {
47421 +       unsigned char ac_status;        /* line connected yes/no */
47422 +       unsigned char status;           /* battery loading yes/no */
47423 +       unsigned char percentage;       /* percentage loaded */
47424 +       unsigned short life;            /* life till empty */
47425 +};
47426 +
47427 +/* These should match the apm_bios.h definitions */
47428 +#define SIMPAD_AC_STATUS_AC_OFFLINE      0x00
47429 +#define SIMPAD_AC_STATUS_AC_ONLINE       0x01
47430 +#define SIMPAD_AC_STATUS_AC_BACKUP       0x02   /* What does this mean? */
47431 +#define SIMPAD_AC_STATUS_AC_UNKNOWN      0xff
47432 +
47433 +/* These bitfields are rarely "or'd" together */
47434 +#define SIMPAD_BATT_STATUS_HIGH          0x01
47435 +#define SIMPAD_BATT_STATUS_LOW           0x02
47436 +#define SIMPAD_BATT_STATUS_CRITICAL      0x04
47437 +#define SIMPAD_BATT_STATUS_CHARGING      0x08
47438 +#define SIMPAD_BATT_STATUS_CHARGE_MAIN   0x10
47439 +#define SIMPAD_BATT_STATUS_DEAD          0x20   /* Battery will not charge */
47440 +#define SIMPAD_BATT_NOT_INSTALLED        0x20   /* For expansion pack batteries */
47441 +#define SIMPAD_BATT_STATUS_FULL          0x40   /* Battery fully charged (and connected to AC) */
47442 +#define SIMPAD_BATT_STATUS_NOBATT        0x80
47443 +#define SIMPAD_BATT_STATUS_UNKNOWN       0xff
47444 +
47445 +extern int simpad_get_battery(struct simpad_battery* );
47446  
47447 -#endif // SIMPAD_H
47448 +#endif // __ASM_ARCH_SIMPAD_H
47449  
47450  
47451  
47452 diff -Nru a/include/asm-arm/checksum.h b/include/asm-arm/checksum.h
47453 --- a/include/asm-arm/checksum.h        Tue Oct 15 10:15:06 2002
47454 +++ b/include/asm-arm/checksum.h        Mon Jun 23 03:41:42 2003
47455 @@ -105,7 +105,7 @@
47456         adcs    %0, %0, %5                                      \n\
47457         adc     %0, %0, #0"
47458         : "=&r"(sum)
47459 -       : "r" (sum), "r" (daddr), "r" (saddr), "r" (ntohs(len) << 16), "Ir" (proto << 8)
47460 +       : "r" (sum), "r" (daddr), "r" (saddr), "r" (ntohs(len)), "Ir" (ntohs(proto))
47461         : "cc");
47462         return sum;
47463  }      
47464 @@ -127,7 +127,7 @@
47465         addcs   %0, %0, #0x10000                                \n\
47466         mvn     %0, %0"
47467         : "=&r"(sum)
47468 -       : "r" (sum), "r" (daddr), "r" (saddr), "r" (ntohs(len)), "Ir" (proto << 8)
47469 +       : "r" (sum), "r" (daddr), "r" (saddr), "r" (ntohs(len)), "Ir" (ntohs(proto))
47470         : "cc");
47471         return sum >> 16;
47472  }
47473 diff -Nru a/include/asm-arm/dma-mapping.h b/include/asm-arm/dma-mapping.h
47474 --- a/include/asm-arm/dma-mapping.h     Wed Jun  4 08:09:55 2003
47475 +++ b/include/asm-arm/dma-mapping.h     Wed Aug 13 16:46:20 2003
47476 @@ -129,6 +129,28 @@
47477  }
47478  
47479  /**
47480 + * dma_map_page - map a portion of a page for streaming DMA
47481 + * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
47482 + * @page: page that buffer resides in
47483 + * @offset: offset into page for start of buffer
47484 + * @size: size of buffer to map
47485 + * @dir: DMA transfer direction
47486 + *
47487 + * Ensure that any data held in the cache is appropriately discarded
47488 + * or written back.
47489 + *
47490 + * The device owns this memory once this call has completed.  The CPU
47491 + * can regain ownership by calling dma_unmap_page() or dma_sync_single().
47492 + */
47493 +static inline dma_addr_t
47494 +dma_map_page(struct device *dev, struct page *page,
47495 +            unsigned long offset, size_t size,
47496 +            enum dma_data_direction dir)
47497 +{
47498 +       return dma_map_single(dev, page_address(page) + offset, size, (int)dir);
47499 +}
47500 +
47501 +/**
47502   * dma_unmap_single - unmap a single buffer previously mapped
47503   * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
47504   * @handle: DMA address of buffer
47505 @@ -152,21 +174,26 @@
47506         /* nothing to do */
47507  }
47508  
47509 -#if 0
47510 -static inline dma_addr_t
47511 -dma_map_page(struct device *dev, struct page *page, unsigned long off,
47512 -            size_t size, enum dma_data_direction dir)
47513 -{
47514 -       /* fixme */
47515 -}
47516 -
47517 +/**
47518 + * dma_unmap_page - unmap a buffer previously mapped through dma_map_page()
47519 + * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
47520 + * @handle: DMA address of buffer
47521 + * @size: size of buffer to map
47522 + * @dir: DMA transfer direction
47523 + *
47524 + * Unmap a single streaming mode DMA translation.  The handle and size
47525 + * must match what was provided in the previous dma_map_single() call.
47526 + * All other usages are undefined.
47527 + *
47528 + * After this call, reads by the CPU to the buffer are guaranteed to see
47529 + * whatever the device wrote there.
47530 + */
47531  static inline void
47532  dma_unmap_page(struct device *dev, dma_addr_t handle, size_t size,
47533                enum dma_data_direction dir)
47534  {
47535 -       /* fixme */
47536 +       dma_unmap_single(dev, handle, size, (int)dir);
47537  }
47538 -#endif
47539  
47540  /**
47541   * dma_map_sg - map a set of SG buffers for streaming mode DMA
47542 diff -Nru a/include/asm-arm/hardware/amba.h b/include/asm-arm/hardware/amba.h
47543 --- a/include/asm-arm/hardware/amba.h   Wed Jun 18 15:23:24 2003
47544 +++ b/include/asm-arm/hardware/amba.h   Sun Aug 24 07:16:13 2003
47545 @@ -28,8 +28,8 @@
47546         int                     (*probe)(struct amba_device *, void *);
47547         int                     (*remove)(struct amba_device *);
47548         void                    (*shutdown)(struct amba_device *);
47549 -       int                     (*suspend)(struct amba_device *, u32, u32);
47550 -       int                     (*resume)(struct amba_device *, u32);
47551 +       int                     (*suspend)(struct amba_device *, u32);
47552 +       int                     (*resume)(struct amba_device *);
47553         struct amba_id          *id_table;
47554  };
47555  
47556 diff -Nru a/include/asm-arm/hardware/sa1111.h b/include/asm-arm/hardware/sa1111.h
47557 --- a/include/asm-arm/hardware/sa1111.h Tue Aug  5 12:36:08 2003
47558 +++ b/include/asm-arm/hardware/sa1111.h Sun Aug 24 07:45:05 2003
47559 @@ -542,9 +542,16 @@
47560  
47561  #define SA1111_DEV(_d) container_of((_d), struct sa1111_dev, dev)
47562  
47563 +#define sa1111_get_drvdata(d)  dev_get_drvdata(&(d)->dev)
47564 +#define sa1111_set_drvdata(d,p)        dev_get_drvdata(&(d)->dev, p)
47565 +
47566  struct sa1111_driver {
47567         struct device_driver    drv;
47568         unsigned int            devid;
47569 +       int (*probe)(struct sa1111_dev *);
47570 +       int (*remove)(struct sa1111_dev *);
47571 +       int (*suspend)(struct sa1111_dev *, u32);
47572 +       int (*resume)(struct sa1111_dev *);
47573  };
47574  
47575  #define SA1111_DRV(_d) container_of((_d), struct sa1111_driver, drv)
47576 @@ -572,5 +579,8 @@
47577  int sa1111_get_audio_rate(struct sa1111_dev *sadev);
47578  
47579  int sa1111_check_dma_bug(dma_addr_t addr);
47580 +
47581 +int sa1111_driver_register(struct sa1111_driver *);
47582 +void sa1111_driver_unregister(struct sa1111_driver *);
47583  
47584  #endif  /* _ASM_ARCH_SA1111 */
47585 diff -Nru a/include/asm-arm/pci.h b/include/asm-arm/pci.h
47586 --- a/include/asm-arm/pci.h     Mon Jun  9 09:25:33 2003
47587 +++ b/include/asm-arm/pci.h     Wed Aug 13 16:46:20 2003
47588 @@ -96,6 +96,19 @@
47589         return dma_unmap_sg(hwdev ? &hwdev->dev : NULL, sg, nents, dir);
47590  }
47591  
47592 +static inline dma_addr_t
47593 +pci_map_page(struct pci_dev *hwdev, struct page *page, unsigned long offset,
47594 +               size_t size, int dir)
47595 +{
47596 +       return  pci_map_single(hwdev, page_address(page) + offset, size, dir);
47597 +}
47598 +
47599 +static inline void
47600 +pci_unmap_page(struct pci_dev *hwdev, dma_addr_t handle, size_t size, int dir)
47601 +{
47602 +       return pci_unmap_single(hwdev, handle, size, dir);
47603 +}
47604 +
47605  static inline void
47606  pci_dma_sync_single(struct pci_dev *hwdev, dma_addr_t handle, size_t size, int dir)
47607  {
47608 diff -Nru a/include/asm-arm/proc-armo/processor.h b/include/asm-arm/proc-armo/processor.h
47609 --- a/include/asm-arm/proc-armo/processor.h     Wed May 29 08:06:36 2002
47610 +++ b/include/asm-arm/proc-armo/processor.h     Sun Aug 31 16:14:08 2003
47611 @@ -43,7 +43,7 @@
47612         uaccess_t       *uaccess;               /* User access functions*/
47613  
47614  #define EXTRA_THREAD_STRUCT_INIT               \
47615 -       uaccess:        &uaccess_kernel,
47616 +       .uaccess        = &uaccess_kernel,
47617  
47618  #define start_thread(regs,pc,sp)                                       \
47619  ({                                                                     \
47620 diff -Nru a/include/asm-arm/unistd.h b/include/asm-arm/unistd.h
47621 --- a/include/asm-arm/unistd.h  Tue Jan 14 15:28:43 2003
47622 +++ b/include/asm-arm/unistd.h  Tue Jul  8 09:40:32 2003
47623 @@ -303,7 +303,7 @@
47624         "swi    0\n\t"                                  \
47625         "pop    {r7}"
47626  #else
47627 -#define __syscall(name) "swi\t" __sys1(__NR_##name) "\n\t"
47628 +#define __syscall(name) "swi\t" __sys1(__NR_##name) ""
47629  #endif
47630  #endif
47631  
47632 @@ -318,24 +318,28 @@
47633  
47634  #define _syscall0(type,name)                                           \
47635  type name(void) {                                                      \
47636 -  register long __res __asm__("r0");                                   \
47637 +  register long __res_r0 __asm__("r0");                                        \
47638 +  long __res;                                                          \
47639    __asm__ __volatile__ (                                               \
47640    __syscall(name)                                                      \
47641 -       :"=r" (__res)                                                   \
47642 +       : "=r" (__res_r0)                                               \
47643         :                                                               \
47644         : "lr");                                                        \
47645 +  __res = __res_r0;                                                    \
47646    __syscall_return(type,__res);                                                \
47647  }
47648  
47649  #define _syscall1(type,name,type1,arg1)                                \
47650  type name(type1 arg1) {                                                \
47651    register long __r0 __asm__("r0") = (long)arg1;                       \
47652 -  register long __res __asm__("r0");                                   \
47653 +  register long __res_r0 __asm__("r0");                                        \
47654 +  long __res;                                                          \
47655    __asm__ __volatile__ (                                               \
47656    __syscall(name)                                                      \
47657 -       : "=r" (__res)                                                  \
47658 +       : "=r" (__res_r0)                                               \
47659         : "r" (__r0)                                                    \
47660         : "lr");                                                        \
47661 +  __res = __res_r0;                                                    \
47662    __syscall_return(type,__res);                                                \
47663  }
47664  
47665 @@ -343,12 +347,14 @@
47666  type name(type1 arg1,type2 arg2) {                                     \
47667    register long __r0 __asm__("r0") = (long)arg1;                       \
47668    register long __r1 __asm__("r1") = (long)arg2;                       \
47669 -  register long __res __asm__("r0");                                   \
47670 +  register long __res_r0 __asm__("r0");                                        \
47671 +  long __res;                                                          \
47672    __asm__ __volatile__ (                                               \
47673    __syscall(name)                                                      \
47674 -       : "=r" (__res)                                                  \
47675 +       : "=r" (__res_r0)                                               \
47676         : "r" (__r0),"r" (__r1)                                         \
47677         : "lr");                                                        \
47678 +  __res = __res_r0;                                                    \
47679    __syscall_return(type,__res);                                                \
47680  }
47681  
47682 @@ -358,12 +364,14 @@
47683    register long __r0 __asm__("r0") = (long)arg1;                       \
47684    register long __r1 __asm__("r1") = (long)arg2;                       \
47685    register long __r2 __asm__("r2") = (long)arg3;                       \
47686 -  register long __res __asm__("r0");                                   \
47687 +  register long __res_r0 __asm__("r0");                                        \
47688 +  long __res;                                                          \
47689    __asm__ __volatile__ (                                               \
47690    __syscall(name)                                                      \
47691 -       : "=r" (__res)                                                  \
47692 +       : "=r" (__res_r0)                                               \
47693         : "r" (__r0),"r" (__r1),"r" (__r2)                              \
47694         : "lr");                                                        \
47695 +  __res = __res_r0;                                                    \
47696    __syscall_return(type,__res);                                                \
47697  }
47698  
47699 @@ -374,12 +382,14 @@
47700    register long __r1 __asm__("r1") = (long)arg2;                       \
47701    register long __r2 __asm__("r2") = (long)arg3;                       \
47702    register long __r3 __asm__("r3") = (long)arg4;                       \
47703 -  register long __res __asm__("r0");                                   \
47704 +  register long __res_r0 __asm__("r0");                                        \
47705 +  long __res;                                                          \
47706    __asm__ __volatile__ (                                               \
47707    __syscall(name)                                                      \
47708 -       : "=r" (__res)                                                  \
47709 +       : "=r" (__res_r0)                                               \
47710         : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3)                   \
47711         : "lr");                                                        \
47712 +  __res = __res_r0;                                                    \
47713    __syscall_return(type,__res);                                                \
47714  }
47715    
47716 @@ -391,12 +401,14 @@
47717    register long __r2 __asm__("r2") = (long)arg3;                       \
47718    register long __r3 __asm__("r3") = (long)arg4;                       \
47719    register long __r4 __asm__("r4") = (long)arg5;                       \
47720 -  register long __res __asm__("r0");                                   \
47721 +  register long __res_r0 __asm__("r0");                                        \
47722 +  long __res;                                                          \
47723    __asm__ __volatile__ (                                               \
47724    __syscall(name)                                                      \
47725 -       : "=r" (__res)                                                  \
47726 +       : "=r" (__res_r0)                                               \
47727         : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3),"r" (__r4)        \
47728         : "lr");                                                        \
47729 +  __res = __res_r0;                                                    \
47730    __syscall_return(type,__res);                                                \
47731  }
47732  
47733 @@ -408,12 +420,14 @@
47734    register long __r3 __asm__("r3") = (long)arg4;                       \
47735    register long __r4 __asm__("r4") = (long)arg5;                       \
47736    register long __r5 __asm__("r5") = (long)arg6;                       \
47737 -  register long __res __asm__("r0");                                   \
47738 +  register long __res_r0 __asm__("r0");                                        \
47739 +  long __res;                                                          \
47740    __asm__ __volatile__ (                                               \
47741    __syscall(name)                                                      \
47742 -       : "=r" (__res)                                                  \
47743 +       : "=r" (__res_r0)                                               \
47744         : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3), "r" (__r4),"r" (__r5)            \
47745         : "lr");                                                        \
47746 +  __res = __res_r0;                                                    \
47747    __syscall_return(type,__res);                                                \
47748  }
47749  
47750 diff -Nru a/include/asm-arm/xor.h b/include/asm-arm/xor.h
47751 --- a/include/asm-arm/xor.h     Mon Feb  4 23:41:12 2002
47752 +++ b/include/asm-arm/xor.h     Sun Aug 31 16:14:08 2003
47753 @@ -125,11 +125,11 @@
47754  }
47755  
47756  static struct xor_block_template xor_block_arm4regs = {
47757 -       name:   "arm4regs",
47758 -       do_2:   xor_arm4regs_2,
47759 -       do_3:   xor_arm4regs_3,
47760 -       do_4:   xor_arm4regs_4,
47761 -       do_5:   xor_arm4regs_5,
47762 +       .name   = "arm4regs",
47763 +       .do_2   = xor_arm4regs_2,
47764 +       .do_3   = xor_arm4regs_3,
47765 +       .do_4   = xor_arm4regs_4,
47766 +       .do_5   = xor_arm4regs_5,
47767  };
47768  
47769  #undef XOR_TRY_TEMPLATES
47770 diff -Nru a/include/asm-arm26/processor.h b/include/asm-arm26/processor.h
47771 --- a/include/asm-arm26/processor.h     Thu Jun 26 03:24:47 2003
47772 +++ b/include/asm-arm26/processor.h     Sun Aug 31 16:14:08 2003
47773 @@ -51,7 +51,7 @@
47774          uaccess_t       *uaccess;         /* User access functions*/
47775  
47776  #define EXTRA_THREAD_STRUCT_INIT                \
47777 -        uaccess:        &uaccess_kernel,
47778 +        .uaccess        = &uaccess_kernel,
47779  
47780  // FIXME?!!
47781  
47782 diff -Nru a/include/asm-arm26/xor.h b/include/asm-arm26/xor.h
47783 --- a/include/asm-arm26/xor.h   Wed Jun  4 04:14:11 2003
47784 +++ b/include/asm-arm26/xor.h   Sun Aug 31 16:14:08 2003
47785 @@ -125,11 +125,11 @@
47786  }
47787  
47788  static struct xor_block_template xor_block_arm4regs = {
47789 -       name:   "arm4regs",
47790 -       do_2:   xor_arm4regs_2,
47791 -       do_3:   xor_arm4regs_3,
47792 -       do_4:   xor_arm4regs_4,
47793 -       do_5:   xor_arm4regs_5,
47794 +       .name   = "arm4regs",
47795 +       .do_2   = xor_arm4regs_2,
47796 +       .do_3   = xor_arm4regs_3,
47797 +       .do_4   = xor_arm4regs_4,
47798 +       .do_5   = xor_arm4regs_5,
47799  };
47800  
47801  #undef XOR_TRY_TEMPLATES
47802 diff -Nru a/include/asm-h8300/aki3068net/ne.h b/include/asm-h8300/aki3068net/ne.h
47803 --- a/include/asm-h8300/aki3068net/ne.h Sat Jul 19 05:41:33 2003
47804 +++ /dev/null   Wed Dec 31 16:00:00 1969
47805 @@ -1,28 +0,0 @@
47806 -/* AE-3068 (aka. aki3068net) RTL8019AS Config */
47807 -
47808 -#ifndef __H8300_AKI3068NET_NE__
47809 -#define __H8300_AKI3068NET_NE__
47810 -
47811 -#define NE2000_ADDR            0x200000
47812 -#define NE2000_IRQ              5
47813 -#define NE2000_IRQ_VECTOR      (12 + NE2000_IRQ)
47814 -#define        NE2000_BYTE             volatile unsigned short
47815 -
47816 -#define IER                     0xfee015
47817 -#define ISR                    0xfee016
47818 -#define IRQ_MASK               (1 << NE2000_IRQ)
47819 -
47820 -#define WCRL                    0xfee023
47821 -#define MAR0A                   0xffff20
47822 -#define ETCR0A                  0xffff24
47823 -#define DTCR0A                  0xffff27
47824 -#define MAR0B                   0xffff28
47825 -#define DTCR0B                  0xffff2f
47826 -
47827 -#define H8300_INIT_NE()                  \
47828 -do {                                     \
47829 -       wordlength = 1;                  \
47830 -        outb_p(0x48, ioaddr + EN0_DCFG); \
47831 -} while(0)
47832 -
47833 -#endif
47834 diff -Nru a/include/asm-h8300/aki3068net/timer_rate.h b/include/asm-h8300/aki3068net/timer_rate.h
47835 --- a/include/asm-h8300/aki3068net/timer_rate.h Sat Jul 19 09:19:25 2003
47836 +++ /dev/null   Wed Dec 31 16:00:00 1969
47837 @@ -1,9 +0,0 @@
47838 -#ifndef __H8300_AKI3068NET_TIMER_RATE__
47839 -#define __H8300_AKI3068NET_TIMER_RATE__
47840 -
47841 -#include <linux/config.h>
47842 -
47843 -#define H8300_TIMER_COUNT_DATA CONFIG_CPU_CLOCK*10/8192
47844 -#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192
47845 -
47846 -#endif
47847 diff -Nru a/include/asm-h8300/edosk2674/timer_rate.h b/include/asm-h8300/edosk2674/timer_rate.h
47848 --- a/include/asm-h8300/edosk2674/timer_rate.h  Sat Jul 19 09:18:09 2003
47849 +++ /dev/null   Wed Dec 31 16:00:00 1969
47850 @@ -1,4 +0,0 @@
47851 -#include <linux/config.h>
47852 -
47853 -#define H8300_TIMER_COUNT_DATA CONFIG_CPU_CLOCK*10/8192
47854 -#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192
47855 diff -Nru a/include/asm-h8300/h8300_smsc.h b/include/asm-h8300/h8300_smsc.h
47856 --- /dev/null   Wed Dec 31 16:00:00 1969
47857 +++ b/include/asm-h8300/h8300_smsc.h    Sun Aug 31 14:01:50 2003
47858 @@ -0,0 +1,20 @@
47859 +/****************************************************************************/
47860 +
47861 +/*
47862 + *     h8300_smsc.h -- SMSC in H8/300H and H8S Evalution Board.
47863 + *      
47864 + *     (C) Copyright 2003, Yoshinori Sato <ysato@users.sourceforge.jp>
47865 + */
47866 +
47867 +/****************************************************************************/
47868 +#ifndef        h8300smsc_h
47869 +#define        h8300smsc_h
47870 +/****************************************************************************/
47871 +
47872 +/* Such a description is OK ? */
47873 +#define H8300_SMSC_DEFINE
47874 +#include <asm/machine-depend.h>
47875 +#undef  H8300_SMSC_DEFINE
47876 +
47877 +/****************************************************************************/
47878 +#endif /* h8300smsc_h */
47879 diff -Nru a/include/asm-h8300/h8max/machine-depend.h b/include/asm-h8300/h8max/machine-depend.h
47880 --- a/include/asm-h8300/h8max/machine-depend.h  Thu Aug 21 22:56:17 2003
47881 +++ b/include/asm-h8300/h8max/machine-depend.h  Wed Aug 27 07:02:04 2003
47882 @@ -101,67 +101,3 @@
47883  }
47884  
47885  #endif
47886 -
47887 -/* H8MAX IDE I/F Config */
47888 -#ifdef H8300_IDE_DEFINE
47889 -
47890 -#define H8300_IDE_BASE 0x200000
47891 -#define H8300_IDE_CTRL 0x60000c
47892 -#define H8300_IDE_IRQ  5
47893 -#define H8300_IDE_REG_OFFSET 2
47894 -
47895 -#undef outb
47896 -#undef inb
47897 -#undef outb_p
47898 -#undef inb_p
47899 -#undef outsw
47900 -#undef insw
47901 -
47902 -#define outb(d,a) h8max_outb(d,(unsigned short *)a)
47903 -#define inb(a) h8max_inb((unsigned char *)a)
47904 -#define outb_p(d,a) h8max_outb(d,(unsigned short *)a)
47905 -#define inb_p(a) h8max_inb((unsigned char *)a)
47906 -#define outsw(addr,buf,len) h8max_outsw(addr,buf,len);
47907 -#define insw(addr,buf,len) h8max_insw(addr,buf,len);
47908 -
47909 -static inline void h8max_outb(unsigned short d,unsigned short *a)
47910 -{
47911 -       *a = d;
47912 -}
47913 -
47914 -static inline unsigned char h8max_inb(unsigned char *a)
47915 -{
47916 -       return *(a+1);
47917 -}
47918 -
47919 -static inline void h8max_outsw(void *addr, void *buf, int len)
47920 -{
47921 -       unsigned volatile short *ap = (unsigned volatile short *)addr;
47922 -       unsigned short *bp = (unsigned short *)buf;
47923 -       unsigned short d;
47924 -       while(len--) {
47925 -               d = *bp++;
47926 -               *ap = (d >> 8) | (d << 8);
47927 -       }
47928 -}
47929 -
47930 -static inline void h8max_insw(void *addr, void *buf, int len)
47931 -{
47932 -       unsigned volatile short *ap = (unsigned volatile short *)addr;
47933 -       unsigned short *bp = (unsigned short *)buf;
47934 -       unsigned short d;
47935 -       while(len--) {
47936 -               d = *ap;
47937 -               *bp++ = (d >> 8) | (d << 8);
47938 -       }
47939 -}
47940 -
47941 -static inline void target_ide_fix_driveid(struct hd_driveid *id)
47942 -{
47943 -       int c;
47944 -       unsigned short *p = (unsigned short *)id;
47945 -       for (c = 0; c < SECTOR_WORDS; c++, p++)
47946 -               *p = (*p >> 8) | (*p << 8);
47947 -}
47948 -
47949 -#endif
47950 diff -Nru a/include/asm-h8300/h8max/ne.h b/include/asm-h8300/h8max/ne.h
47951 --- a/include/asm-h8300/h8max/ne.h      Sat Jul 19 05:41:33 2003
47952 +++ /dev/null   Wed Dec 31 16:00:00 1969
47953 @@ -1,97 +0,0 @@
47954 -/* H8MAX RTL8019AS Config */
47955 -
47956 -#ifndef __H8300_H8MAX_NE__
47957 -#define __H8300_H8MAX_NE__
47958 -
47959 -#define NE2000_ADDR            0x800600
47960 -#define NE2000_IRQ              4
47961 -#define NE2000_IRQ_VECTOR      (12 + NE2000_IRQ)
47962 -#define        NE2000_BYTE             volatile unsigned short
47963 -
47964 -#define IER                     0xfee015
47965 -#define ISR                    0xfee016
47966 -#define IRQ_MASK               (1 << NE2000_IRQ)
47967 -/* sorry quick hack */
47968 -#if defined(outb)
47969 -# undef outb
47970 -#endif
47971 -#define outb(d,a)               h8max_outb((d),(a) - NE2000_ADDR)
47972 -#if defined(inb)
47973 -# undef inb
47974 -#endif
47975 -#define inb(a)                  h8max_inb((a) - NE2000_ADDR)
47976 -#if defined(outb_p)
47977 -# undef outb_p
47978 -#endif
47979 -#define outb_p(d,a)             h8max_outb((d),(a) - NE2000_ADDR)
47980 -#if defined(inb_p)
47981 -# undef inb_p
47982 -#endif
47983 -#define inb_p(a)                h8max_inb((a) - NE2000_ADDR)
47984 -#if defined(outsw)
47985 -# undef outsw
47986 -#endif
47987 -#define outsw(a,p,l)            h8max_outsw((a) - NE2000_ADDR,(unsigned short *)p,l)
47988 -#if defined(insw)
47989 -# undef insw
47990 -#endif
47991 -#define insw(a,p,l)             h8max_insw((a) - NE2000_ADDR,(unsigned short *)p,l)
47992 -#if defined(outsb)
47993 -# undef outsb
47994 -#endif
47995 -#define outsb(a,p,l)            h8max_outsb((a) - NE2000_ADDR,(unsigned char *)p,l)
47996 -#if defined(insb)
47997 -# undef insb
47998 -#endif
47999 -#define insb(a,p,l)             h8max_insb((a) - NE2000_ADDR,(unsigned char *)p,l)
48000 -
48001 -#define H8300_INIT_NE()                  \
48002 -do {                                     \
48003 -       wordlength = 2;                  \
48004 -       h8max_outb(0x49, ioaddr + EN0_DCFG); \
48005 -       SA_prom[14] = SA_prom[15] = 0x57;\
48006 -} while(0)
48007 -
48008 -static inline void h8max_outb(unsigned char d,unsigned char a)
48009 -{
48010 -       *(unsigned short *)(NE2000_ADDR + (a << 1)) = d;
48011 -}
48012 -
48013 -static inline unsigned char h8max_inb(unsigned char a)
48014 -{
48015 -       return *(unsigned char *)(NE2000_ADDR + (a << 1) +1);
48016 -}
48017 -
48018 -static inline void h8max_outsw(unsigned char a,unsigned short *p,unsigned long l)
48019 -{
48020 -       unsigned short d;
48021 -       for (; l != 0; --l, p++) {
48022 -               d = (((*p) >> 8) & 0xff) | ((*p) << 8);
48023 -               *(unsigned short *)(NE2000_ADDR + (a << 1)) = d;
48024 -       }
48025 -}
48026 -
48027 -static inline void h8max_insw(unsigned char a,unsigned short *p,unsigned long l)
48028 -{
48029 -       unsigned short d;
48030 -       for (; l != 0; --l, p++) {
48031 -               d = *(unsigned short *)(NE2000_ADDR + (a << 1));
48032 -               *p = (d << 8)|((d >> 8) & 0xff);
48033 -       }
48034 -}
48035 -
48036 -static inline void h8max_outsb(unsigned char a,unsigned char *p,unsigned long l)
48037 -{
48038 -       for (; l != 0; --l, p++) {
48039 -               *(unsigned short *)(NE2000_ADDR + (a << 1)) = *p;
48040 -       }
48041 -}
48042 -
48043 -static inline void h8max_insb(unsigned char a,unsigned char *p,unsigned long l)
48044 -{
48045 -       for (; l != 0; --l, p++) {
48046 -               *p = *((unsigned char *)(NE2000_ADDR + (a << 1))+1);
48047 -       }
48048 -}
48049 -
48050 -#endif
48051 diff -Nru a/include/asm-h8300/h8max/timer_rate.h b/include/asm-h8300/h8max/timer_rate.h
48052 --- a/include/asm-h8300/h8max/timer_rate.h      Sat Jul 19 09:19:25 2003
48053 +++ /dev/null   Wed Dec 31 16:00:00 1969
48054 @@ -1,10 +0,0 @@
48055 -#ifndef __H8300_H8MAX_TIMER_RATE__
48056 -#define __H8300_H8MAX_TIMER_RATE__
48057 -
48058 -#include <linux/config.h>
48059 -
48060 -#define H8300_TIMER_COUNT_DATA CONFIG_CPU_CLOCK*10/8192
48061 -#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192
48062 -
48063 -#endif
48064 -
48065 diff -Nru a/include/asm-h8300/ide.h b/include/asm-h8300/ide.h
48066 --- a/include/asm-h8300/ide.h   Thu Aug 21 08:55:15 2003
48067 +++ b/include/asm-h8300/ide.h   Wed Aug 27 07:12:57 2003
48068 @@ -16,145 +16,26 @@
48069  #ifdef __KERNEL__
48070  /****************************************************************************/
48071  
48072 -#include <linux/config.h>
48073 -#include <linux/interrupt.h>
48074 +void h8300_ide_print_resource(char *name, hw_regs_t *hw);
48075 +static inline int ide_default_irq(unsigned long base) { return 0; };
48076 +static inline ide_ioreg_t ide_default_io_base(int index) { return 0; };
48077  
48078 -#include <asm/setup.h>
48079 -#include <asm/io.h>
48080 -#include <asm/irq.h>
48081 -
48082 -/*
48083 - *     Some coldfire specifics.
48084 - */
48085 -
48086 -/*
48087 - *     Save some space, only have 1 interface.
48088 - */
48089 -#define MAX_HWIFS      1
48090 -
48091 -/*
48092 - *     Fix up things that may not have been provided.
48093 - */
48094 -
48095 -#undef SUPPORT_SLOW_DATA_PORTS
48096 -#define SUPPORT_SLOW_DATA_PORTS 0
48097 -
48098 -#undef SUPPORT_VLB_SYNC
48099 -#define SUPPORT_VLB_SYNC 0
48100 -
48101 -/* this definition is used only on startup .. */
48102 -#undef HD_DATA
48103 -#define HD_DATA NULL
48104 -
48105 -#define        DBGIDE(fmt,a...)
48106 -// #define     DBGIDE(fmt,a...) printk(fmt, ##a)
48107 -#define IDE_INLINE __inline__
48108 -// #define IDE_INLINE
48109 -
48110 -#define ide__sti()     __sti()
48111 -
48112 -/****************************************************************************/
48113 -
48114 -typedef union {
48115 -       unsigned all                    : 8;    /* all of the bits together */
48116 -       struct {
48117 -               unsigned bit7           : 1;    /* always 1 */
48118 -               unsigned lba            : 1;    /* using LBA instead of CHS */
48119 -               unsigned bit5           : 1;    /* always 1 */
48120 -               unsigned unit           : 1;    /* drive select number, 0 or 1 */
48121 -               unsigned head           : 4;    /* always zeros here */
48122 -       } b;
48123 -} select_t;
48124 -
48125 -/*
48126 - *     Our list of ports/irq's for different boards.
48127 - */
48128 -
48129 -/* machine depend header include */
48130 -#define H8300_IDE_DEFINE
48131 -#include <asm/machine-depend.h>
48132 -#undef  H8300_IDE_DEFINE
48133 -
48134 -/****************************************************************************/
48135 -
48136 -static IDE_INLINE int ide_default_irq(ide_ioreg_t base)
48137 +static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
48138 +        unsigned long ctrl_port, int *irq)
48139  {
48140 -       return H8300_IDE_IRQ+12;
48141  }
48142  
48143 -static IDE_INLINE ide_ioreg_t ide_default_io_base(int index)
48144 -{
48145 -       return (ide_ioreg_t)H8300_IDE_BASE;
48146 -}
48147  
48148 -/*
48149 - * Set up a hw structure for a specified data port, control port and IRQ.
48150 - * This should follow whatever the default interface uses.
48151 - */
48152 -static IDE_INLINE void ide_init_hwif_ports(
48153 -       hw_regs_t *hw,
48154 -       ide_ioreg_t data_port,
48155 -       ide_ioreg_t ctrl_port,
48156 -       int *irq)
48157 +static inline void ide_init_default_hwifs(void)
48158  {
48159 -       ide_ioreg_t reg = data_port;
48160 -       int i;
48161 -
48162 -       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
48163 -               hw->io_ports[i] = reg;
48164 -               reg += H8300_IDE_REG_OFFSET;
48165 -       }
48166 -       if (ctrl_port) {
48167 -               hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
48168 -       } else {
48169 -               hw->io_ports[IDE_CONTROL_OFFSET] = (ide_ioreg_t)H8300_IDE_CTRL;
48170 -       }
48171  }
48172  
48173 +#define MAX_HWIFS      1
48174  
48175 -/*
48176 - * This registers the standard ports for this architecture with the IDE
48177 - * driver.
48178 - */
48179 -static IDE_INLINE void ide_init_default_hwifs(void)
48180 -{
48181 -       hw_regs_t hw;
48182 -       ide_ioreg_t base;
48183 -       int index;
48184 -
48185 -       for (index = 0; index < MAX_HWIFS; index++) {
48186 -               base = ide_default_io_base(index);
48187 -               if (!base)
48188 -                       continue;
48189 -               memset(&hw, 0, sizeof(hw));
48190 -               ide_init_hwif_ports(&hw, base, 0, NULL);
48191 -               hw.irq = ide_default_irq(base);
48192 -               ide_register_hw(&hw, NULL);
48193 -       }
48194 -}
48195 -
48196 -#define ide_request_irq(irq,hand,flg,dev,id)   request_irq((irq),(hand),(flg),(dev),(id))
48197 -#define ide_free_irq(irq,dev_id)               free_irq((irq), (dev_id))
48198 -#define ide_check_region(from,extent)          (0)
48199 -#define ide_request_region(from,extent,name)   do {} while(0)
48200 -#define ide_release_region(from,extent)                do {} while(0)
48201 -
48202 -/*
48203 - * The following are not needed for the non-m68k ports
48204 - */
48205 -#define ide_ack_intr(hwif)             (1)
48206 -#define ide_fix_driveid(id)            target_ide_fix_driveid(id)
48207 -#define ide_release_lock(lock)         do {} while (0)
48208 -#define ide_get_lock(lock, hdlr, data) do {} while (0)
48209 -
48210 -static IDE_INLINE void ide_print_resource(char *name,hw_regs_t *hw)
48211 -{
48212 -       printk("%s at 0x%08x-0x%08x,0x%08x on irq %d", name,
48213 -               (unsigned int)hw->io_ports[IDE_DATA_OFFSET],
48214 -               (unsigned int)hw->io_ports[IDE_DATA_OFFSET]+(8*H8300_IDE_REG_OFFSET)-1,
48215 -               (unsigned int)hw->io_ports[IDE_CONTROL_OFFSET],
48216 -               hw->irq);
48217 -}
48218 +#define __ide_mm_insw(port,addr,count)  do { } while(0)
48219 +#define __ide_mm_insl(port,addr,count)  do { } while(0)
48220 +#define __ide_mm_outsw(port,addr,count) do { } while(0)
48221 +#define __ide_mm_outsl(port,addr,count) do { } while(0)
48222  
48223  /****************************************************************************/
48224  #endif /* __KERNEL__ */
48225 diff -Nru a/include/asm-h8300/irq.h b/include/asm-h8300/irq.h
48226 --- a/include/asm-h8300/irq.h   Sun Jul 13 23:17:52 2003
48227 +++ b/include/asm-h8300/irq.h   Wed Aug 27 07:02:04 2003
48228 @@ -3,11 +3,35 @@
48229  
48230  #include <asm/ptrace.h>
48231  
48232 -#if defined(CONFIG_CPU_H8300H)
48233 +#if defined(__H8300H__)
48234  #define NR_IRQS 64
48235 +#define EXT_IRQ0 12
48236 +#define EXT_IRQ1 13
48237 +#define EXT_IRQ2 14
48238 +#define EXT_IRQ3 15
48239 +#define EXT_IRQ4 16
48240 +#define EXT_IRQ5 17
48241 +#define EXT_IRQ6 18
48242 +#define EXT_IRQ7 19
48243  #endif
48244  #if defined(CONFIG_CPU_H8S)
48245  #define NR_IRQS 128
48246 +#define EXT_IRQ0 16
48247 +#define EXT_IRQ1 17
48248 +#define EXT_IRQ2 18
48249 +#define EXT_IRQ3 19
48250 +#define EXT_IRQ4 20
48251 +#define EXT_IRQ5 21
48252 +#define EXT_IRQ6 22
48253 +#define EXT_IRQ7 23
48254 +#define EXT_IRQ8 24
48255 +#define EXT_IRQ9 25
48256 +#define EXT_IRQ10 26
48257 +#define EXT_IRQ11 27
48258 +#define EXT_IRQ12 28
48259 +#define EXT_IRQ13 29
48260 +#define EXT_IRQ14 30
48261 +#define EXT_IRQ15 31
48262  #endif
48263  
48264  static __inline__ int irq_canonicalize(int irq)
48265 diff -Nru a/include/asm-h8300/machine-depend.h b/include/asm-h8300/machine-depend.h
48266 --- a/include/asm-h8300/machine-depend.h        Thu Aug 21 22:56:18 2003
48267 +++ /dev/null   Wed Dec 31 16:00:00 1969
48268 @@ -1,70 +0,0 @@
48269 -/* EDOSK2674 board depend header */
48270 -
48271 -/* TIMER rate define */
48272 -#ifdef H8300_TIMER_DEFINE
48273 -#define H8300_TIMER_COUNT_DATA 33000*10/8192
48274 -#define H8300_TIMER_FREQ 33000*1000/8192
48275 -#endif
48276 -
48277 -/* EDOSK-2674R SMSC Network Controler Target Depend impliments */
48278 -#ifdef H8300_SMSC_DEFINE
48279 -
48280 -#define SMSC_BASE 0xf80000
48281 -#define SMSC_IRQ 16
48282 -
48283 -/* sorry quick hack */
48284 -#if defined(outw)
48285 -# undef outw
48286 -#endif
48287 -#define outw(d,a) edosk2674_smsc_outw(d,(volatile unsigned short *)(a))
48288 -#if defined(inw)
48289 -# undef inw
48290 -#endif
48291 -#define inw(a) edosk2674_smsc_inw((volatile unsigned short *)(a))
48292 -#if defined(outsw)
48293 -# undef outsw
48294 -#endif
48295 -#define outsw(a,p,l) edosk2674_smsc_outsw((volatile unsigned short *)(a),p,l)
48296 -#if defined(insw)
48297 -# undef insw
48298 -#endif
48299 -#define insw(a,p,l) edosk2674_smsc_insw((volatile unsigned short *)(a),p,l)
48300 -
48301 -static inline void edosk2674_smsc_outw(
48302 -       unsigned short d,
48303 -       volatile unsigned short *a
48304 -       )
48305 -{
48306 -       *a = (d >> 8) | (d << 8);
48307 -}
48308 -
48309 -static inline unsigned short edosk2674_smsc_inw(
48310 -       volatile unsigned short *a
48311 -       )
48312 -{
48313 -       unsigned short d;
48314 -       d = *a;
48315 -       return (d >> 8) | (d << 8);
48316 -}
48317 -
48318 -static inline void edosk2674_smsc_outsw(
48319 -       volatile unsigned short *a,
48320 -       unsigned short *p,
48321 -       unsigned long l
48322 -       )
48323 -{
48324 -       for (; l != 0; --l, p++)
48325 -               *a = *p;
48326 -}
48327 -
48328 -static inline void edosk2674_smsc_insw(
48329 -       volatile unsigned short *a,
48330 -       unsigned short *p,
48331 -       unsigned long l
48332 -       )
48333 -{
48334 -       for (; l != 0; --l, p++)
48335 -               *p = *a;
48336 -}
48337 -
48338 -#endif
48339 diff -Nru a/include/asm-h8300/pci.h b/include/asm-h8300/pci.h
48340 --- a/include/asm-h8300/pci.h   Mon Jun  9 09:25:52 2003
48341 +++ b/include/asm-h8300/pci.h   Wed Aug 27 07:02:04 2003
48342 @@ -19,4 +19,6 @@
48343         /* We don't do dynamic PCI IRQ allocation */
48344  }
48345  
48346 +#define PCI_DMA_BUS_IS_PHYS    (1)
48347 +
48348  #endif /* _ASM_H8300_PCI_H */
48349 diff -Nru a/include/asm-i386/apic.h b/include/asm-i386/apic.h
48350 --- a/include/asm-i386/apic.h   Sun Jun 15 11:00:08 2003
48351 +++ b/include/asm-i386/apic.h   Fri Aug 29 03:51:17 2003
48352 @@ -64,6 +64,8 @@
48353         apic_write_around(APIC_EOI, 0);
48354  }
48355  
48356 +extern void (*wait_timer_tick)(void);
48357 +
48358  extern int get_maxlvt(void);
48359  extern void clear_local_APIC(void);
48360  extern void connect_bsp_APIC (void);
48361 diff -Nru a/include/asm-i386/bugs.h b/include/asm-i386/bugs.h
48362 --- a/include/asm-i386/bugs.h   Sun Apr 20 12:24:22 2003
48363 +++ b/include/asm-i386/bugs.h   Sun Aug 31 16:14:48 2003
48364 @@ -193,11 +193,6 @@
48365             && (boot_cpu_data.x86_mask < 6 || boot_cpu_data.x86_mask == 11))
48366                 panic("Kernel compiled for PMMX+, assumes a local APIC without the read-before-write bug!");
48367  #endif
48368 -
48369 -#ifdef CONFIG_X86_SSE2
48370 -       if (!cpu_has_sse2)
48371 -               panic("Kernel compiled for SSE2, CPU doesn't have it.");
48372 -#endif
48373  }
48374  
48375  extern void alternative_instructions(void);
48376 diff -Nru a/include/asm-i386/hpet.h b/include/asm-i386/hpet.h
48377 --- /dev/null   Wed Dec 31 16:00:00 1969
48378 +++ b/include/asm-i386/hpet.h   Sun Aug 31 16:15:40 2003
48379 @@ -0,0 +1,116 @@
48380 +
48381 +#ifndef _I386_HPET_H
48382 +#define _I386_HPET_H
48383 +
48384 +#ifdef CONFIG_HPET_TIMER
48385 +
48386 +#include <linux/errno.h>
48387 +#include <linux/module.h>
48388 +#include <linux/sched.h>
48389 +#include <linux/kernel.h>
48390 +#include <linux/param.h>
48391 +#include <linux/string.h>
48392 +#include <linux/mm.h>
48393 +#include <linux/interrupt.h>
48394 +#include <linux/time.h>
48395 +#include <linux/delay.h>
48396 +#include <linux/init.h>
48397 +#include <linux/smp.h>
48398 +
48399 +#include <asm/io.h>
48400 +#include <asm/smp.h>
48401 +#include <asm/irq.h>
48402 +#include <asm/msr.h>
48403 +#include <asm/delay.h>
48404 +#include <asm/mpspec.h>
48405 +#include <asm/uaccess.h>
48406 +#include <asm/processor.h>
48407 +
48408 +#include <linux/timex.h>
48409 +#include <linux/config.h>
48410 +
48411 +#include <asm/fixmap.h>
48412 +
48413 +/*
48414 + * Documentation on HPET can be found at:
48415 + *      http://www.intel.com/ial/home/sp/pcmmspec.htm
48416 + *      ftp://download.intel.com/ial/home/sp/mmts098.pdf
48417 + */
48418 +
48419 +#define HPET_MMAP_SIZE 1024
48420 +
48421 +#define HPET_ID                0x000
48422 +#define HPET_PERIOD    0x004
48423 +#define HPET_CFG       0x010
48424 +#define HPET_STATUS    0x020
48425 +#define HPET_COUNTER   0x0f0
48426 +#define HPET_T0_CFG    0x100
48427 +#define HPET_T0_CMP    0x108
48428 +#define HPET_T0_ROUTE  0x110
48429 +#define HPET_T1_CFG    0x120
48430 +#define HPET_T1_CMP    0x128
48431 +#define HPET_T1_ROUTE  0x130
48432 +#define HPET_T2_CFG    0x140
48433 +#define HPET_T2_CMP    0x148
48434 +#define HPET_T2_ROUTE  0x150
48435 +
48436 +#define HPET_ID_VENDOR 0xffff0000
48437 +#define HPET_ID_LEGSUP 0x00008000
48438 +#define HPET_ID_NUMBER 0x00001f00
48439 +#define HPET_ID_REV    0x000000ff
48440 +
48441 +#define HPET_ID_VENDOR_SHIFT   16
48442 +#define HPET_ID_VENDOR_8086    0x8086
48443 +
48444 +#define HPET_CFG_ENABLE        0x001
48445 +#define HPET_CFG_LEGACY        0x002
48446 +
48447 +#define HPET_TN_ENABLE         0x004
48448 +#define HPET_TN_PERIODIC       0x008
48449 +#define HPET_TN_PERIODIC_CAP   0x010
48450 +#define HPET_TN_SETVAL         0x040
48451 +#define HPET_TN_32BIT          0x100
48452 +
48453 +/* Use our own asm for 64 bit multiply/divide */
48454 +#define ASM_MUL64_REG(eax_out,edx_out,reg_in,eax_in)                   \
48455 +               __asm__ __volatile__("mull %2"                          \
48456 +                               :"=a" (eax_out), "=d" (edx_out)         \
48457 +                               :"r" (reg_in), "0" (eax_in))
48458 +
48459 +#define ASM_DIV64_REG(eax_out,edx_out,reg_in,eax_in,edx_in)            \
48460 +               __asm__ __volatile__("divl %2"                          \
48461 +                               :"=a" (eax_out), "=d" (edx_out)         \
48462 +                               :"r" (reg_in), "0" (eax_in), "1" (edx_in))
48463 +
48464 +#define KERNEL_TICK_USEC       (1000000UL/HZ)  /* tick value in microsec */
48465 +/* Max HPET Period is 10^8 femto sec as in HPET spec */
48466 +#define HPET_MAX_PERIOD (100000000UL)
48467 +/*
48468 + * Min HPET period is 10^5 femto sec just for safety. If it is less than this,
48469 + * then 32 bit HPET counter wrapsaround in less than 0.5 sec.
48470 + */
48471 +#define HPET_MIN_PERIOD (100000UL)
48472 +
48473 +extern unsigned long hpet_period;      /* fsecs / HPET clock */
48474 +extern unsigned long hpet_tick;        /* hpet clks count per tick */
48475 +extern unsigned long hpet_address;     /* hpet memory map physical address */
48476 +
48477 +extern int hpet_rtc_timer_init(void);
48478 +extern int hpet_enable(void);
48479 +extern int is_hpet_enabled(void);
48480 +extern int is_hpet_capable(void);
48481 +extern int hpet_readl(unsigned long a);
48482 +extern void hpet_writel(unsigned long d, unsigned long a);
48483 +
48484 +#ifdef CONFIG_RTC
48485 +#define CONFIG_HPET_EMULATE_RTC        1
48486 +extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask);
48487 +extern int hpet_set_rtc_irq_bit(unsigned long bit_mask);
48488 +extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min, unsigned char sec);
48489 +extern int hpet_set_periodic_freq(unsigned long freq);
48490 +extern int hpet_rtc_dropped_irq(void);
48491 +extern int hpet_rtc_timer_init(void);
48492 +extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs);
48493 +#endif /* CONFIG_RTC */
48494 +#endif /* CONFIG_HPET_TIMER */
48495 +#endif /* _I386_HPET_H */
48496 diff -Nru a/include/asm-i386/i387.h b/include/asm-i386/i387.h
48497 --- a/include/asm-i386/i387.h   Fri May  9 14:22:55 2003
48498 +++ b/include/asm-i386/i387.h   Tue Sep  2 00:37:21 2003
48499 @@ -26,7 +26,9 @@
48500  extern void kernel_fpu_begin(void);
48501  #define kernel_fpu_end() do { stts(); preempt_enable(); } while(0)
48502  
48503 -
48504 +/*
48505 + * These must be called with preempt disabled
48506 + */
48507  static inline void __save_init_fpu( struct task_struct *tsk )
48508  {
48509         if ( cpu_has_fxsr ) {
48510 @@ -39,19 +41,12 @@
48511         tsk->thread_info->status &= ~TS_USEDFPU;
48512  }
48513  
48514 -static inline void save_init_fpu( struct task_struct *tsk )
48515 -{
48516 -       __save_init_fpu(tsk);
48517 -       stts();
48518 -}
48519 -
48520 -
48521 -#define unlazy_fpu( tsk ) do { \
48522 +#define __unlazy_fpu( tsk ) do { \
48523         if ((tsk)->thread_info->status & TS_USEDFPU) \
48524                 save_init_fpu( tsk ); \
48525  } while (0)
48526  
48527 -#define clear_fpu( tsk )                                       \
48528 +#define __clear_fpu( tsk )                                     \
48529  do {                                                           \
48530         if ((tsk)->thread_info->status & TS_USEDFPU) {          \
48531                 asm volatile("fwait");                          \
48532 @@ -60,6 +55,30 @@
48533         }                                                       \
48534  } while (0)
48535  
48536 +
48537 +/*
48538 + * These disable preemption on their own and are safe
48539 + */
48540 +static inline void save_init_fpu( struct task_struct *tsk )
48541 +{
48542 +       preempt_disable();
48543 +       __save_init_fpu(tsk);
48544 +       stts();
48545 +       preempt_enable();
48546 +}
48547 +
48548 +#define unlazy_fpu( tsk ) do { \
48549 +       preempt_disable();      \
48550 +       __unlazy_fpu(tsk);      \
48551 +       preempt_enable();       \
48552 +} while (0)
48553 +
48554 +#define clear_fpu( tsk ) do {  \
48555 +       preempt_disable();      \
48556 +       __clear_fpu( tsk );     \
48557 +       preempt_enable();       \
48558 +} while (0)
48559 +                                       \
48560  /*
48561   * FPU state interaction...
48562   */
48563 diff -Nru a/include/asm-i386/processor.h b/include/asm-i386/processor.h
48564 --- a/include/asm-i386/processor.h      Wed Aug 20 11:14:51 2003
48565 +++ b/include/asm-i386/processor.h      Sun Aug 31 16:13:54 2003
48566 @@ -578,6 +578,8 @@
48567  #define ARCH_HAS_PREFETCH
48568  extern inline void prefetch(const void *x)
48569  {
48570 +       if (cpu_data[0].x86_vendor == X86_VENDOR_AMD)
48571 +               return;         /* Some athlons fault if the address is bad */
48572         alternative_input(ASM_NOP4,
48573                           "prefetchnta (%1)",
48574                           X86_FEATURE_XMM,
48575 diff -Nru a/include/asm-i386/smp.h b/include/asm-i386/smp.h
48576 --- a/include/asm-i386/smp.h    Mon Aug 18 19:46:23 2003
48577 +++ b/include/asm-i386/smp.h    Sun Aug 31 16:14:42 2003
48578 @@ -32,7 +32,6 @@
48579   */
48580   
48581  extern void smp_alloc_memory(void);
48582 -extern physid_mask_t phys_cpu_present_map;
48583  extern int pic_mode;
48584  extern int smp_num_siblings;
48585  extern int cpu_sibling_map[];
48586 diff -Nru a/include/asm-i386/timer.h b/include/asm-i386/timer.h
48587 --- a/include/asm-i386/timer.h  Wed Jul  2 21:21:34 2003
48588 +++ b/include/asm-i386/timer.h  Sun Aug 31 16:15:21 2003
48589 @@ -38,4 +38,8 @@
48590  extern struct timer_opts timer_cyclone;
48591  #endif
48592  
48593 +#ifdef CONFIG_HPET_TIMER
48594 +extern struct timer_opts timer_hpet;
48595 +#endif
48596 +
48597  #endif
48598 diff -Nru a/include/asm-ia64/hw_irq.h b/include/asm-ia64/hw_irq.h
48599 --- a/include/asm-ia64/hw_irq.h Tue Jul 29 08:53:10 2003
48600 +++ b/include/asm-ia64/hw_irq.h Tue Aug 26 15:09:18 2003
48601 @@ -39,9 +39,9 @@
48602   * Vectors 0x10-0x1f are used for low priority interrupts, e.g. CMCI.
48603   */
48604  #define IA64_CPEP_VECTOR               0x1c    /* corrected platform error polling vector */
48605 -#define IA64_CMCP_VECTOR               0x1d    /* correctable machine-check polling vector */
48606 +#define IA64_CMCP_VECTOR               0x1d    /* corrected machine-check polling vector */
48607  #define IA64_CPE_VECTOR                        0x1e    /* corrected platform error interrupt vector */
48608 -#define IA64_CMC_VECTOR                        0x1f    /* correctable machine-check interrupt vector */
48609 +#define IA64_CMC_VECTOR                        0x1f    /* corrected machine-check interrupt vector */
48610  /*
48611   * Vectors 0x20-0x2f are reserved for legacy ISA IRQs.
48612   */
48613 diff -Nru a/include/asm-ia64/pci.h b/include/asm-ia64/pci.h
48614 --- a/include/asm-ia64/pci.h    Tue Jun 24 14:16:56 2003
48615 +++ b/include/asm-ia64/pci.h    Mon Aug 25 14:45:43 2003
48616 @@ -74,7 +74,7 @@
48617  #define pci_dac_dma_supported(pci_dev, mask)           (1)
48618  #define pci_dac_page_to_dma(dev,pg,off,dir)            ((dma_addr_t) page_to_bus(pg) + (off))
48619  #define pci_dac_dma_to_page(dev,dma_addr)              (virt_to_page(bus_to_virt(dma_addr)))
48620 -#define pci_dac_dma_to_offset(dev,dma_addr)            ((dma_addr) & ~PAGE_MASK)
48621 +#define pci_dac_dma_to_offset(dev,dma_addr)            offset_in_page(dma_addr)
48622  #define pci_dac_dma_sync_single(dev,dma_addr,len,dir)  do { mb(); } while (0)
48623  
48624  #define sg_dma_len(sg)         ((sg)->dma_length)
48625 diff -Nru a/include/asm-ia64/unistd.h b/include/asm-ia64/unistd.h
48626 --- a/include/asm-ia64/unistd.h Tue Aug 19 23:13:40 2003
48627 +++ b/include/asm-ia64/unistd.h Mon Aug 25 14:47:33 2003
48628 @@ -248,6 +248,7 @@
48629  #define __NR_sys_clock_nanosleep       1256
48630  #define __NR_sys_fstatfs64             1257
48631  #define __NR_sys_statfs64              1258
48632 +#define __NR_fadvises64_64             1259
48633  
48634  #ifdef __KERNEL__
48635  
48636 diff -Nru a/include/asm-m68k/local.h b/include/asm-m68k/local.h
48637 --- /dev/null   Wed Dec 31 16:00:00 1969
48638 +++ b/include/asm-m68k/local.h  Sun Jul 27 17:23:16 2003
48639 @@ -0,0 +1,6 @@
48640 +#ifndef _ASM_M68K_LOCAL_H
48641 +#define _ASM_M68K_LOCAL_H
48642 +
48643 +#include <asm-generic/local.h>
48644 +
48645 +#endif /* _ASM_M68K_LOCAL_H */
48646 diff -Nru a/include/asm-m68k/sections.h b/include/asm-m68k/sections.h
48647 --- /dev/null   Wed Dec 31 16:00:00 1969
48648 +++ b/include/asm-m68k/sections.h       Sun Jul 27 17:23:16 2003
48649 @@ -0,0 +1,6 @@
48650 +#ifndef _ASM_M68K_SECTIONS_H
48651 +#define _ASM_M68K_SECTIONS_H
48652 +
48653 +#include <asm-generic/sections.h>
48654 +
48655 +#endif /* _ASM_M68K_SECTIONS_H */
48656 diff -Nru a/include/asm-m68k/system.h b/include/asm-m68k/system.h
48657 --- a/include/asm-m68k/system.h Wed Feb 26 10:53:19 2003
48658 +++ b/include/asm-m68k/system.h Tue Aug 12 05:48:28 2003
48659 @@ -36,9 +36,12 @@
48660  #define switch_to(prev,next,last) do { \
48661    register void *_prev __asm__ ("a0") = (prev); \
48662    register void *_next __asm__ ("a1") = (next); \
48663 +  register void *_last __asm__ ("d1"); \
48664    __asm__ __volatile__("jbsr resume" \
48665 -                      : : "a" (_prev), "a" (_next) \
48666 -                      : "d0", "d1", "d2", "d3", "d4", "d5", "a0", "a1"); \
48667 +                      : "=a" (_prev), "=a" (_next), "=d" (_last) \
48668 +                      : "0" (_prev), "1" (_next) \
48669 +                      : "d0", "d2", "d3", "d4", "d5"); \
48670 +  (last) = _last; \
48671  } while (0)
48672  
48673  
48674 diff -Nru a/include/asm-m68knommu/irq.h b/include/asm-m68knommu/irq.h
48675 --- a/include/asm-m68knommu/irq.h       Fri Nov  1 08:37:46 2002
48676 +++ b/include/asm-m68knommu/irq.h       Sat Aug 23 06:08:54 2003
48677 @@ -2,6 +2,7 @@
48678  #define _M68K_IRQ_H_
48679  
48680  #include <linux/config.h>
48681 +#include <linux/interrupt.h>
48682  #include <asm/ptrace.h>
48683  
48684  #ifdef CONFIG_COLDFIRE
48685 @@ -62,7 +63,7 @@
48686  extern void (*mach_disable_irq)(unsigned int);
48687  
48688  extern int sys_request_irq(unsigned int, 
48689 -       void (*)(int, void *, struct pt_regs *), 
48690 +       irqreturn_t (*)(int, void *, struct pt_regs *), 
48691         unsigned long, const char *, void *);
48692  extern void sys_free_irq(unsigned int, void *);
48693  
48694 @@ -91,7 +92,7 @@
48695   * interrupt source (if it supports chaining).
48696   */
48697  typedef struct irq_node {
48698 -       void            (*handler)(int, void *, struct pt_regs *);
48699 +       irqreturn_t     (*handler)(int, void *, struct pt_regs *);
48700         unsigned long   flags;
48701         void            *dev_id;
48702         const char      *devname;
48703 @@ -102,7 +103,7 @@
48704   * This structure has only 4 elements for speed reasons
48705   */
48706  typedef struct irq_handler {
48707 -       void            (*handler)(int, void *, struct pt_regs *);
48708 +       irqreturn_t     (*handler)(int, void *, struct pt_regs *);
48709         unsigned long   flags;
48710         void            *dev_id;
48711         const char      *devname;
48712 diff -Nru a/include/asm-m68knommu/local.h b/include/asm-m68knommu/local.h
48713 --- /dev/null   Wed Dec 31 16:00:00 1969
48714 +++ b/include/asm-m68knommu/local.h     Sat Aug 23 06:08:54 2003
48715 @@ -0,0 +1,6 @@
48716 +#ifndef __M68KNOMMU_LOCAL_H
48717 +#define __M68KNOMMU_LOCAL_H
48718 +
48719 +#include <asm-generic/local.h>
48720 +
48721 +#endif /* __M68KNOMMU_LOCAL_H */
48722 diff -Nru a/include/asm-m68knommu/sections.h b/include/asm-m68knommu/sections.h
48723 --- /dev/null   Wed Dec 31 16:00:00 1969
48724 +++ b/include/asm-m68knommu/sections.h  Sat Aug 23 06:08:54 2003
48725 @@ -0,0 +1,7 @@
48726 +#ifndef _M68KNOMMU_SECTIONS_H
48727 +#define _M68KNOMMU_SECTIONS_H
48728 +
48729 +/* nothing to see, move along */
48730 +#include <asm-generic/sections.h>
48731 +
48732 +#endif
48733 diff -Nru a/include/asm-ppc/cpm_8260.h b/include/asm-ppc/cpm_8260.h
48734 --- a/include/asm-ppc/cpm_8260.h        Sun Sep 15 21:52:03 2002
48735 +++ b/include/asm-ppc/cpm_8260.h        Thu Aug 21 15:26:43 2003
48736 @@ -195,7 +195,7 @@
48737  
48738  /* SMC uart mode register (Internal memory map).
48739  */
48740 -#define        SMCMR_REN       ((ushort)0x0001)
48741 +#define SMCMR_REN      ((ushort)0x0001)
48742  #define SMCMR_TEN      ((ushort)0x0002)
48743  #define SMCMR_DM       ((ushort)0x000c)
48744  #define SMCMR_SM_GCI   ((ushort)0x0000)
48745 @@ -212,10 +212,12 @@
48746  
48747  /* SMC Event and Mask register.
48748  */
48749 -#define        SMCM_TXE        ((unsigned char)0x10)
48750 -#define        SMCM_BSY        ((unsigned char)0x04)
48751 -#define        SMCM_TX         ((unsigned char)0x02)
48752 -#define        SMCM_RX         ((unsigned char)0x01)
48753 +#define SMCM_BRKE       ((unsigned char)0x40)   /* When in UART Mode */
48754 +#define SMCM_BRK        ((unsigned char)0x10)   /* When in UART Mode */
48755 +#define SMCM_TXE       ((unsigned char)0x10)
48756 +#define SMCM_BSY       ((unsigned char)0x04)
48757 +#define SMCM_TX                ((unsigned char)0x02)
48758 +#define SMCM_RX                ((unsigned char)0x01)
48759  
48760  /* Baud rate generators.
48761  */
48762 @@ -314,10 +316,10 @@
48763  
48764  /* SCC Event and Mask register.
48765  */
48766 -#define        SCCM_TXE        ((unsigned char)0x10)
48767 -#define        SCCM_BSY        ((unsigned char)0x04)
48768 -#define        SCCM_TX         ((unsigned char)0x02)
48769 -#define        SCCM_RX         ((unsigned char)0x01)
48770 +#define SCCM_TXE       ((unsigned char)0x10)
48771 +#define SCCM_BSY       ((unsigned char)0x04)
48772 +#define SCCM_TX                ((unsigned char)0x02)
48773 +#define SCCM_RX                ((unsigned char)0x01)
48774  
48775  typedef struct scc_param {
48776         ushort  scc_rbase;      /* Rx Buffer descriptor base address */
48777 diff -Nru a/include/asm-ppc/macio.h b/include/asm-ppc/macio.h
48778 --- a/include/asm-ppc/macio.h   Sat Aug  9 09:39:19 2003
48779 +++ b/include/asm-ppc/macio.h   Sun Aug 24 04:06:49 2003
48780 @@ -42,6 +42,9 @@
48781  #define        to_macio_device(d) container_of(d, struct macio_dev, ofdev.dev)
48782  #define        of_to_macio_device(d) container_of(d, struct macio_dev, ofdev)
48783  
48784 +extern struct macio_dev *macio_dev_get(struct macio_dev *dev);
48785 +extern void macio_dev_put(struct macio_dev *dev);
48786 +
48787  /*
48788   * A driver for a mac-io chip based device
48789   */
48790 @@ -54,8 +57,8 @@
48791         int     (*probe)(struct macio_dev* dev, const struct of_match *match);
48792         int     (*remove)(struct macio_dev* dev);
48793  
48794 -       int     (*suspend)(struct macio_dev* dev, u32 state, u32 level);
48795 -       int     (*resume)(struct macio_dev* dev, u32 level);
48796 +       int     (*suspend)(struct macio_dev* dev, u32 state);
48797 +       int     (*resume)(struct macio_dev* dev);
48798         int     (*shutdown)(struct macio_dev* dev);
48799  
48800         struct device_driver    driver;
48801 diff -Nru a/include/asm-ppc/of_device.h b/include/asm-ppc/of_device.h
48802 --- a/include/asm-ppc/of_device.h       Sat Aug  9 09:40:04 2003
48803 +++ b/include/asm-ppc/of_device.h       Sun Aug 24 04:06:49 2003
48804 @@ -39,6 +39,9 @@
48805  extern const struct of_match *of_match_device(
48806         const struct of_match *matches, const struct of_device *dev);
48807  
48808 +extern struct of_device *of_dev_get(struct of_device *dev);
48809 +extern void of_dev_put(struct of_device *dev);
48810 +
48811  /*
48812   * An of_platform_driver driver is attached to a basic of_device on
48813   * the "platform bus" (of_platform_bus_type)
48814 @@ -52,8 +55,8 @@
48815         int     (*probe)(struct of_device* dev, const struct of_match *match);
48816         int     (*remove)(struct of_device* dev);
48817  
48818 -       int     (*suspend)(struct of_device* dev, u32 state, u32 level);
48819 -       int     (*resume)(struct of_device* dev, u32 level);
48820 +       int     (*suspend)(struct of_device* dev, u32 state);
48821 +       int     (*resume)(struct of_device* dev);
48822         int     (*shutdown)(struct of_device* dev);
48823  
48824         struct device_driver    driver;
48825 @@ -65,6 +68,7 @@
48826  extern int of_device_register(struct of_device *ofdev);
48827  extern void of_device_unregister(struct of_device *ofdev);
48828  extern struct of_device *of_platform_device_create(struct device_node *np, const char *bus_id);
48829 +extern void of_release_dev(struct device *dev);
48830  
48831  #endif /* __OF_DEVICE_H__ */
48832  
48833 diff -Nru a/include/asm-ppc/processor.h b/include/asm-ppc/processor.h
48834 --- a/include/asm-ppc/processor.h       Wed Jul 16 20:41:10 2003
48835 +++ b/include/asm-ppc/processor.h       Fri Aug 22 05:26:16 2003
48836 @@ -654,6 +654,7 @@
48837   */
48838  #define EISA_bus 0
48839  #define MCA_bus 0
48840 +#define MCA_bus__is_a_macro
48841  
48842  /* Lazy FPU handling on uni-processor */
48843  extern struct task_struct *last_task_used_math;
48844 diff -Nru a/include/asm-ppc/prom.h b/include/asm-ppc/prom.h
48845 --- a/include/asm-ppc/prom.h    Sat Jan  4 03:31:26 2003
48846 +++ b/include/asm-ppc/prom.h    Sun Aug 24 03:57:52 2003
48847 @@ -62,18 +62,35 @@
48848  struct prom_args;
48849  typedef void (*prom_entry)(struct prom_args *);
48850  
48851 -/* Prototypes */
48852 -extern void abort(void);
48853 -extern unsigned long prom_init(int, int, prom_entry);
48854 -extern void prom_print(const char *msg);
48855 -extern void relocate_nodes(void);
48856 -extern void finish_device_tree(void);
48857 +/* OBSOLETE: Old style node lookup */
48858  extern struct device_node *find_devices(const char *name);
48859  extern struct device_node *find_type_devices(const char *type);
48860  extern struct device_node *find_path_device(const char *path);
48861  extern struct device_node *find_compatible_devices(const char *type,
48862                                                    const char *compat);
48863  extern struct device_node *find_all_nodes(void);
48864 +
48865 +/* New style node lookup */
48866 +extern struct device_node *of_find_node_by_name(struct device_node *from,
48867 +       const char *name);
48868 +extern struct device_node *of_find_node_by_type(struct device_node *from,
48869 +       const char *type);
48870 +extern struct device_node *of_find_compatible_node(struct device_node *from,
48871 +       const char *type, const char *compat);
48872 +extern struct device_node *of_find_node_by_path(const char *path);
48873 +extern struct device_node *of_find_all_nodes(struct device_node *prev);
48874 +extern struct device_node *of_get_parent(const struct device_node *node);
48875 +extern struct device_node *of_get_next_child(const struct device_node *node,
48876 +                                            struct device_node *prev);
48877 +extern struct device_node *of_node_get(struct device_node *node);
48878 +extern void of_node_put(struct device_node *node);
48879 +
48880 +/* Other Prototypes */
48881 +extern void abort(void);
48882 +extern unsigned long prom_init(int, int, prom_entry);
48883 +extern void prom_print(const char *msg);
48884 +extern void relocate_nodes(void);
48885 +extern void finish_device_tree(void);
48886  extern int device_is_compatible(struct device_node *device, const char *);
48887  extern int machine_is_compatible(const char *compat);
48888  extern unsigned char *get_property(struct device_node *node, const char *name,
48889 diff -Nru a/include/asm-ppc/unistd.h b/include/asm-ppc/unistd.h
48890 --- a/include/asm-ppc/unistd.h  Tue Jul 15 04:47:19 2003
48891 +++ b/include/asm-ppc/unistd.h  Fri Aug 22 19:15:18 2003
48892 @@ -258,8 +258,9 @@
48893  #define __NR_utimes            251
48894  #define __NR_statfs64          252
48895  #define __NR_fstatfs64         253
48896 +#define __NR_fadvise64_64      254
48897  
48898 -#define __NR_syscalls          254
48899 +#define __NR_syscalls          255
48900  
48901  #define __NR(n)        #n
48902  
48903 diff -Nru a/include/asm-sparc/pci.h b/include/asm-sparc/pci.h
48904 --- a/include/asm-sparc/pci.h   Mon Jun  9 09:27:29 2003
48905 +++ b/include/asm-sparc/pci.h   Thu Aug 28 01:15:54 2003
48906 @@ -78,6 +78,14 @@
48907  #define pci_unmap_len_set(PTR, LEN_NAME, VAL)          \
48908         (((PTR)->LEN_NAME) = (VAL))
48909  
48910 +/*
48911 + * Same as above, only with pages instead of mapped addresses.
48912 + */
48913 +extern dma_addr_t pci_map_page(struct pci_dev *hwdev, struct page *page,
48914 +                       unsigned long offset, size_t size, int direction);
48915 +extern void pci_unmap_page(struct pci_dev *hwdev,
48916 +                       dma_addr_t dma_address, size_t size, int direction);
48917 +
48918  /* Map a set of buffers described by scatterlist in streaming
48919   * mode for DMA.  This is the scather-gather version of the
48920   * above pci_map_single interface.  Here the scatter gather list
48921 diff -Nru a/include/asm-sparc/smp.h b/include/asm-sparc/smp.h
48922 --- a/include/asm-sparc/smp.h   Mon Aug 18 19:46:23 2003
48923 +++ b/include/asm-sparc/smp.h   Thu Aug 28 00:18:36 2003
48924 @@ -8,11 +8,13 @@
48925  
48926  #include <linux/config.h>
48927  #include <linux/threads.h>
48928 -#include <linux/cpumask.h>
48929  #include <asm/head.h>
48930  #include <asm/btfixup.h>
48931  
48932  #ifndef __ASSEMBLY__
48933 +
48934 +#include <linux/cpumask.h>
48935 +
48936  /* PROM provided per-processor information we need
48937   * to start them all up.
48938   */
48939 diff -Nru a/include/asm-sparc/unistd.h b/include/asm-sparc/unistd.h
48940 --- a/include/asm-sparc/unistd.h        Sat Aug 16 14:13:18 2003
48941 +++ b/include/asm-sparc/unistd.h        Wed Aug 27 23:52:25 2003
48942 @@ -282,10 +282,11 @@
48943  #define __NR_timer_gettime     263
48944  #define __NR_timer_getoverrun  264
48945  #define __NR_timer_delete      265
48946 -/* WARNING: You MAY NOT add syscall numbers larger than 265, since
48947 +#define __NR_timer_create      266
48948 +/* WARNING: You MAY NOT add syscall numbers larger than 266, since
48949   *          all of the syscall tables in the Sparc kernel are
48950 - *          sized to have 266 entries (starting at zero).  Therefore
48951 - *          find a free slot in the 0-265 range.
48952 + *          sized to have 267 entries (starting at zero).  Therefore
48953 + *          find a free slot in the 0-266 range.
48954   */
48955  
48956  #define _syscall0(type,name) \
48957 diff -Nru a/include/asm-sparc64/siginfo.h b/include/asm-sparc64/siginfo.h
48958 --- a/include/asm-sparc64/siginfo.h     Sun Jan  5 23:08:44 2003
48959 +++ b/include/asm-sparc64/siginfo.h     Thu Aug 28 01:31:51 2003
48960 @@ -83,7 +83,7 @@
48961  #ifdef __KERNEL__
48962  
48963  typedef struct sigevent32 {
48964 -       sigval_t sigev_value;
48965 +       sigval_t32 sigev_value;
48966         int sigev_signo;
48967         int sigev_notify;
48968         union {
48969 diff -Nru a/include/asm-sparc64/unistd.h b/include/asm-sparc64/unistd.h
48970 --- a/include/asm-sparc64/unistd.h      Sat Aug 16 14:13:18 2003
48971 +++ b/include/asm-sparc64/unistd.h      Wed Aug 27 23:52:25 2003
48972 @@ -284,10 +284,11 @@
48973  #define __NR_timer_gettime     263
48974  #define __NR_timer_getoverrun  264
48975  #define __NR_timer_delete      265
48976 -/* WARNING: You MAY NOT add syscall numbers larger than 265, since
48977 +#define __NR_timer_create      266
48978 +/* WARNING: You MAY NOT add syscall numbers larger than 266, since
48979   *          all of the syscall tables in the Sparc kernel are
48980 - *          sized to have 266 entries (starting at zero).  Therefore
48981 - *          find a free slot in the 0-265 range.
48982 + *          sized to have 267 entries (starting at zero).  Therefore
48983 + *          find a free slot in the 0-266 range.
48984   */
48985  
48986  #define _syscall0(type,name) \
48987 diff -Nru a/include/asm-x86_64/bitops.h b/include/asm-x86_64/bitops.h
48988 --- a/include/asm-x86_64/bitops.h       Mon Aug 18 19:46:23 2003
48989 +++ b/include/asm-x86_64/bitops.h       Sat Aug 23 04:08:11 2003
48990 @@ -466,7 +466,7 @@
48991  
48992         __asm__("bsfl %1,%0\n\t"
48993                 "cmovzl %2,%0" 
48994 -               : "=r" (r) : "g" (x), "r" (32));
48995 +               : "=r" (r) : "g" (x), "r" (-1));
48996         return r+1;
48997  }
48998  
48999 diff -Nru a/include/asm-x86_64/ia32.h b/include/asm-x86_64/ia32.h
49000 --- a/include/asm-x86_64/ia32.h Fri May 23 03:22:07 2003
49001 +++ b/include/asm-x86_64/ia32.h Sun Aug 31 16:13:59 2003
49002 @@ -160,7 +160,6 @@
49003         char                    f_fpack[6];
49004  };
49005  
49006 -#define IA32_PAGE_OFFSET 0xffffe000
49007  #define IA32_STACK_TOP IA32_PAGE_OFFSET
49008  
49009  #ifdef __KERNEL__
49010 diff -Nru a/include/asm-x86_64/mpspec.h b/include/asm-x86_64/mpspec.h
49011 --- a/include/asm-x86_64/mpspec.h       Mon Aug 18 19:46:23 2003
49012 +++ b/include/asm-x86_64/mpspec.h       Sat Aug 23 05:13:33 2003
49013 @@ -169,7 +169,6 @@
49014  extern cpumask_t mp_bus_to_cpumask [MAX_MP_BUSSES];
49015  
49016  extern unsigned int boot_cpu_physical_apicid;
49017 -extern cpumask_t phys_cpu_present_map;
49018  extern int smp_found_config;
49019  extern void find_smp_config (void);
49020  extern void get_smp_config (void);
49021 @@ -197,6 +196,50 @@
49022  extern void mp_config_ioapic_for_sci(int irq);
49023  
49024  extern int using_apic_timer;
49025 +
49026 +#define PHYSID_ARRAY_SIZE      BITS_TO_LONGS(MAX_APICS)
49027 +
49028 +struct physid_mask
49029 +{
49030 +       unsigned long mask[PHYSID_ARRAY_SIZE];
49031 +};
49032 +
49033 +typedef struct physid_mask physid_mask_t;
49034 +
49035 +#define physid_set(physid, map)                        set_bit(physid, (map).mask)
49036 +#define physid_clear(physid, map)              clear_bit(physid, (map).mask)
49037 +#define physid_isset(physid, map)              test_bit(physid, (map).mask)
49038 +#define physid_test_and_set(physid, map)       test_and_set_bit(physid, (map).mask)
49039 +
49040 +#define physids_and(dst, src1, src2)           bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
49041 +#define physids_or(dst, src1, src2)            bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
49042 +#define physids_clear(map)                     bitmap_clear((map).mask, MAX_APICS)
49043 +#define physids_complement(map)                        bitmap_complement((map).mask, MAX_APICS)
49044 +#define physids_empty(map)                     bitmap_empty((map).mask, MAX_APICS)
49045 +#define physids_equal(map1, map2)              bitmap_equal((map1).mask, (map2).mask, MAX_APICS)
49046 +#define physids_weight(map)                    bitmap_weight((map).mask, MAX_APICS)
49047 +#define physids_shift_right(d, s, n)           bitmap_shift_right((d).mask, (s).mask, n, MAX_APICS)
49048 +#define physids_shift_left(d, s, n)            bitmap_shift_left((d).mask, (s).mask, n, MAX_APICS)
49049 +#define physids_coerce(map)                    ((map).mask[0])
49050 +
49051 +#define physids_promote(physids)                                               \
49052 +       ({                                                                      \
49053 +               physid_mask_t __physid_mask = PHYSID_MASK_NONE;                 \
49054 +               __physid_mask.mask[0] = physids;                                \
49055 +               __physid_mask;                                                  \
49056 +       })
49057 +
49058 +#define physid_mask_of_physid(physid)                                          \
49059 +       ({                                                                      \
49060 +               physid_mask_t __physid_mask = PHYSID_MASK_NONE;                 \
49061 +               physid_set(physid, __physid_mask);                              \
49062 +               __physid_mask;                                                  \
49063 +       })
49064 +
49065 +#define PHYSID_MASK_ALL                { {[0 ... PHYSID_ARRAY_SIZE-1] = ~0UL} }
49066 +#define PHYSID_MASK_NONE       { {[0 ... PHYSID_ARRAY_SIZE-1] = 0UL} }
49067 +
49068 +extern physid_mask_t phys_cpu_present_map;
49069  
49070  #endif
49071  
49072 diff -Nru a/include/asm-x86_64/percpu.h b/include/asm-x86_64/percpu.h
49073 --- a/include/asm-x86_64/percpu.h       Fri Aug  8 13:06:56 2003
49074 +++ b/include/asm-x86_64/percpu.h       Sat Aug 23 05:29:54 2003
49075 @@ -31,6 +31,9 @@
49076                         memcpy((pcpudst)+__per_cpu_offset(__i), \
49077                                (src), (size));                  \
49078  } while (0)
49079 +
49080 +extern void setup_per_cpu_areas(void);
49081 +
49082  #else /* ! SMP */
49083  
49084  #define DEFINE_PER_CPU(type, name) \
49085 @@ -45,7 +48,5 @@
49086  
49087  #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
49088  #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
49089 -
49090 -extern void setup_per_cpu_areas(void);
49091  
49092  #endif /* _ASM_X8664_PERCPU_H_ */
49093 diff -Nru a/include/asm-x86_64/processor.h b/include/asm-x86_64/processor.h
49094 --- a/include/asm-x86_64/processor.h    Wed Aug 20 11:16:28 2003
49095 +++ b/include/asm-x86_64/processor.h    Sun Aug 31 16:13:59 2003
49096 @@ -18,6 +18,7 @@
49097  #include <asm/current.h>
49098  #include <asm/system.h>
49099  #include <asm/mmsegment.h>
49100 +#include <linux/personality.h>
49101  
49102  #define TF_MASK                0x00000100
49103  #define IF_MASK                0x00000200
49104 @@ -172,7 +173,8 @@
49105  /* This decides where the kernel will search for a free chunk of vm
49106   * space during mmap's.
49107   */
49108 -#define TASK_UNMAPPED_32 0xa0000000
49109 +#define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? 0xc0000000 : 0xFFFFe000)
49110 +#define TASK_UNMAPPED_32 (IA32_PAGE_OFFSET / 3)
49111  #define TASK_UNMAPPED_64 PAGE_ALIGN(TASK_SIZE/3) 
49112  #define TASK_UNMAPPED_BASE     \
49113         (test_thread_flag(TIF_IA32) ? TASK_UNMAPPED_32 : TASK_UNMAPPED_64)  
49114 @@ -225,7 +227,6 @@
49115          * 8 bytes, for an extra "long" of ~0UL
49116          */
49117         unsigned long io_bitmap[IO_BITMAP_LONGS + 1];
49118 -       u32 __cacheline_filler[4];      /* size is 0x100 */
49119  } __attribute__((packed)) ____cacheline_aligned;
49120  
49121  struct thread_struct {
49122 diff -Nru a/include/asm-x86_64/smp.h b/include/asm-x86_64/smp.h
49123 --- a/include/asm-x86_64/smp.h  Mon Aug 18 19:46:23 2003
49124 +++ b/include/asm-x86_64/smp.h  Sat Aug 23 05:14:50 2003
49125 @@ -36,7 +36,6 @@
49126   */
49127   
49128  extern void smp_alloc_memory(void);
49129 -extern cpumask_t phys_cpu_present_map;
49130  extern cpumask_t cpu_online_map;
49131  extern volatile unsigned long smp_invalidate_needed;
49132  extern int pic_mode;
49133 diff -Nru a/include/asm-x86_64/suspend.h b/include/asm-x86_64/suspend.h
49134 --- a/include/asm-x86_64/suspend.h      Sat Jun  7 00:54:11 2003
49135 +++ b/include/asm-x86_64/suspend.h      Sat Aug 23 05:22:09 2003
49136 @@ -44,7 +44,7 @@
49137                         :"r" ((thread)->debugreg##register))
49138  
49139  extern void fix_processor_context(void);
49140 -extern void do_magic(int resume);
49141 +extern int do_magic(int resume);
49142  
49143  #ifdef CONFIG_ACPI_SLEEP
49144  extern unsigned long saved_eip;
49145 diff -Nru a/include/asm-x86_64/topology.h b/include/asm-x86_64/topology.h
49146 --- a/include/asm-x86_64/topology.h     Mon Aug 18 19:46:23 2003
49147 +++ b/include/asm-x86_64/topology.h     Sat Aug 23 04:00:02 2003
49148 @@ -10,21 +10,18 @@
49149  /* Map the K8 CPU local memory controllers to a simple 1:1 CPU:NODE topology */
49150  
49151  extern int fake_node;
49152 -extern cpumask_t cpu_online_map;
49153 +extern unsigned long cpu_online_map;
49154  
49155  #define cpu_to_node(cpu)               (fake_node ? 0 : (cpu))
49156  #define memblk_to_node(memblk)         (fake_node ? 0 : (memblk))
49157  #define parent_node(node)              (node)
49158  #define node_to_first_cpu(node)        (fake_node ? 0 : (node))
49159 -#define node_to_cpu_mask(node) (fake_node ? cpu_online_map : cpumask_of_cpu(node))
49160 +#define node_to_cpu_mask(node) (fake_node ? cpu_online_map : (1UL << (node)))
49161  #define node_to_memblk(node)           (node)
49162  
49163 -static inline cpumask_t pcibus_to_cpumask(int bus)
49164 +static inline unsigned long pcibus_to_cpumask(int bus)
49165  {
49166 -       cpumask_t ret;
49167 -
49168 -       cpus_and(ret, mp_bus_to_cpumask[bus], cpu_online_map);
49169 -       return ret;
49170 +       return mp_bus_to_cpumask[bus] & cpu_online_map; 
49171  }
49172  
49173  #define NODE_BALANCE_RATE 30   /* CHECKME */ 
49174 diff -Nru a/include/linux/blkdev.h b/include/linux/blkdev.h
49175 --- a/include/linux/blkdev.h    Thu Aug 14 18:16:17 2003
49176 +++ b/include/linux/blkdev.h    Mon Sep  1 04:03:21 2003
49177 @@ -243,6 +243,7 @@
49178  
49179  struct bio_vec;
49180  typedef int (merge_bvec_fn) (request_queue_t *, struct bio *, struct bio_vec *);
49181 +typedef void (activity_fn) (void *data, int rw);
49182  
49183  enum blk_queue_state {
49184         Queue_down,
49185 @@ -283,6 +284,7 @@
49186         prep_rq_fn              *prep_rq_fn;
49187         unplug_fn               *unplug_fn;
49188         merge_bvec_fn           *merge_bvec_fn;
49189 +       activity_fn             *activity_fn;
49190  
49191         /*
49192          * Auto-unplugging state
49193 @@ -300,6 +302,8 @@
49194          */
49195         void                    *queuedata;
49196  
49197 +       void                    *activity_data;
49198 +
49199         /*
49200          * queue needs bounce pages for pages above this limit
49201          */
49202 @@ -504,6 +508,7 @@
49203  extern void blk_stop_queue(request_queue_t *q);
49204  extern void __blk_stop_queue(request_queue_t *q);
49205  extern void blk_run_queue(request_queue_t *q);
49206 +extern void blk_queue_activity_fn(request_queue_t *, activity_fn *, void *);
49207  
49208  static inline request_queue_t *bdev_get_queue(struct block_device *bdev)
49209  {
49210 diff -Nru a/include/linux/cyclomx.h b/include/linux/cyclomx.h
49211 --- a/include/linux/cyclomx.h   Tue May 20 07:19:38 2003
49212 +++ b/include/linux/cyclomx.h   Sat Aug 23 20:38:19 2003
49213 @@ -52,7 +52,7 @@
49214         char in_isr;                    /* interrupt-in-service flag */
49215         char buff_int_mode_unbusy;      /* flag for carrying out dev_tint */
49216         wait_queue_head_t wait_stats;  /* to wait for the STATS indication */
49217 -       u32 mbox;                       /* -> mailbox */
49218 +       void *mbox;                     /* -> mailbox */
49219         void (*isr)(struct cycx_device* card);  /* interrupt service routine */
49220         int (*exec)(struct cycx_device* card, void* u_cmd, void* u_data);
49221         union {
49222 diff -Nru a/include/linux/cycx_cfm.h b/include/linux/cycx_cfm.h
49223 --- a/include/linux/cycx_cfm.h  Thu May 15 19:24:05 2003
49224 +++ b/include/linux/cycx_cfm.h  Sat Aug 23 19:57:15 2003
49225 @@ -90,7 +90,7 @@
49226         unsigned short      reserved[6];
49227         char                descr[CFM_DESCR_LEN];
49228         struct cycx_fw_info info;
49229 -       unsigned char       image[1];
49230 +       unsigned char       image[0];
49231  };
49232  
49233  struct cycx_fw_header {
49234 diff -Nru a/include/linux/cycx_drv.h b/include/linux/cycx_drv.h
49235 --- a/include/linux/cycx_drv.h  Thu May 15 19:33:21 2003
49236 +++ b/include/linux/cycx_drv.h  Sat Aug 23 20:11:44 2003
49237 @@ -48,7 +48,7 @@
49238  struct cycx_hw {
49239         u32 fwid;
49240         int irq;
49241 -       u32 dpmbase;
49242 +       void *dpmbase;
49243         u32 dpmsize;
49244         u32 reserved[5];
49245  };
49246 @@ -58,7 +58,7 @@
49247  extern int cycx_down(struct cycx_hw *hw);
49248  extern int cycx_peek(struct cycx_hw *hw, u32 addr, void *buf, u32 len);
49249  extern int cycx_poke(struct cycx_hw *hw, u32 addr, void *buf, u32 len);
49250 -extern int cycx_exec(u32 addr);
49251 +extern int cycx_exec(void *addr);
49252  
49253  extern void cycx_inten(struct cycx_hw *hw);
49254  extern void cycx_intr(struct cycx_hw *hw);
49255 diff -Nru a/include/linux/ethtool.h b/include/linux/ethtool.h
49256 --- a/include/linux/ethtool.h   Thu Aug  7 13:16:01 2003
49257 +++ b/include/linux/ethtool.h   Mon Sep  1 17:25:54 2003
49258 @@ -255,8 +255,11 @@
49259  /* Some generic methods drivers may use in their ethtool_ops */
49260  u32 ethtool_op_get_link(struct net_device *dev);
49261  u32 ethtool_op_get_tx_csum(struct net_device *dev);
49262 +int ethtool_op_set_tx_csum(struct net_device *dev, u32 data);
49263  u32 ethtool_op_get_sg(struct net_device *dev);
49264  int ethtool_op_set_sg(struct net_device *dev, u32 data);
49265 +u32 ethtool_op_get_tso(struct net_device *dev);
49266 +int ethtool_op_set_tso(struct net_device *dev, u32 data);
49267  
49268  /**
49269   * &ethtool_ops - Alter and report network device settings
49270 @@ -284,6 +287,8 @@
49271   * set_tx_csum: Turn transmit checksums on or off
49272   * get_sg: Report whether scatter-gather is enabled
49273   * set_sg: Turn scatter-gather on or off
49274 + * get_tso: Report whether TCP segmentation offload is enabled
49275 + * set_tso: Turn TCP segmentation offload on or off
49276   * self_test: Run specified self-tests
49277   * get_strings: Return a set of strings that describe the requested objects 
49278   * phys_id: Identify the device
49279 @@ -337,6 +342,8 @@
49280         int     (*set_tx_csum)(struct net_device *, u32);
49281         u32     (*get_sg)(struct net_device *);
49282         int     (*set_sg)(struct net_device *, u32);
49283 +       u32     (*get_tso)(struct net_device *);
49284 +       int     (*set_tso)(struct net_device *, u32);
49285         int     (*self_test_count)(struct net_device *);
49286         void    (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
49287         void    (*get_strings)(struct net_device *, u32 stringset, u8 *);
49288 diff -Nru a/include/linux/fs.h b/include/linux/fs.h
49289 --- a/include/linux/fs.h        Fri Jul 11 10:32:02 2003
49290 +++ b/include/linux/fs.h        Sun Aug 31 16:14:42 2003
49291 @@ -336,10 +336,8 @@
49292  };
49293  
49294  struct block_device {
49295 -       struct list_head        bd_hash;
49296 -       atomic_t                bd_count;
49297 -       struct inode *          bd_inode;
49298         dev_t                   bd_dev;  /* not a kdev_t - it's a search key */
49299 +       struct inode *          bd_inode;       /* will die */
49300         int                     bd_openers;
49301         struct semaphore        bd_sem; /* open/close mutex */
49302         struct list_head        bd_inodes;
49303 @@ -347,10 +345,11 @@
49304         int                     bd_holders;
49305         struct block_device *   bd_contains;
49306         unsigned                bd_block_size;
49307 -       sector_t                bd_offset;
49308 +       struct hd_struct *      bd_part;
49309         unsigned                bd_part_count;
49310         int                     bd_invalidated;
49311         struct gendisk *        bd_disk;
49312 +       struct list_head        bd_list;
49313  };
49314  
49315  /*
49316 @@ -468,6 +467,16 @@
49317  #endif
49318  }
49319  
49320 +static inline unsigned iminor(struct inode *inode)
49321 +{
49322 +       return minor(inode->i_rdev);
49323 +}
49324 +
49325 +static inline unsigned imajor(struct inode *inode)
49326 +{
49327 +       return major(inode->i_rdev);
49328 +}
49329 +
49330  struct fown_struct {
49331         rwlock_t lock;          /* protects pid, uid, euid fields */
49332         int pid;                /* pid or -pgrp where SIGIO should be sent */
49333 @@ -600,6 +609,10 @@
49334  extern int fcntl_setlk64(struct file *, unsigned int, struct flock64 __user *);
49335  #endif
49336  
49337 +extern void send_sigio(struct fown_struct *fown, int fd, int band);
49338 +extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
49339 +extern int fcntl_getlease(struct file *filp);
49340 +
49341  /* fs/locks.c */
49342  extern void locks_init_lock(struct file_lock *);
49343  extern void locks_copy_lock(struct file_lock *, struct file_lock *);
49344 @@ -1176,6 +1189,12 @@
49345  unsigned long invalidate_mapping_pages(struct address_space *mapping,
49346                                         pgoff_t start, pgoff_t end);
49347  unsigned long invalidate_inode_pages(struct address_space *mapping);
49348 +static inline void invalidate_remote_inode(struct inode *inode)
49349 +{
49350 +       if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
49351 +           S_ISLNK(inode->i_mode))
49352 +               invalidate_inode_pages(inode->i_mapping);
49353 +}
49354  extern void invalidate_inode_pages2(struct address_space *mapping);
49355  extern void write_inode_now(struct inode *, int);
49356  extern int filemap_fdatawrite(struct address_space *);
49357 diff -Nru a/include/linux/genhd.h b/include/linux/genhd.h
49358 --- a/include/linux/genhd.h     Thu Jun  5 23:32:48 2003
49359 +++ b/include/linux/genhd.h     Sun Aug 31 16:14:27 2003
49360 @@ -197,7 +197,7 @@
49361  
49362  static inline sector_t get_start_sect(struct block_device *bdev)
49363  {
49364 -       return bdev->bd_offset;
49365 +       return bdev->bd_contains == bdev ? 0 : bdev->bd_part->start_sect;
49366  }
49367  static inline sector_t get_capacity(struct gendisk *disk)
49368  {
49369 diff -Nru a/include/linux/ide.h b/include/linux/ide.h
49370 --- a/include/linux/ide.h       Wed Aug 20 09:01:03 2003
49371 +++ b/include/linux/ide.h       Mon Sep  1 04:03:22 2003
49372 @@ -1044,6 +1044,8 @@
49373         void            *hwif_data;     /* extra hwif data */
49374  
49375         unsigned dma;
49376 +
49377 +       void (*led_act)(void *data, int rw);
49378  } ide_hwif_t;
49379  
49380  /*
49381 @@ -1242,21 +1244,6 @@
49382  
49383  extern int generic_ide_ioctl(struct block_device *, unsigned, unsigned long);
49384  
49385 -/*
49386 - * IDE modules.
49387 - */
49388 -#define IDE_CHIPSET_MODULE             0       /* not supported yet */
49389 -#define IDE_PROBE_MODULE               1
49390 -
49391 -typedef int    (ide_module_init_proc)(void);
49392 -
49393 -typedef struct ide_module_s {
49394 -       int                             type;
49395 -       ide_module_init_proc            *init;
49396 -       void                            *info;
49397 -       struct ide_module_s             *next;
49398 -} ide_module_t;
49399 -
49400  typedef struct ide_devices_s {
49401         char                    name[4];                /* hdX */
49402         unsigned                attached        : 1;    /* native */
49403 @@ -1274,8 +1261,7 @@
49404   */
49405  #ifndef _IDE_C
49406  extern ide_hwif_t      ide_hwifs[];            /* master data repository */
49407 -extern ide_module_t    *ide_chipsets;
49408 -extern ide_module_t    *ide_probe;
49409 +extern int (*ide_probe)(void);
49410  
49411  extern ide_devices_t   *idedisk;
49412  extern ide_devices_t   *idecd;
49413 @@ -1772,8 +1758,6 @@
49414  extern void ide_hwif_release_regions(ide_hwif_t* hwif);
49415  extern void ide_unregister (unsigned int index);
49416  
49417 -extern int export_ide_init_queue(ide_drive_t *);
49418 -extern u8 export_probe_for_drive(ide_drive_t *);
49419  extern int probe_hwif_init(ide_hwif_t *);
49420  
49421  static inline void *ide_get_hwifdata (ide_hwif_t * hwif)
49422 @@ -1793,6 +1777,24 @@
49423  extern char *ide_xfer_verbose(u8 xfer_rate);
49424  extern void ide_toggle_bounce(ide_drive_t *drive, int on);
49425  extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);
49426 +
49427 +typedef struct ide_pio_timings_s {
49428 +       int     setup_time;     /* Address setup (ns) minimum */
49429 +       int     active_time;    /* Active pulse (ns) minimum */
49430 +       int     cycle_time;     /* Cycle time (ns) minimum = (setup + active + recovery) */
49431 +} ide_pio_timings_t;
49432 +
49433 +typedef struct ide_pio_data_s {
49434 +       u8 pio_mode;
49435 +       u8 use_iordy;
49436 +       u8 overridden;
49437 +       u8 blacklisted;
49438 +       unsigned int cycle_time;
49439 +} ide_pio_data_t;
49440 +
49441 +extern u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode, ide_pio_data_t *d);
49442 +extern const ide_pio_timings_t ide_pio_timings[6];
49443 +
49444  
49445  extern spinlock_t ide_lock;
49446  extern struct semaphore ide_cfg_sem;
49447 diff -Nru a/include/linux/ipv6_route.h b/include/linux/ipv6_route.h
49448 --- a/include/linux/ipv6_route.h        Wed Jul 23 02:57:57 2003
49449 +++ b/include/linux/ipv6_route.h        Sat Aug 30 21:26:12 2003
49450 @@ -24,6 +24,7 @@
49451  #define RTF_CACHE      0x01000000      /* cache entry                  */
49452  #define RTF_FLOW       0x02000000      /* flow significant route       */
49453  #define RTF_POLICY     0x04000000      /* policy route                 */
49454 +#define RTF_NDISC      0x08000000      /* ndisc route                  */
49455  
49456  #define RTF_LOCAL      0x80000000
49457  
49458 diff -Nru a/include/linux/kdev_t.h b/include/linux/kdev_t.h
49459 --- a/include/linux/kdev_t.h    Fri Aug  1 02:22:20 2003
49460 +++ b/include/linux/kdev_t.h    Tue Aug 26 09:25:39 2003
49461 @@ -90,22 +90,7 @@
49462         return dev.value;
49463  }
49464  
49465 -static inline kdev_t val_to_kdev(unsigned int val)
49466 -{
49467 -       kdev_t dev;
49468 -       dev.value = val;
49469 -       return dev;
49470 -}
49471 -
49472 -#define HASHDEV(dev)   (kdev_val(dev))
49473  #define NODEV          (mk_kdev(0,0))
49474 -
49475 -static inline int kdev_same(kdev_t dev1, kdev_t dev2)
49476 -{
49477 -       return dev1.value == dev2.value;
49478 -}
49479 -
49480 -#define kdev_none(d1)  (!kdev_val(d1))
49481  
49482  /* Mask off the high bits for now.. */
49483  #define minor(dev)     ((dev).value & 0xff)
49484 diff -Nru a/include/linux/mmzone.h b/include/linux/mmzone.h
49485 --- a/include/linux/mmzone.h    Fri Aug  1 03:02:10 2003
49486 +++ b/include/linux/mmzone.h    Sun Aug 31 16:14:47 2003
49487 @@ -89,17 +89,24 @@
49488  
49489         ZONE_PADDING(_pad2_)
49490  
49491 -       /*
49492 -        * measure of scanning intensity for this zone. It is calculated
49493 -        * as exponentially decaying average of the scanning priority
49494 -        * required to free enough pages in this zone
49495 -        * (zone_adj_pressure()).
49496 +       /*
49497 +        * prev_priority holds the scanning priority for this zone.  It is
49498 +        * defined as the scanning priority at which we achieved our reclaim
49499 +        * target at the previous try_to_free_pages() or balance_pgdat()
49500 +        * invokation.
49501          *
49502 -        *     0                    --- low pressure
49503 +        * We use prev_priority as a measure of how much stress page reclaim is
49504 +        * under - it drives the swappiness decision: whether to unmap mapped
49505 +        * pages.
49506          *
49507 -        *     (DEF_PRIORITY << 10) --- high pressure
49508 +        * temp_priority is used to remember the scanning priority at which
49509 +        * this zone was successfully refilled to free_pages == pages_high.
49510 +        *
49511 +        * Access to both these fields is quite racy even on uniprocessor.  But
49512 +        * it is expected to average out OK.
49513          */
49514 -       int pressure;
49515 +       int temp_priority;
49516 +       int prev_priority;
49517  
49518         /*
49519          * free areas of different sizes
49520 diff -Nru a/include/linux/netdevice.h b/include/linux/netdevice.h
49521 --- a/include/linux/netdevice.h Tue Aug 19 21:01:19 2003
49522 +++ b/include/linux/netdevice.h Mon Sep  1 12:14:20 2003
49523 @@ -168,9 +168,9 @@
49524         unsigned fastroute_deferred_out;
49525         unsigned fastroute_latency_reduction;
49526         unsigned cpu_collision;
49527 -} ____cacheline_aligned;
49528 +};
49529  
49530 -extern struct netif_rx_stats netdev_rx_stat[];
49531 +DECLARE_PER_CPU(struct netif_rx_stats, netdev_rx_stat);
49532  
49533  
49534  /*
49535 @@ -830,6 +830,38 @@
49536         smp_mb__before_clear_bit();
49537         clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
49538         local_irq_restore(flags);
49539 +}
49540 +
49541 +static inline void netif_poll_disable(struct net_device *dev)
49542 +{
49543 +       while (test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state)) {
49544 +               /* No hurry. */
49545 +               current->state = TASK_INTERRUPTIBLE;
49546 +               schedule_timeout(1);
49547 +       }
49548 +}
49549 +
49550 +static inline void netif_poll_enable(struct net_device *dev)
49551 +{
49552 +       clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
49553 +}
49554 +
49555 +/* same as netif_rx_complete, except that local_irq_save(flags)
49556 + * has already been issued
49557 + */
49558 +static inline void __netif_rx_complete(struct net_device *dev)
49559 +{
49560 +       if (!test_bit(__LINK_STATE_RX_SCHED, &dev->state)) BUG();
49561 +       list_del(&dev->poll_list);
49562 +       smp_mb__before_clear_bit();
49563 +       clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
49564 +}
49565 +
49566 +static inline void netif_tx_disable(struct net_device *dev)
49567 +{
49568 +       spin_lock_bh(&dev->xmit_lock);
49569 +       netif_stop_queue(dev);
49570 +       spin_unlock_bh(&dev->xmit_lock);
49571  }
49572  
49573  /* These functions live elsewhere (drivers/net/net_init.c, but related) */
49574 diff -Nru a/include/linux/netfilter_bridge/ebt_802_3.h b/include/linux/netfilter_bridge/ebt_802_3.h
49575 --- /dev/null   Wed Dec 31 16:00:00 1969
49576 +++ b/include/linux/netfilter_bridge/ebt_802_3.h        Sat Aug 30 20:40:29 2003
49577 @@ -0,0 +1,60 @@
49578 +#ifndef __LINUX_BRIDGE_EBT_802_3_H
49579 +#define __LINUX_BRIDGE_EBT_802_3_H
49580 +
49581 +#define EBT_802_3_SAP 0x01
49582 +#define EBT_802_3_TYPE 0x02
49583 +
49584 +#define EBT_802_3_MATCH "802_3"
49585 +
49586 +/*
49587 + * If frame has DSAP/SSAP value 0xaa you must check the SNAP type
49588 + * to discover what kind of packet we're carrying. 
49589 + */
49590 +#define CHECK_TYPE 0xaa
49591 +
49592 +/*
49593 + * Control field may be one or two bytes.  If the first byte has
49594 + * the value 0x03 then the entire length is one byte, otherwise it is two.
49595 + * One byte controls are used in Unnumbered Information frames.
49596 + * Two byte controls are used in Numbered Information frames.
49597 + */
49598 +#define IS_UI 0x03
49599 +
49600 +#define EBT_802_3_MASK (EBT_802_3_SAP | EBT_802_3_TYPE | EBT_802_3)
49601 +
49602 +/* ui has one byte ctrl, ni has two */
49603 +struct hdr_ui {
49604 +       uint8_t dsap;
49605 +       uint8_t ssap;
49606 +       uint8_t ctrl;
49607 +       uint8_t orig[3];
49608 +       uint16_t type;
49609 +};
49610 +
49611 +struct hdr_ni {
49612 +       uint8_t dsap;
49613 +       uint8_t ssap;
49614 +       uint16_t ctrl;
49615 +       uint8_t  orig[3];
49616 +       uint16_t type;
49617 +};
49618 +
49619 +struct ebt_802_3_hdr {
49620 +       uint8_t  daddr[6];
49621 +       uint8_t  saddr[6];
49622 +       uint16_t len;
49623 +       union {
49624 +               struct hdr_ui ui;
49625 +               struct hdr_ni ni;
49626 +       } llc;
49627 +};
49628 +
49629 +struct ebt_802_3_info 
49630 +{
49631 +       uint8_t  sap;
49632 +       uint16_t type;
49633 +       uint8_t  bitmask;
49634 +       uint8_t  invflags;
49635 +};
49636 +
49637 +#endif
49638 diff -Nru a/include/linux/netfilter_bridge/ebt_arpreply.h b/include/linux/netfilter_bridge/ebt_arpreply.h
49639 --- /dev/null   Wed Dec 31 16:00:00 1969
49640 +++ b/include/linux/netfilter_bridge/ebt_arpreply.h     Sun Aug 24 04:31:45 2003
49641 @@ -0,0 +1,11 @@
49642 +#ifndef __LINUX_BRIDGE_EBT_ARPREPLY_H
49643 +#define __LINUX_BRIDGE_EBT_ARPREPLY_H
49644 +
49645 +struct ebt_arpreply_info
49646 +{
49647 +       unsigned char mac[ETH_ALEN];
49648 +       int target;
49649 +};
49650 +#define EBT_ARPREPLY_TARGET "arpreply"
49651 +
49652 +#endif
49653 diff -Nru a/include/linux/netfilter_bridge.h b/include/linux/netfilter_bridge.h
49654 --- a/include/linux/netfilter_bridge.h  Sun Apr 27 18:39:57 2003
49655 +++ b/include/linux/netfilter_bridge.h  Mon Sep  1 01:44:26 2003
49656 @@ -6,7 +6,7 @@
49657  
49658  #include <linux/config.h>
49659  #include <linux/netfilter.h>
49660 -#if defined(__KERNEL__) && defined(CONFIG_NETFILTER)
49661 +#if defined(__KERNEL__) && defined(CONFIG_BRIDGE_NETFILTER)
49662  #include <asm/atomic.h>
49663  #endif
49664  
49665 @@ -27,11 +27,6 @@
49666  
49667  #ifdef __KERNEL__
49668  
49669 -#define BRNF_PKT_TYPE                  0x01
49670 -#define BRNF_BRIDGED_DNAT              0x02
49671 -#define BRNF_DONT_TAKE_PARENT          0x04
49672 -#define BRNF_BRIDGED                   0x08
49673 -
49674  enum nf_br_hook_priorities {
49675         NF_BR_PRI_FIRST = INT_MIN,
49676         NF_BR_PRI_NAT_DST_BRIDGED = -300,
49677 @@ -43,7 +38,13 @@
49678         NF_BR_PRI_LAST = INT_MAX,
49679  };
49680  
49681 -#ifdef CONFIG_NETFILTER
49682 +#ifdef CONFIG_BRIDGE_NETFILTER
49683 +
49684 +#define BRNF_PKT_TYPE                  0x01
49685 +#define BRNF_BRIDGED_DNAT              0x02
49686 +#define BRNF_DONT_TAKE_PARENT          0x04
49687 +#define BRNF_BRIDGED                   0x08
49688 +
49689  static inline
49690  struct nf_bridge_info *nf_bridge_alloc(struct sk_buff *skb)
49691  {
49692 @@ -63,7 +64,7 @@
49693                 __u32 ipv4;
49694         } daddr;
49695  };
49696 -#endif /* CONFIG_NETFILTER */
49697 +#endif /* CONFIG_BRIDGE_NETFILTER */
49698  
49699  #endif /* __KERNEL__ */
49700  #endif
49701 diff -Nru a/include/linux/netfilter_ipv4/ipt_CLASSIFY.h b/include/linux/netfilter_ipv4/ipt_CLASSIFY.h
49702 --- /dev/null   Wed Dec 31 16:00:00 1969
49703 +++ b/include/linux/netfilter_ipv4/ipt_CLASSIFY.h       Sun Aug 24 17:25:17 2003
49704 @@ -0,0 +1,8 @@
49705 +#ifndef _IPT_CLASSIFY_H
49706 +#define _IPT_CLASSIFY_H
49707 +
49708 +struct ipt_classify_target_info {
49709 +       u_int32_t priority;
49710 +};
49711 +
49712 +#endif /*_IPT_CLASSIFY_H */
49713 diff -Nru a/include/linux/netfilter_ipv4/ipt_SAME.h b/include/linux/netfilter_ipv4/ipt_SAME.h
49714 --- /dev/null   Wed Dec 31 16:00:00 1969
49715 +++ b/include/linux/netfilter_ipv4/ipt_SAME.h   Sun Aug 24 17:25:18 2003
49716 @@ -0,0 +1,19 @@
49717 +#ifndef _IPT_SAME_H
49718 +#define _IPT_SAME_H
49719 +
49720 +#define IPT_SAME_MAX_RANGE     10
49721 +
49722 +#define IPT_SAME_NODST         0x01
49723 +
49724 +struct ipt_same_info
49725 +{
49726 +       unsigned char info;
49727 +       u_int32_t rangesize;
49728 +       u_int32_t ipnum;
49729 +       u_int32_t *iparray;
49730 +
49731 +       /* hangs off end. */
49732 +       struct ip_nat_range range[IPT_SAME_MAX_RANGE];
49733 +};
49734 +
49735 +#endif /*_IPT_SAME_H*/
49736 diff -Nru a/include/linux/netfilter_ipv4/ipt_iprange.h b/include/linux/netfilter_ipv4/ipt_iprange.h
49737 --- /dev/null   Wed Dec 31 16:00:00 1969
49738 +++ b/include/linux/netfilter_ipv4/ipt_iprange.h        Sun Aug 24 17:25:18 2003
49739 @@ -0,0 +1,23 @@
49740 +#ifndef _IPT_IPRANGE_H
49741 +#define _IPT_IPRANGE_H
49742 +
49743 +#define IPRANGE_SRC            0x01    /* Match source IP address */
49744 +#define IPRANGE_DST            0x02    /* Match destination IP address */
49745 +#define IPRANGE_SRC_INV                0x10    /* Negate the condition */
49746 +#define IPRANGE_DST_INV                0x20    /* Negate the condition */
49747 +
49748 +struct ipt_iprange {
49749 +       /* Inclusive: network order. */
49750 +       u_int32_t min_ip, max_ip;
49751 +};
49752 +
49753 +struct ipt_iprange_info
49754 +{
49755 +       struct ipt_iprange src;
49756 +       struct ipt_iprange dst;
49757 +
49758 +       /* Flags from above */
49759 +       u_int8_t flags;
49760 +};
49761 +
49762 +#endif /* _IPT_IPRANGE_H */
49763 diff -Nru a/include/linux/nfsd/nfsfh.h b/include/linux/nfsd/nfsfh.h
49764 --- a/include/linux/nfsd/nfsfh.h        Mon Feb 17 13:50:11 2003
49765 +++ b/include/linux/nfsd/nfsfh.h        Tue Aug 26 09:25:41 2003
49766 @@ -294,8 +294,8 @@
49767                 /* how much do we care for accuracy with MinixFS? */
49768                 fhp->fh_post_blocks     = (inode->i_size+511) >> 9;
49769         }
49770 -       fhp->fh_post_rdev[0]    = htonl((u32)major(inode->i_rdev));
49771 -       fhp->fh_post_rdev[1]    = htonl((u32)minor(inode->i_rdev));
49772 +       fhp->fh_post_rdev[0]    = htonl((u32)imajor(inode));
49773 +       fhp->fh_post_rdev[1]    = htonl((u32)iminor(inode));
49774         fhp->fh_post_atime      = inode->i_atime;
49775         fhp->fh_post_mtime      = inode->i_mtime;
49776         fhp->fh_post_ctime      = inode->i_ctime;
49777 diff -Nru a/include/linux/nfsd/state.h b/include/linux/nfsd/state.h
49778 --- a/include/linux/nfsd/state.h        Thu Jun 26 21:26:02 2003
49779 +++ b/include/linux/nfsd/state.h        Sat Aug 23 15:07:31 2003
49780 @@ -113,21 +113,15 @@
49781         int                     so_confirmed; /* successful OPEN_CONFIRM? */
49782  };
49783  
49784 -typedef struct {
49785 -       u32                     dev; /* super_block->s_dev */
49786 -       unsigned long           ino;
49787 -       u32                     generation;
49788 -} nfs4_ino_desc_t;
49789 -
49790  /*
49791  *  nfs4_file: a file opened by some number of (open) nfs4_stateowners.
49792  *    o fi_perfile list is used to search for conflicting 
49793  *      share_acces, share_deny on the file.
49794  */
49795  struct nfs4_file {
49796 -       struct list_head        fi_hash;    /* hash by nfs4_ino_desc_t fields */
49797 +       struct list_head        fi_hash;    /* hash by "struct inode *" */
49798         struct list_head        fi_perfile; /* list: nfs4_stateid */
49799 -       nfs4_ino_desc_t         fi_ino;
49800 +       struct inode            *fi_inode;
49801         u32                     fi_id;      /* used with stateowner->so_id 
49802                                              * for openstateid_hashtbl hash */
49803  };
49804 diff -Nru a/include/linux/pci_ids.h b/include/linux/pci_ids.h
49805 --- a/include/linux/pci_ids.h   Wed Aug 20 14:33:08 2003
49806 +++ b/include/linux/pci_ids.h   Mon Sep  1 17:32:02 2003
49807 @@ -798,6 +798,7 @@
49808  #define PCI_DEVICE_ID_APPLE_UNI_N_FW2  0x0030
49809  #define PCI_DEVICE_ID_APPLE_UNI_N_GMAC2        0x0032
49810  #define PCI_DEVICE_ID_APPLE_UNI_N_AGP2 0x0034
49811 +#define PCI_DEVICE_ID_APPLE_KAUAI_ATA  0x003b
49812  #define PCI_DEVICE_ID_APPLE_KEYLARGO_I 0x003e
49813  #define PCI_DEVICE_ID_APPLE_TIGON3     0x1645
49814  
49815 @@ -1115,7 +1116,9 @@
49816  #define PCI_DEVICE_ID_TTI_HPT374       0x0008
49817  
49818  #define PCI_VENDOR_ID_VIA              0x1106
49819 -#define PCI_DEVICE_ID_VIA_P4X600       0x0198
49820 +#define PCI_DEVICE_ID_VIA_8763_0       0x0198
49821 +#define PCI_DEVICE_ID_VIA_8380_0       0x0204
49822 +#define PCI_DEVICE_ID_VIA_PX8X0_0      0x0259
49823  #define PCI_DEVICE_ID_VIA_8363_0       0x0305 
49824  #define PCI_DEVICE_ID_VIA_8371_0       0x0391
49825  #define PCI_DEVICE_ID_VIA_8501_0       0x0501
49826 @@ -1130,10 +1133,10 @@
49827  #define PCI_DEVICE_ID_VIA_82C597_0     0x0597
49828  #define PCI_DEVICE_ID_VIA_82C598_0     0x0598
49829  #define PCI_DEVICE_ID_VIA_8601_0       0x0601
49830 -#define PCI_DEVICE_ID_VIA_82C694X_0    0x0605
49831 +#define PCI_DEVICE_ID_VIA_8605_0       0x0605
49832  #define PCI_DEVICE_ID_VIA_82C680       0x0680
49833  #define PCI_DEVICE_ID_VIA_82C686       0x0686
49834 -#define PCI_DEVICE_ID_VIA_82C691       0x0691
49835 +#define PCI_DEVICE_ID_VIA_82C691_0     0x0691
49836  #define PCI_DEVICE_ID_VIA_82C693       0x0693
49837  #define PCI_DEVICE_ID_VIA_82C693_1     0x0698
49838  #define PCI_DEVICE_ID_VIA_82C926       0x0926
49839 @@ -1156,19 +1159,21 @@
49840  #define PCI_DEVICE_ID_VIA_8622         0x3102 
49841  #define PCI_DEVICE_ID_VIA_8233C_0      0x3109
49842  #define PCI_DEVICE_ID_VIA_8361         0x3112
49843 -#define PCI_DEVICE_ID_VIA_KM266                0x3116
49844 -#define PCI_DEVICE_ID_VIA_CLE266       0x3123
49845 +#define PCI_DEVICE_ID_VIA_XM266                0x3116
49846 +#define PCI_DEVICE_ID_VIA_862X_0       0x3123
49847  #define PCI_DEVICE_ID_VIA_8753_0       0x3128
49848  #define PCI_DEVICE_ID_VIA_8233A                0x3147
49849 -#define PCI_DEVICE_ID_VIA_8752         0x3148
49850 +#define PCI_DEVICE_ID_VIA_8703_51_0    0x3148
49851  #define PCI_DEVICE_ID_VIA_8237_SATA    0x3149
49852 -#define PCI_DEVICE_ID_VIA_KN266                0x3156
49853 -#define PCI_DEVICE_ID_VIA_8754         0x3168
49854 +#define PCI_DEVICE_ID_VIA_XN266                0x3156
49855 +#define PCI_DEVICE_ID_VIA_8754C_0      0x3168
49856  #define PCI_DEVICE_ID_VIA_8235         0x3177
49857  #define PCI_DEVICE_ID_VIA_P4N333       0x3178
49858 -#define PCI_DEVICE_ID_VIA_K8T400M_0    0x3188
49859 +#define PCI_DEVICE_ID_VIA_8385_0       0x3188
49860  #define PCI_DEVICE_ID_VIA_8377_0       0x3189
49861 -#define PCI_DEVICE_ID_VIA_KM400                0x3205
49862 +#define PCI_DEVICE_ID_VIA_8378_0       0x3205
49863 +#define PCI_DEVICE_ID_VIA_8783_0       0x3208
49864 +#define PCI_DEVICE_ID_VIA_PT880                0x3258
49865  #define PCI_DEVICE_ID_VIA_P4M400       0x3209
49866  #define PCI_DEVICE_ID_VIA_8237         0x3227
49867  #define PCI_DEVICE_ID_VIA_86C100A      0x6100
49868 @@ -1183,7 +1188,12 @@
49869  #define PCI_DEVICE_ID_VIA_8505_1       0x8605
49870  #define PCI_DEVICE_ID_VIA_8633_1       0xB091
49871  #define PCI_DEVICE_ID_VIA_8367_1       0xB099
49872 -#define PCI_DEVICE_ID_VIA_8653_1       0xB101
49873 +#define PCI_DEVICE_ID_VIA_P4X266_1     0xB101
49874 +#define PCI_DEVICE_ID_VIA_8615_1       0xB103
49875 +#define PCI_DEVICE_ID_VIA_8361_1       0xB112
49876 +#define PCI_DEVICE_ID_VIA_8235_1       0xB168
49877 +#define PCI_DEVICE_ID_VIA_838X_1       0xB188
49878 +#define PCI_DEVICE_ID_VIA_83_87XX_1    0xB198
49879  
49880  #define PCI_VENDOR_ID_SIEMENS           0x110A
49881  #define PCI_DEVICE_ID_SIEMENS_DSCC4     0x2102
49882 @@ -1274,6 +1284,9 @@
49883  #define PCI_DEVICE_ID_SYSKONNECT_FP    0x4000
49884  #define PCI_DEVICE_ID_SYSKONNECT_TR    0x4200
49885  #define PCI_DEVICE_ID_SYSKONNECT_GE    0x4300
49886 +#define PCI_DEVICE_ID_SYSKONNECT_YU    0x4320
49887 +#define PCI_DEVICE_ID_SYSKONNECT_9DXX  0x4400
49888 +#define PCI_DEVICE_ID_SYSKONNECT_9MXX  0x4500
49889  
49890  #define PCI_VENDOR_ID_VMIC             0x114a
49891  #define PCI_DEVICE_ID_VMIC_VME         0x7587
49892 @@ -1332,7 +1345,10 @@
49893  #define PCI_VENDOR_ID_TOSHIBA          0x1179
49894  #define PCI_DEVICE_ID_TOSHIBA_601      0x0601
49895  #define PCI_DEVICE_ID_TOSHIBA_TOPIC95  0x060a
49896 +#define PCI_DEVICE_ID_TOSHIBA_TOPIC95_A 0x0603
49897 +#define PCI_DEVICE_ID_TOSHIBA_TOPIC95_B 0x060a
49898  #define PCI_DEVICE_ID_TOSHIBA_TOPIC97  0x060f
49899 +#define PCI_DEVICE_ID_TOSHIBA_TOPIC100 0x0617
49900  
49901  #define PCI_VENDOR_ID_TOSHIBA_2                0x102f
49902  #define PCI_DEVICE_ID_TOSHIBA_TX3927   0x000a
49903 @@ -1758,11 +1774,19 @@
49904  #define PCI_DEVICE_ID_TIGON3_5703      0x1647
49905  #define PCI_DEVICE_ID_TIGON3_5704      0x1648
49906  #define PCI_DEVICE_ID_TIGON3_5702FE    0x164d
49907 +#define PCI_DEVICE_ID_TIGON3_5705      0x1653
49908 +#define PCI_DEVICE_ID_TIGON3_5705_2    0x1654
49909 +#define PCI_DEVICE_ID_TIGON3_5705M     0x165d
49910 +#define PCI_DEVICE_ID_TIGON3_5705M_2   0x165e
49911 +#define PCI_DEVICE_ID_TIGON3_5782      0x1696
49912 +#define PCI_DEVICE_ID_TIGON3_5788      0x169c
49913  #define PCI_DEVICE_ID_TIGON3_5702X     0x16a6
49914  #define PCI_DEVICE_ID_TIGON3_5703X     0x16a7
49915  #define PCI_DEVICE_ID_TIGON3_5704S     0x16a8
49916  #define PCI_DEVICE_ID_TIGON3_5702A3    0x16c6
49917  #define PCI_DEVICE_ID_TIGON3_5703A3    0x16c7
49918 +#define PCI_DEVICE_ID_TIGON3_5901      0x170d
49919 +#define PCI_DEVICE_ID_TIGON3_5901_2    0x170e
49920  #define PCI_DEVICE_ID_BCM4401          0x4401
49921  
49922  #define PCI_VENDOR_ID_SYBA             0x1592
49923 @@ -1790,6 +1814,7 @@
49924  #define PCI_DEVICE_ID_ALTIMA_AC1000    0x03e8
49925  #define PCI_DEVICE_ID_ALTIMA_AC1001    0x03e9
49926  #define PCI_DEVICE_ID_ALTIMA_AC9100    0x03ea
49927 +#define PCI_DEVICE_ID_ALTIMA_AC1003    0x03eb
49928  
49929  #define PCI_VENDOR_ID_SYMPHONY         0x1c1c
49930  #define PCI_DEVICE_ID_SYMPHONY_101     0x0001
49931 diff -Nru a/include/linux/personality.h b/include/linux/personality.h
49932 --- a/include/linux/personality.h       Sun Dec 29 15:44:39 2002
49933 +++ b/include/linux/personality.h       Sun Aug 31 16:13:59 2003
49934 @@ -34,6 +34,7 @@
49935         SHORT_INODE =           0x1000000,
49936         WHOLE_SECONDS =         0x2000000,
49937         STICKY_TIMEOUTS =       0x4000000,
49938 +       ADDR_LIMIT_3GB =        0x8000000,
49939  };
49940  
49941  /*
49942 @@ -56,6 +57,7 @@
49943         PER_SUNOS =             0x0006 | STICKY_TIMEOUTS,
49944         PER_XENIX =             0x0007 | STICKY_TIMEOUTS | SHORT_INODE,
49945         PER_LINUX32 =           0x0008,
49946 +       PER_LINUX32_3GB =       0x0008 | ADDR_LIMIT_3GB,
49947         PER_IRIX32 =            0x0009 | STICKY_TIMEOUTS,/* IRIX5 32-bit */
49948         PER_IRIXN32 =           0x000a | STICKY_TIMEOUTS,/* IRIX6 new 32-bit */
49949         PER_IRIX64 =            0x000b | STICKY_TIMEOUTS,/* IRIX6 64-bit */
49950 diff -Nru a/include/linux/pmu.h b/include/linux/pmu.h
49951 --- a/include/linux/pmu.h       Sun Feb  2 13:51:33 2003
49952 +++ b/include/linux/pmu.h       Mon Aug 25 10:06:34 2003
49953 @@ -33,6 +33,7 @@
49954  #define PMU_CPU_SPEED          0x7d    /* control CPU speed on some models */
49955  #define PMU_SLEEP              0x7f    /* put CPU to sleep */
49956  #define PMU_POWER_EVENTS       0x8f    /* Send power-event commands to PMU */
49957 +#define PMU_I2C_CMD            0x9a    /* I2C operations */
49958  #define PMU_RESET              0xd0    /* reset CPU */
49959  #define PMU_GET_BRIGHTBUTTON   0xd9    /* report brightness up/down pos */
49960  #define PMU_GET_COVER          0xdc    /* report cover open/closed */
49961 @@ -69,6 +70,20 @@
49962   * or via PMU_INT_ENVIRONMENT on core99 */
49963  #define PMU_ENV_LID_CLOSED     0x01    /* The lid is closed */
49964  
49965 +/* I2C related definitions */
49966 +#define PMU_I2C_MODE_SIMPLE    0
49967 +#define PMU_I2C_MODE_STDSUB    1
49968 +#define PMU_I2C_MODE_COMBINED  2
49969 +
49970 +#define PMU_I2C_BUS_STATUS     0
49971 +#define PMU_I2C_BUS_SYSCLK     1
49972 +#define PMU_I2C_BUS_POWER      2
49973 +
49974 +#define PMU_I2C_STATUS_OK      0
49975 +#define PMU_I2C_STATUS_DATAREAD        1
49976 +#define PMU_I2C_STATUS_BUSY    0xfe
49977 +
49978 +
49979  /* Kind of PMU (model) */
49980  enum {
49981         PMU_UNKNOWN,
49982 @@ -127,6 +142,8 @@
49983                 void (*done)(struct adb_request *), int nbytes, ...);
49984  
49985  extern void pmu_poll(void);
49986 +extern void pmu_poll_adb(void); /* For use by xmon */
49987 +extern void pmu_wait_complete(struct adb_request *req);
49988  
49989  /* For use before switching interrupts off for a long time;
49990   * warning: not stackable
49991 @@ -138,9 +155,16 @@
49992  
49993  extern void pmu_restart(void);
49994  extern void pmu_shutdown(void);
49995 +extern void pmu_unlock(void);
49996  
49997  extern int pmu_present(void);
49998  extern int pmu_get_model(void);
49999 +
50000 +extern int pmu_i2c_combined_read(int bus, int addr, int subaddr,  u8* data, int len);
50001 +extern int pmu_i2c_stdsub_write(int bus, int addr, int subaddr,  u8* data, int len);
50002 +extern int pmu_i2c_simple_read(int bus, int addr,  u8* data, int len);
50003 +extern int pmu_i2c_simple_write(int bus, int addr,  u8* data, int len);
50004 +
50005  
50006  #ifdef CONFIG_PMAC_PBOOK
50007  /*
50008 diff -Nru a/include/linux/proc_fs.h b/include/linux/proc_fs.h
50009 --- a/include/linux/proc_fs.h   Thu Jul 10 22:22:53 2003
50010 +++ b/include/linux/proc_fs.h   Sun Aug 31 16:14:22 2003
50011 @@ -182,12 +182,6 @@
50012         remove_proc_entry(name,proc_net);
50013  }
50014  
50015 -/*
50016 - * fs/proc/kcore.c
50017 - */
50018 -extern void kclist_add(struct kcore_list *, void *, size_t);
50019 -extern struct kcore_list *kclist_del(void *);
50020 -
50021  #else
50022  
50023  #define proc_root_driver NULL
50024 @@ -223,6 +217,9 @@
50025  
50026  extern struct proc_dir_entry proc_root;
50027  
50028 +#endif /* CONFIG_PROC_FS */
50029 +
50030 +#if !defined(CONFIG_PROC_FS)
50031  static inline void kclist_add(struct kcore_list *new, void *addr, size_t size)
50032  {
50033  }
50034 @@ -230,8 +227,10 @@
50035  {
50036         return NULL;
50037  }
50038 -
50039 -#endif /* CONFIG_PROC_FS */
50040 +#else
50041 +extern void kclist_add(struct kcore_list *, void *, size_t);
50042 +extern struct kcore_list *kclist_del(void *);
50043 +#endif
50044  
50045  struct proc_inode {
50046         struct task_struct *task;
50047 diff -Nru a/include/linux/sched.h b/include/linux/sched.h
50048 --- a/include/linux/sched.h     Wed Aug 20 22:32:07 2003
50049 +++ b/include/linux/sched.h     Sun Aug 31 16:14:26 2003
50050 @@ -391,6 +391,7 @@
50051         struct timer_list real_timer;
50052         struct list_head posix_timers; /* POSIX.1b Interval Timers */
50053         unsigned long utime, stime, cutime, cstime;
50054 +       unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; /* context switch counts */
50055         u64 start_time;
50056  /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
50057         unsigned long min_flt, maj_flt, nswap, cmin_flt, cmaj_flt, cnswap;
50058 diff -Nru a/include/linux/serial_core.h b/include/linux/serial_core.h
50059 --- a/include/linux/serial_core.h       Wed Jul 16 01:49:46 2003
50060 +++ b/include/linux/serial_core.h       Sun Aug 24 08:17:18 2003
50061 @@ -67,6 +67,9 @@
50062  #define PORT_PC9861    45
50063  #define PORT_PC9801_101        46
50064  
50065 +/* Macintosh Zilog type numbers */
50066 +#define PORT_MAC_ZILOG 50      /* m68k : not yet implemented */
50067 +#define PORT_PMAC_ZILOG        51
50068  
50069  #ifdef __KERNEL__
50070  
50071 diff -Nru a/include/linux/skbuff.h b/include/linux/skbuff.h
50072 --- a/include/linux/skbuff.h    Thu Aug  7 14:30:45 2003
50073 +++ b/include/linux/skbuff.h    Mon Sep  1 01:44:26 2003
50074 @@ -98,7 +98,7 @@
50075         struct nf_conntrack *master;
50076  };
50077  
50078 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
50079 +#ifdef CONFIG_BRIDGE_NETFILTER
50080  struct nf_bridge_info {
50081         atomic_t use;
50082         struct net_device *physindev;
50083 @@ -244,7 +244,7 @@
50084  #ifdef CONFIG_NETFILTER_DEBUG
50085          unsigned int           nf_debug;
50086  #endif
50087 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
50088 +#ifdef CONFIG_BRIDGE_NETFILTER
50089         struct nf_bridge_info   *nf_bridge;
50090  #endif
50091  #endif /* CONFIG_NETFILTER */
50092 @@ -1195,7 +1195,7 @@
50093                 atomic_inc(&nfct->master->use);
50094  }
50095  
50096 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
50097 +#ifdef CONFIG_BRIDGE_NETFILTER
50098  static inline void nf_bridge_put(struct nf_bridge_info *nf_bridge)
50099  {
50100         if (nf_bridge && atomic_dec_and_test(&nf_bridge->use))
50101 diff -Nru a/include/linux/sonypi.h b/include/linux/sonypi.h
50102 --- a/include/linux/sonypi.h    Tue Feb 18 03:32:56 2003
50103 +++ b/include/linux/sonypi.h    Fri Aug  1 05:36:45 2003
50104 @@ -94,6 +94,8 @@
50105  #define SONYPI_EVENT_MEMORYSTICK_INSERT                54
50106  #define SONYPI_EVENT_MEMORYSTICK_EJECT         55
50107  #define SONYPI_EVENT_ANYBUTTON_RELEASED                56
50108 +#define SONYPI_EVENT_BATTERY_INSERT            57
50109 +#define SONYPI_EVENT_BATTERY_REMOVE            58
50110  
50111  /* get/set brightness */
50112  #define SONYPI_IOCGBRT         _IOR('v', 0, __u8)
50113 diff -Nru a/include/linux/tpqic02.h b/include/linux/tpqic02.h
50114 --- a/include/linux/tpqic02.h   Mon May 12 20:10:40 2003
50115 +++ b/include/linux/tpqic02.h   Tue Aug 26 09:25:40 2003
50116 @@ -587,10 +587,10 @@
50117   *  |___________________ Reserved for diagnostics during debugging.
50118   */
50119  
50120 -#define        TP_REWCLOSE(d)  ((minor(d)&0x01) == 1)                  /* rewind bit */
50121 +#define        TP_REWCLOSE(d)  ((d)&1)                 /* rewind bit */
50122                            /* rewind is only done if data has been transferred */
50123 -#define        TP_DENS(dev)    ((minor(dev) >> 1) & 0x07)            /* tape density */
50124 -#define TP_UNIT(dev)   ((minor(dev) >> 4) & 0x07)             /* unit number */
50125 +#define        TP_DENS(d)      (((d) >> 1) & 0x07)           /* tape density */
50126 +#define TP_UNIT(d)     (((d) >> 4) & 0x07)            /* unit number */
50127  
50128  /* print excessive diagnostics */
50129  #define TP_DIAGS(dev)  (QIC02_TAPE_DEBUG & TPQD_DIAGS)
50130 diff -Nru a/include/linux/tty.h b/include/linux/tty.h
50131 --- a/include/linux/tty.h       Thu Jul 17 22:30:53 2003
50132 +++ b/include/linux/tty.h       Tue Aug 26 09:25:40 2003
50133 @@ -367,7 +367,7 @@
50134  extern int macserial_init(void);
50135  extern int a2232board_init(void);
50136  
50137 -extern int tty_paranoia_check(struct tty_struct *tty, kdev_t device,
50138 +extern int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
50139                               const char *routine);
50140  extern char *tty_name(struct tty_struct *tty, char *buf);
50141  extern void tty_wait_until_sent(struct tty_struct * tty, long timeout);
50142 diff -Nru a/include/linux/wait.h b/include/linux/wait.h
50143 --- a/include/linux/wait.h      Sun May 18 17:00:00 2003
50144 +++ b/include/linux/wait.h      Sun Aug 31 16:14:00 2003
50145 @@ -220,22 +220,6 @@
50146         __remove_wait_queue(q,  wait);
50147  }
50148  
50149 -#define add_wait_queue_cond(q, wait, cond) \
50150 -       ({                                                      \
50151 -               unsigned long flags;                            \
50152 -               int _raced = 0;                                 \
50153 -               spin_lock_irqsave(&(q)->lock, flags);   \
50154 -               (wait)->flags = 0;                              \
50155 -               __add_wait_queue((q), (wait));                  \
50156 -               rmb();                                          \
50157 -               if (!(cond)) {                                  \
50158 -                       _raced = 1;                             \
50159 -                       __remove_wait_queue((q), (wait));       \
50160 -               }                                               \
50161 -               spin_lock_irqrestore(&(q)->lock, flags);        \
50162 -               _raced;                                         \
50163 -       })
50164 -
50165  /*
50166   * These are the old interfaces to sleep waiting for an event.
50167   * They are racy.  DO NOT use them, use the wait_event* interfaces above.  
50168 diff -Nru a/include/net/ax25.h b/include/net/ax25.h
50169 --- a/include/net/ax25.h        Thu Aug 21 11:59:08 2003
50170 +++ b/include/net/ax25.h        Sun Aug 24 04:34:01 2003
50171 @@ -314,7 +314,7 @@
50172  /* ax25_route.c */
50173  extern void ax25_rt_device_down(struct net_device *);
50174  extern int  ax25_rt_ioctl(unsigned int, void *);
50175 -extern int  ax25_rt_get_info(char *, char **, off_t, int);
50176 +extern struct file_operations ax25_route_fops;
50177  extern int  ax25_rt_autobind(ax25_cb *, ax25_address *);
50178  extern ax25_route *ax25_rt_find_route(ax25_route *, ax25_address *,
50179         struct net_device *);
50180 @@ -373,7 +373,7 @@
50181  extern int  ax25_uid_policy;
50182  extern ax25_address *ax25_findbyuid(uid_t);
50183  extern int  ax25_uid_ioctl(int, struct sockaddr_ax25 *);
50184 -extern int  ax25_uid_get_info(char *, char **, off_t, int);
50185 +extern struct file_operations ax25_uid_fops;
50186  extern void ax25_uid_free(void);
50187  
50188  /* sysctl_net_ax25.c */
50189 diff -Nru a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h
50190 --- a/include/net/ip6_tunnel.h  Mon Jun  9 07:56:44 2003
50191 +++ b/include/net/ip6_tunnel.h  Mon Sep  1 01:55:01 2003
50192 @@ -25,6 +25,8 @@
50193         int recursion;          /* depth of hard_start_xmit recursion */
50194         struct ip6_tnl_parm parms;      /* tunnel configuration paramters */
50195         struct flowi fl;        /* flowi template for xmit */
50196 +       struct dst_entry *dst_cache;    /* cached dst */
50197 +       u32 dst_cookie;
50198  };
50199  
50200  /* Tunnel encapsulation limit destination sub-option */
50201 diff -Nru a/include/net/irda/vlsi_ir.h b/include/net/irda/vlsi_ir.h
50202 --- a/include/net/irda/vlsi_ir.h        Tue Jun 10 16:16:15 2003
50203 +++ b/include/net/irda/vlsi_ir.h        Sun Aug 24 04:45:26 2003
50204 @@ -3,7 +3,7 @@
50205   *
50206   *     vlsi_ir.h:      VLSI82C147 PCI IrDA controller driver for Linux
50207   *
50208 - *     Version:        0.4a
50209 + *     Version:        0.5
50210   *
50211   *     Copyright (c) 2001-2003 Martin Diehl
50212   *
50213 @@ -27,18 +27,71 @@
50214  #ifndef IRDA_VLSI_FIR_H
50215  #define IRDA_VLSI_FIR_H
50216  
50217 -/*
50218 - * #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,xx)
50219 - *
50220 - * missing pci-dma api call to give streaming dma buffer back to hw
50221 - * patch floating on lkml - probably present in 2.5.26 or later
50222 - * otherwise defining it as noop is ok, since the vlsi-ir is only
50223 - * used on two oldish x86-based notebooks which are cache-coherent
50224 +/* ================================================================
50225 + * compatibility stuff
50226   */
50227 -#define pci_dma_prep_single(dev, addr, size, direction)        /* nothing */
50228 -/*
50229 - * #endif
50230 +
50231 +/* definitions not present in pci_ids.h */
50232 +
50233 +#ifndef PCI_CLASS_WIRELESS_IRDA
50234 +#define PCI_CLASS_WIRELESS_IRDA                0x0d00
50235 +#endif
50236 +
50237 +#ifndef PCI_CLASS_SUBCLASS_MASK
50238 +#define PCI_CLASS_SUBCLASS_MASK                0xffff
50239 +#endif
50240 +
50241 +/* missing pci-dma api call to give streaming dma buffer back to hw
50242 + * patch was floating on lkml around 2.5.2x and might be present later.
50243 + * Defining it this way is ok, since the vlsi-ir is only
50244 + * used on two oldish x86-based notebooks which are cache-coherent
50245 + * (and flush_write_buffers also handles PPro errata and C3 OOstore)
50246   */
50247 +#ifdef CONFIG_X86
50248 +#include <asm-i386/io.h>
50249 +#define pci_dma_prep_single(dev, addr, size, direction)        flush_write_buffers()
50250 +#else
50251 +#error missing pci dma api call
50252 +#endif
50253 +
50254 +/* in recent 2.5 interrupt handlers have non-void return value */
50255 +#ifndef IRQ_RETVAL
50256 +typedef void irqreturn_t;
50257 +#define IRQ_NONE
50258 +#define IRQ_HANDLED
50259 +#define IRQ_RETVAL(x)
50260 +#endif
50261 +
50262 +/* some stuff need to check kernelversion. Not all 2.5 stuff was present
50263 + * in early 2.5.x - the test is merely to separate 2.4 from 2.5
50264 + */
50265 +#include <linux/version.h>
50266 +
50267 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
50268 +
50269 +/* PDE() introduced in 2.5.4 */
50270 +#ifdef CONFIG_PROC_FS
50271 +#define PDE(inode) ((inode)->u.generic_ip)
50272 +#endif
50273 +
50274 +/* irda crc16 calculation exported in 2.5.42 */
50275 +#define irda_calc_crc16(fcs,buf,len)   (GOOD_FCS)
50276 +
50277 +/* we use this for unified pci device name access */
50278 +#define PCIDEV_NAME(pdev)      ((pdev)->name)
50279 +
50280 +#else /* 2.5 or later */
50281 +
50282 +/* recent 2.5/2.6 stores pci device names at varying places ;-) */
50283 +#ifdef CONFIG_PCI_NAMES
50284 +/* human readable name */
50285 +#define PCIDEV_NAME(pdev)      ((pdev)->pretty_name)
50286 +#else
50287 +/* whatever we get from the associated struct device - bus:slot:dev.fn id */
50288 +#define PCIDEV_NAME(pdev)      (pci_name(pdev))
50289 +#endif
50290 +
50291 +#endif
50292  
50293  /* ================================================================ */
50294  
50295 @@ -138,7 +191,7 @@
50296   *     - IRMISC_UARTSEL configured
50297   *     - IRCFG_MASTER must be cleared
50298   *     - IRCFG_SIR must be set
50299 - *     - IRENABLE_IREN must be asserted 0->1 (and hence IRENABLE_SIR_ON)
50300 + *     - IRENABLE_PHYANDCLOCK must be asserted 0->1 (and hence IRENABLE_SIR_ON)
50301   */
50302  
50303  enum vlsi_pci_irmisc {
50304 @@ -298,7 +351,7 @@
50305  /* notes:
50306   *     - not more than one SIR/MIR/FIR bit must be set at any time
50307   *     - SIR, MIR, FIR and CRC16 select the configuration which will
50308 - *       be applied on next 0->1 transition of IRENABLE_IREN (see below).
50309 + *       be applied on next 0->1 transition of IRENABLE_PHYANDCLOCK (see below).
50310   *     - besides allowing the PCI interface to execute busmaster cycles
50311   *       and therefore the ring SM to operate, the MSTR bit has side-effects:
50312   *       when MSTR is cleared, the RINGPTR's get reset and the legacy UART mode
50313 @@ -349,7 +402,7 @@
50314   */
50315  
50316  enum vlsi_pio_irenable {
50317 -       IRENABLE_IREN           = 0x8000,  /* enable IR phy and gate the mode config (rw) */
50318 +       IRENABLE_PHYANDCLOCK    = 0x8000,  /* enable IR phy and gate the mode config (rw) */
50319         IRENABLE_CFGER          = 0x4000,  /* mode configuration error (ro) */
50320         IRENABLE_FIR_ON         = 0x2000,  /* FIR on status (ro) */
50321         IRENABLE_MIR_ON         = 0x1000,  /* MIR on status (ro) */
50322 @@ -366,7 +419,7 @@
50323  /* VLSI_PIO_PHYCTL: IR Physical Layer Current Control Register (u16, ro) */
50324  
50325  /* read-back of the currently applied physical layer status.
50326 - * applied from VLSI_PIO_NPHYCTL at rising edge of IRENABLE_IREN
50327 + * applied from VLSI_PIO_NPHYCTL at rising edge of IRENABLE_PHYANDCLOCK
50328   * contents identical to VLSI_PIO_NPHYCTL (see below)
50329   */
50330  
50331 @@ -374,7 +427,7 @@
50332  
50333  /* VLSI_PIO_NPHYCTL: IR Physical Layer Next Control Register (u16, rw) */
50334  
50335 -/* latched during IRENABLE_IREN=0 and applied at 0-1 transition
50336 +/* latched during IRENABLE_PHYANDCLOCK=0 and applied at 0-1 transition
50337   *
50338   * consists of BAUD[15:10], PLSWID[9:5] and PREAMB[4:0] bits defined as follows:
50339   *
50340 @@ -616,21 +669,22 @@
50341          */
50342  
50343         if ((a & ~DMA_MASK_MSTRPAGE)>>24 != MSTRPAGE_VALUE) {
50344 -               BUG();
50345 +               ERROR("%s: pci busaddr inconsistency!\n", __FUNCTION__);
50346 +               dump_stack();
50347                 return;
50348         }
50349  
50350         a &= DMA_MASK_MSTRPAGE;  /* clear highbyte to make sure we won't write
50351                                   * to status - just in case MSTRPAGE_VALUE!=0
50352                                   */
50353 -       rd->hw->rd_addr = a;
50354 +       rd->hw->rd_addr = cpu_to_le32(a);
50355         wmb();
50356         rd_set_status(rd, s);    /* may pass ownership to the hardware */
50357  }
50358  
50359  static inline void rd_set_count(struct ring_descr *rd, u16 c)
50360  {
50361 -       rd->hw->rd_count = c;
50362 +       rd->hw->rd_count = cpu_to_le16(c);
50363  }
50364  
50365  static inline u8 rd_get_status(struct ring_descr *rd)
50366 @@ -642,13 +696,13 @@
50367  {
50368         dma_addr_t      a;
50369  
50370 -       a = (rd->hw->rd_addr & DMA_MASK_MSTRPAGE) | (MSTRPAGE_VALUE << 24);
50371 -       return a;
50372 +       a = le32_to_cpu(rd->hw->rd_addr);
50373 +       return (a & DMA_MASK_MSTRPAGE) | (MSTRPAGE_VALUE << 24);
50374  }
50375  
50376  static inline u16 rd_get_count(struct ring_descr *rd)
50377  {
50378 -       return rd->hw->rd_count;
50379 +       return le16_to_cpu(rd->hw->rd_count);
50380  }
50381  
50382  /******************************************************************/
50383 diff -Nru a/init/main.c b/init/main.c
50384 --- a/init/main.c       Fri May  2 11:15:48 2003
50385 +++ b/init/main.c       Sun Aug 31 16:14:48 2003
50386 @@ -89,10 +89,6 @@
50387  extern void tc_init(void);
50388  #endif
50389  
50390 -#if defined(CONFIG_SYSVIPC)
50391 -extern void ipc_init(void);
50392 -#endif
50393 -
50394  /*
50395   * Are we up and running (ie do we have all the infrastructure
50396   * set up)
50397 @@ -106,6 +102,8 @@
50398  #define MAX_INIT_ENVS 8
50399  
50400  extern void time_init(void);
50401 +/* Default late time init is NULL. archs can override this later. */
50402 +void (*late_time_init)(void) = NULL;
50403  extern void softirq_init(void);
50404  
50405  int rows, cols;
50406 @@ -421,7 +419,6 @@
50407         console_init();
50408         profile_init();
50409         local_irq_enable();
50410 -       calibrate_delay();
50411  #ifdef CONFIG_BLK_DEV_INITRD
50412         if (initrd_start && !initrd_below_start_ok &&
50413                         initrd_start < min_low_pfn << PAGE_SHIFT) {
50414 @@ -433,6 +430,9 @@
50415         page_address_init();
50416         mem_init();
50417         kmem_cache_init();
50418 +       if (late_time_init)
50419 +               late_time_init();
50420 +       calibrate_delay();
50421         pidmap_init();
50422         pgtable_cache_init();
50423         pte_chain_init();
50424 @@ -448,9 +448,6 @@
50425         populate_rootfs();
50426  #ifdef CONFIG_PROC_FS
50427         proc_root_init();
50428 -#endif
50429 -#if defined(CONFIG_SYSVIPC)
50430 -       ipc_init();
50431  #endif
50432         check_bugs();
50433         printk("POSIX conformance testing by UNIFIX\n");
50434 diff -Nru a/ipc/msg.c b/ipc/msg.c
50435 --- a/ipc/msg.c Mon May 12 21:23:19 2003
50436 +++ b/ipc/msg.c Thu Aug 28 10:07:51 2003
50437 @@ -707,7 +707,7 @@
50438                 goto retry;
50439         }
50440  
50441 -       msq->q_lspid = current->pid;
50442 +       msq->q_lspid = current->tgid;
50443         msq->q_stime = get_seconds();
50444  
50445         if(!pipelined_send(msq,msg)) {
50446 @@ -801,7 +801,7 @@
50447                 list_del(&msg->m_list);
50448                 msq->q_qnum--;
50449                 msq->q_rtime = get_seconds();
50450 -               msq->q_lrpid = current->pid;
50451 +               msq->q_lrpid = current->tgid;
50452                 msq->q_cbytes -= msg->m_ts;
50453                 atomic_sub(msg->m_ts,&msg_bytes);
50454                 atomic_dec(&msg_hdrs);
50455 diff -Nru a/ipc/sem.c b/ipc/sem.c
50456 --- a/ipc/sem.c Sun Jul 13 08:55:51 2003
50457 +++ b/ipc/sem.c Thu Aug 28 10:08:09 2003
50458 @@ -664,7 +664,7 @@
50459                 for (un = sma->undo; un; un = un->id_next)
50460                         un->semadj[semnum] = 0;
50461                 curr->semval = val;
50462 -               curr->sempid = current->pid;
50463 +               curr->sempid = current->tgid;
50464                 sma->sem_ctime = get_seconds();
50465                 /* maybe some queued-up processes were waiting for this */
50466                 update_queue(sma);
50467 @@ -1052,7 +1052,7 @@
50468         if (error)
50469                 goto out_unlock_free;
50470  
50471 -       error = try_atomic_semop (sma, sops, nsops, un, current->pid);
50472 +       error = try_atomic_semop (sma, sops, nsops, un, current->tgid);
50473         if (error <= 0)
50474                 goto update;
50475  
50476 @@ -1064,7 +1064,7 @@
50477         queue.sops = sops;
50478         queue.nsops = nsops;
50479         queue.undo = un;
50480 -       queue.pid = current->pid;
50481 +       queue.pid = current->tgid;
50482         queue.id = semid;
50483         if (alter)
50484                 append_to_queue(sma ,&queue);
50485 @@ -1206,7 +1206,7 @@
50486                                 sem->semval += u->semadj[i];
50487                                 if (sem->semval < 0)
50488                                         sem->semval = 0; /* shouldn't happen */
50489 -                               sem->sempid = current->pid;
50490 +                               sem->sempid = current->tgid;
50491                         }
50492                 }
50493                 sma->sem_otime = get_seconds();
50494 diff -Nru a/ipc/shm.c b/ipc/shm.c
50495 --- a/ipc/shm.c Thu Jul 10 22:22:59 2003
50496 +++ b/ipc/shm.c Thu Aug 28 10:08:22 2003
50497 @@ -89,7 +89,7 @@
50498         if(!(shp = shm_lock(id)))
50499                 BUG();
50500         shp->shm_atim = get_seconds();
50501 -       shp->shm_lprid = current->pid;
50502 +       shp->shm_lprid = current->tgid;
50503         shp->shm_nattch++;
50504         shm_unlock(shp);
50505  }
50506 @@ -136,7 +136,7 @@
50507         /* remove from the list of attaches of the shm segment */
50508         if(!(shp = shm_lock(id)))
50509                 BUG();
50510 -       shp->shm_lprid = current->pid;
50511 +       shp->shm_lprid = current->tgid;
50512         shp->shm_dtim = get_seconds();
50513         shp->shm_nattch--;
50514         if(shp->shm_nattch == 0 &&
50515 @@ -209,7 +209,7 @@
50516         if(id == -1) 
50517                 goto no_id;
50518  
50519 -       shp->shm_cprid = current->pid;
50520 +       shp->shm_cprid = current->tgid;
50521         shp->shm_lprid = 0;
50522         shp->shm_atim = shp->shm_dtim = 0;
50523         shp->shm_ctim = get_seconds();
50524 diff -Nru a/ipc/util.c b/ipc/util.c
50525 --- a/ipc/util.c        Tue Jul  1 06:04:38 2003
50526 +++ b/ipc/util.c        Sun Aug 31 16:14:46 2003
50527 @@ -36,13 +36,14 @@
50528   *     memory are initialised
50529   */
50530   
50531 -void __init ipc_init (void)
50532 +static int __init ipc_init(void)
50533  {
50534         sem_init();
50535         msg_init();
50536         shm_init();
50537 -       return;
50538 +       return 0;
50539  }
50540 +__initcall(ipc_init);
50541  
50542  /**
50543   *     ipc_init_ids            -       initialise IPC identifiers
50544 diff -Nru a/kernel/Makefile b/kernel/Makefile
50545 --- a/kernel/Makefile   Wed Aug  6 13:59:24 2003
50546 +++ b/kernel/Makefile   Sun Aug 31 16:13:58 2003
50547 @@ -20,9 +20,6 @@
50548  obj-$(CONFIG_COMPAT) += compat.o
50549  obj-$(CONFIG_IKCONFIG) += configs.o
50550  
50551 -# files to be removed upon make clean
50552 -clean-files := ikconfig.h
50553 -
50554  ifneq ($(CONFIG_IA64),y)
50555  # According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
50556  # needed for x86 only.  Why this used to be enabled for all architectures is beyond
50557 @@ -32,8 +29,12 @@
50558  CFLAGS_sched.o := $(PROFILING) -fno-omit-frame-pointer
50559  endif
50560  
50561 -$(obj)/ikconfig.h: scripts/mkconfigs .config Makefile
50562 -       $(CONFIG_SHELL) scripts/mkconfigs .config Makefile > $(obj)/ikconfig.h
50563 +quiet_cmd_ikconfig = IKCFG   $@
50564 +      cmd_ikconfig = $(CONFIG_SHELL) $< .config $(srctree)/Makefile > $@
50565 +
50566 +targets += ikconfig.h
50567 +
50568 +$(obj)/ikconfig.h: scripts/mkconfigs .config Makefile FORCE
50569 +       $(call if_changed,ikconfig)
50570  
50571 -$(obj)/configs.o: $(obj)/ikconfig.h $(obj)/configs.c \
50572 -               include/linux/version.h include/linux/compile.h
50573 +$(obj)/configs.o: $(obj)/ikconfig.h
50574 diff -Nru a/kernel/compat.c b/kernel/compat.c
50575 --- a/kernel/compat.c   Sat Aug  9 07:50:24 2003
50576 +++ b/kernel/compat.c   Wed Aug 27 23:55:00 2003
50577 @@ -464,6 +464,7 @@
50578         if (get_compat_itimerspec(&newts, new))
50579                 return -EFAULT; 
50580         oldfs = get_fs();
50581 +       set_fs(KERNEL_DS);
50582         err = sys_timer_settime(timer_id, flags, &newts, &oldts);
50583         set_fs(oldfs); 
50584         if (!err && old && put_compat_itimerspec(old, &oldts))
50585 @@ -477,6 +478,7 @@
50586         mm_segment_t oldfs;
50587         struct itimerspec ts; 
50588         oldfs = get_fs();
50589 +       set_fs(KERNEL_DS);
50590         err = sys_timer_gettime(timer_id, &ts); 
50591         set_fs(oldfs); 
50592         if (!err && put_compat_itimerspec(setting, &ts))
50593 @@ -494,7 +496,8 @@
50594         struct timespec ts; 
50595         if (get_compat_timespec(&ts, tp))
50596                 return -EFAULT; 
50597 -       oldfs = get_fs(); 
50598 +       oldfs = get_fs();
50599 +       set_fs(KERNEL_DS);      
50600         err = sys_clock_settime(which_clock, &ts); 
50601         set_fs(oldfs);
50602         return err;
50603 @@ -508,7 +511,8 @@
50604         long err;
50605         mm_segment_t oldfs;
50606         struct timespec ts; 
50607 -       oldfs = get_fs(); 
50608 +       oldfs = get_fs();
50609 +       set_fs(KERNEL_DS);
50610         err = sys_clock_gettime(which_clock, &ts); 
50611         set_fs(oldfs);
50612         if (!err && put_compat_timespec(&ts, tp))
50613 @@ -524,7 +528,8 @@
50614         long err;
50615         mm_segment_t oldfs;
50616         struct timespec ts; 
50617 -       oldfs = get_fs(); 
50618 +       oldfs = get_fs();
50619 +       set_fs(KERNEL_DS);
50620         err = sys_clock_getres(which_clock, &ts); 
50621         set_fs(oldfs);
50622         if (!err && put_compat_timespec(&ts, tp))
50623 @@ -546,7 +551,8 @@
50624         struct timespec in, out; 
50625         if (get_compat_timespec(&in, rqtp)) 
50626                 return -EFAULT;
50627 -       oldfs = get_fs(); 
50628 +       oldfs = get_fs();
50629 +       set_fs(KERNEL_DS);      
50630         err = sys_clock_nanosleep(which_clock, flags, &in, &out);  
50631         set_fs(oldfs);
50632         if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
50633 diff -Nru a/kernel/exit.c b/kernel/exit.c
50634 --- a/kernel/exit.c     Tue Aug  5 23:04:02 2003
50635 +++ b/kernel/exit.c     Sun Aug 31 16:14:26 2003
50636 @@ -80,6 +80,8 @@
50637         p->parent->cmin_flt += p->min_flt + p->cmin_flt;
50638         p->parent->cmaj_flt += p->maj_flt + p->cmaj_flt;
50639         p->parent->cnswap += p->nswap + p->cnswap;
50640 +       p->parent->cnvcsw += p->nvcsw + p->cnvcsw;
50641 +       p->parent->cnivcsw += p->nivcsw + p->cnivcsw;
50642         sched_exit(p);
50643         write_unlock_irq(&tasklist_lock);
50644         spin_unlock(&p->proc_lock);
50645 diff -Nru a/kernel/fork.c b/kernel/fork.c
50646 --- a/kernel/fork.c     Wed Aug 20 22:32:07 2003
50647 +++ b/kernel/fork.c     Sun Aug 31 16:14:26 2003
50648 @@ -461,6 +461,7 @@
50649         tsk->min_flt = tsk->maj_flt = 0;
50650         tsk->cmin_flt = tsk->cmaj_flt = 0;
50651         tsk->nswap = tsk->cnswap = 0;
50652 +       tsk->nvcsw = tsk->nivcsw = tsk->cnvcsw = tsk->cnivcsw = 0;
50653  
50654         tsk->mm = NULL;
50655         tsk->active_mm = NULL;
50656 diff -Nru a/kernel/futex.c b/kernel/futex.c
50657 --- a/kernel/futex.c    Sun May 25 20:39:28 2003
50658 +++ b/kernel/futex.c    Sun Aug 31 16:14:42 2003
50659 @@ -28,6 +28,7 @@
50660   */
50661  #include <linux/slab.h>
50662  #include <linux/poll.h>
50663 +#include <linux/fs.h>
50664  #include <linux/file.h>
50665  #include <linux/hash.h>
50666  #include <linux/init.h>
50667 @@ -60,8 +61,6 @@
50668  /* The key for the hash is the address + index + offset within page */
50669  static struct list_head futex_queues[1<<FUTEX_HASHBITS];
50670  static spinlock_t futex_lock = SPIN_LOCK_UNLOCKED;
50671 -
50672 -extern void send_sigio(struct fown_struct *fown, int fd, int band);
50673  
50674  /* Futex-fs vfsmount entry: */
50675  static struct vfsmount *futex_mnt;
50676 diff -Nru a/kernel/kallsyms.c b/kernel/kallsyms.c
50677 --- a/kernel/kallsyms.c Tue Aug 19 04:58:04 2003
50678 +++ b/kernel/kallsyms.c Sun Aug 31 16:14:13 2003
50679 @@ -189,9 +189,11 @@
50680         if (pos < iter->pos)
50681                 reset_iter(iter);
50682  
50683 -       /* We need to iterate through the previous symbols. */
50684 -       for (; iter->pos <= pos; iter->pos++)
50685 +       /* We need to iterate through the previous symbols: can be slow */
50686 +       for (; iter->pos != pos; iter->pos++) {
50687                 get_ksymbol_core(iter);
50688 +               cond_resched();
50689 +       }
50690         return 1;
50691  }
50692  
50693 @@ -280,8 +282,7 @@
50694  {
50695         struct proc_dir_entry *entry;
50696  
50697 -       /* root-only: could chew up lots of cpu by read, seek back, read... */
50698 -       entry = create_proc_entry("kallsyms", 0400, NULL);
50699 +       entry = create_proc_entry("kallsyms", 0444, NULL);
50700         if (entry)
50701                 entry->proc_fops = &kallsyms_operations;
50702         return 0;
50703 diff -Nru a/kernel/ksyms.c b/kernel/ksyms.c
50704 --- a/kernel/ksyms.c    Tue Aug 19 09:33:08 2003
50705 +++ b/kernel/ksyms.c    Thu Aug 28 00:36:28 2003
50706 @@ -120,7 +120,6 @@
50707  EXPORT_SYMBOL(max_mapnr);
50708  #endif
50709  EXPORT_SYMBOL(high_memory);
50710 -EXPORT_SYMBOL_GPL(invalidate_mmap_range);
50711  EXPORT_SYMBOL(vmtruncate);
50712  EXPORT_SYMBOL(find_vma);
50713  EXPORT_SYMBOL(get_unmapped_area);
50714 @@ -198,7 +197,6 @@
50715  EXPORT_SYMBOL(invalidate_inode_pages);
50716  EXPORT_SYMBOL_GPL(invalidate_inode_pages2);
50717  EXPORT_SYMBOL(truncate_inode_pages);
50718 -EXPORT_SYMBOL(install_page);
50719  EXPORT_SYMBOL(fsync_bdev);
50720  EXPORT_SYMBOL(permission);
50721  EXPORT_SYMBOL(vfs_permission);
50722 diff -Nru a/kernel/posix-timers.c b/kernel/posix-timers.c
50723 --- a/kernel/posix-timers.c     Sat Jun 14 16:15:58 2003
50724 +++ b/kernel/posix-timers.c     Sat Aug 30 22:24:41 2003
50725 @@ -948,11 +948,15 @@
50726   */
50727  static int do_posix_gettime(struct k_clock *clock, struct timespec *tp)
50728  {
50729 +       struct timeval tv;
50730 +
50731         if (clock->clock_get)
50732                 return clock->clock_get(tp);
50733  
50734 -       do_gettimeofday((struct timeval *) tp);
50735 -       tp->tv_nsec *= NSEC_PER_USEC;
50736 +       do_gettimeofday(&tv);
50737 +       tp->tv_sec = tv.tv_sec;
50738 +       tp->tv_nsec = tv.tv_usec * NSEC_PER_USEC;
50739 +
50740         return 0;
50741  }
50742  
50743 diff -Nru a/kernel/sched.c b/kernel/sched.c
50744 --- a/kernel/sched.c    Mon Aug 18 19:46:23 2003
50745 +++ b/kernel/sched.c    Sun Aug 31 16:14:26 2003
50746 @@ -1325,8 +1325,10 @@
50747                 }
50748         default:
50749                 deactivate_task(prev, rq);
50750 +               prev->nvcsw++;
50751 +               break;
50752         case TASK_RUNNING:
50753 -               ;
50754 +               prev->nivcsw++;
50755         }
50756  pick_next_task:
50757         if (unlikely(!rq->nr_running)) {
50758 diff -Nru a/kernel/sys.c b/kernel/sys.c
50759 --- a/kernel/sys.c      Tue Aug 19 21:53:11 2003
50760 +++ b/kernel/sys.c      Sun Aug 31 16:14:26 2003
50761 @@ -1309,6 +1309,8 @@
50762                 case RUSAGE_SELF:
50763                         jiffies_to_timeval(p->utime, &r.ru_utime);
50764                         jiffies_to_timeval(p->stime, &r.ru_stime);
50765 +                       r.ru_nvcsw = p->nvcsw;
50766 +                       r.ru_nivcsw = p->nivcsw;
50767                         r.ru_minflt = p->min_flt;
50768                         r.ru_majflt = p->maj_flt;
50769                         r.ru_nswap = p->nswap;
50770 @@ -1316,6 +1318,8 @@
50771                 case RUSAGE_CHILDREN:
50772                         jiffies_to_timeval(p->cutime, &r.ru_utime);
50773                         jiffies_to_timeval(p->cstime, &r.ru_stime);
50774 +                       r.ru_nvcsw = p->cnvcsw;
50775 +                       r.ru_nivcsw = p->cnivcsw;
50776                         r.ru_minflt = p->cmin_flt;
50777                         r.ru_majflt = p->cmaj_flt;
50778                         r.ru_nswap = p->cnswap;
50779 @@ -1323,6 +1327,8 @@
50780                 default:
50781                         jiffies_to_timeval(p->utime + p->cutime, &r.ru_utime);
50782                         jiffies_to_timeval(p->stime + p->cstime, &r.ru_stime);
50783 +                       r.ru_nvcsw = p->nvcsw + p->cnvcsw;
50784 +                       r.ru_nivcsw = p->nivcsw + p->cnivcsw;
50785                         r.ru_minflt = p->min_flt + p->cmin_flt;
50786                         r.ru_majflt = p->maj_flt + p->cmaj_flt;
50787                         r.ru_nswap = p->nswap + p->cnswap;
50788 diff -Nru a/kernel/timer.c b/kernel/timer.c
50789 --- a/kernel/timer.c    Thu Aug 14 17:00:00 2003
50790 +++ b/kernel/timer.c    Tue Sep  2 00:05:52 2003
50791 @@ -338,6 +338,7 @@
50792                         break;
50793                 }
50794         }
50795 +       smp_rmb();
50796         if (timer_pending(timer))
50797                 goto del_again;
50798  
50799 diff -Nru a/mm/fremap.c b/mm/fremap.c
50800 --- a/mm/fremap.c       Sun May 25 14:08:24 2003
50801 +++ b/mm/fremap.c       Thu Aug 28 00:38:39 2003
50802 @@ -3,7 +3,7 @@
50803   * 
50804   * Explicit pagetable population and nonlinear (random) mappings support.
50805   *
50806 - * started by Ingo Molnar, Copyright (C) 2002
50807 + * started by Ingo Molnar, Copyright (C) 2002, 2003
50808   */
50809  
50810  #include <linux/mm.h>
50811 @@ -13,6 +13,8 @@
50812  #include <linux/pagemap.h>
50813  #include <linux/swapops.h>
50814  #include <linux/rmap-locking.h>
50815 +#include <linux/module.h>
50816 +
50817  #include <asm/mmu_context.h>
50818  #include <asm/cacheflush.h>
50819  #include <asm/tlbflush.h>
50820 @@ -95,6 +97,8 @@
50821  err:
50822         return err;
50823  }
50824 +EXPORT_SYMBOL(install_page);
50825 +
50826  
50827  /***
50828   * sys_remap_file_pages - remap arbitrary pages of a shared backing store
50829 diff -Nru a/mm/memory.c b/mm/memory.c
50830 --- a/mm/memory.c       Thu Aug 14 18:17:40 2003
50831 +++ b/mm/memory.c       Sun Aug 31 16:14:24 2003
50832 @@ -45,6 +45,7 @@
50833  #include <linux/pagemap.h>
50834  #include <linux/vcache.h>
50835  #include <linux/rmap-locking.h>
50836 +#include <linux/module.h>
50837  
50838  #include <asm/pgalloc.h>
50839  #include <asm/rmap.h>
50840 @@ -810,17 +811,18 @@
50841  static inline int zeromap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address,
50842                                      unsigned long size, pgprot_t prot)
50843  {
50844 -       unsigned long end;
50845 +       unsigned long base, end;
50846  
50847 +       base = address & PGDIR_MASK;
50848         address &= ~PGDIR_MASK;
50849         end = address + size;
50850         if (end > PGDIR_SIZE)
50851                 end = PGDIR_SIZE;
50852         do {
50853 -               pte_t * pte = pte_alloc_map(mm, pmd, address);
50854 +               pte_t * pte = pte_alloc_map(mm, pmd, base + address);
50855                 if (!pte)
50856                         return -ENOMEM;
50857 -               zeromap_pte_range(pte, address, end - address, prot);
50858 +               zeromap_pte_range(pte, base + address, end - address, prot);
50859                 pte_unmap(pte);
50860                 address = (address + PMD_SIZE) & PMD_MASK;
50861                 pmd++;
50862 @@ -1138,6 +1140,7 @@
50863                 invalidate_mmap_range_list(&mapping->i_mmap_shared, hba, hlen);
50864         up(&mapping->i_shared_sem);
50865  }
50866 +EXPORT_SYMBOL_GPL(invalidate_mmap_range);
50867  
50868  /*
50869   * Handle all mappings that got truncated by a "truncate()"
50870 @@ -1384,10 +1387,10 @@
50871         unsigned long address, int write_access, pte_t *page_table, pmd_t *pmd)
50872  {
50873         struct page * new_page;
50874 -       struct address_space *mapping;
50875 +       struct address_space *mapping = NULL;
50876         pte_t entry;
50877         struct pte_chain *pte_chain;
50878 -       int sequence;
50879 +       int sequence = 0;
50880         int ret;
50881  
50882         if (!vma->vm_ops || !vma->vm_ops->nopage)
50883 @@ -1396,8 +1399,10 @@
50884         pte_unmap(page_table);
50885         spin_unlock(&mm->page_table_lock);
50886  
50887 -       mapping = vma->vm_file->f_dentry->d_inode->i_mapping;
50888 -       sequence = atomic_read(&mapping->truncate_count);
50889 +       if (vma->vm_file) {
50890 +               mapping = vma->vm_file->f_dentry->d_inode->i_mapping;
50891 +               sequence = atomic_read(&mapping->truncate_count);
50892 +       }
50893         smp_rmb();  /* Prevent CPU from reordering lock-free ->nopage() */
50894  retry:
50895         new_page = vma->vm_ops->nopage(vma, address & PAGE_MASK, 0);
50896 @@ -1433,7 +1438,8 @@
50897          * invalidated this page.  If invalidate_mmap_range got called,
50898          * retry getting the page.
50899          */
50900 -       if (unlikely(sequence != atomic_read(&mapping->truncate_count))) {
50901 +       if (mapping &&
50902 +             (unlikely(sequence != atomic_read(&mapping->truncate_count)))) {
50903                 sequence = atomic_read(&mapping->truncate_count);
50904                 spin_unlock(&mm->page_table_lock);
50905                 page_cache_release(new_page);
50906 @@ -1453,7 +1459,8 @@
50907          */
50908         /* Only go through if we didn't race with anybody else... */
50909         if (pte_none(*page_table)) {
50910 -               ++mm->rss;
50911 +               if (!PageReserved(new_page))
50912 +                       ++mm->rss;
50913                 flush_icache_page(vma, new_page);
50914                 entry = mk_pte(new_page, vma->vm_page_prot);
50915                 if (write_access)
50916 diff -Nru a/mm/swapfile.c b/mm/swapfile.c
50917 --- a/mm/swapfile.c     Thu Jul 31 16:52:11 2003
50918 +++ b/mm/swapfile.c     Sun Aug 31 16:15:45 2003
50919 @@ -1403,7 +1403,8 @@
50920         p->max = maxpages;
50921         p->pages = nr_good_pages;
50922  
50923 -       if (setup_swap_extents(p))
50924 +       error = setup_swap_extents(p);
50925 +       if (error)
50926                 goto bad_swap;
50927  
50928         swap_list_lock();
50929 diff -Nru a/mm/vmscan.c b/mm/vmscan.c
50930 --- a/mm/vmscan.c       Thu Aug 21 11:57:48 2003
50931 +++ b/mm/vmscan.c       Sun Aug 31 16:14:47 2003
50932 @@ -80,25 +80,6 @@
50933  #endif
50934  
50935  /*
50936 - * exponentially decaying average
50937 - */
50938 -static inline int expavg(int avg, int val)
50939 -{
50940 -       return ((val - avg) >> 1) + avg;
50941 -}
50942 -
50943 -static void zone_adj_pressure(struct zone *zone, int priority)
50944 -{
50945 -       zone->pressure = expavg(zone->pressure,
50946 -                       (DEF_PRIORITY - priority) << 10);
50947 -}
50948 -
50949 -static int pressure_to_priority(int pressure)
50950 -{
50951 -       return DEF_PRIORITY - (pressure >> 10);
50952 -}
50953 -
50954 -/*
50955   * The list of shrinker callbacks used by to apply pressure to
50956   * ageable caches.
50957   */
50958 @@ -646,7 +627,7 @@
50959          * `distress' is a measure of how much trouble we're having reclaiming
50960          * pages.  0 -> no problems.  100 -> great trouble.
50961          */
50962 -       distress = 100 >> pressure_to_priority(zone->pressure);
50963 +       distress = 100 >> zone->prev_priority;
50964  
50965         /*
50966          * The point of this algorithm is to decide when to start reclaiming
50967 @@ -830,6 +811,9 @@
50968                 int nr_mapped = 0;
50969                 int max_scan;
50970  
50971 +               if (zone->free_pages < zone->pages_high)
50972 +                       zone->temp_priority = priority;
50973 +
50974                 if (zone->all_unreclaimable && priority != DEF_PRIORITY)
50975                         continue;       /* Let kswapd poll it */
50976  
50977 @@ -843,10 +827,8 @@
50978                 ret += shrink_zone(zone, max_scan, gfp_mask,
50979                                 to_reclaim, &nr_mapped, ps, priority);
50980                 *total_scanned += max_scan + nr_mapped;
50981 -               if (ret >= nr_pages) {
50982 -                       zone_adj_pressure(zone, priority);
50983 +               if (ret >= nr_pages)
50984                         break;
50985 -               }
50986         }
50987         return ret;
50988  }
50989 @@ -880,6 +862,9 @@
50990  
50991         inc_page_state(allocstall);
50992  
50993 +       for (zone = cz; zone >= cz->zone_pgdat->node_zones; --zone)
50994 +               zone->temp_priority = DEF_PRIORITY;
50995 +
50996         for (priority = DEF_PRIORITY; priority >= 0; priority--) {
50997                 int total_scanned = 0;
50998                 struct page_state ps;
50999 @@ -912,9 +897,9 @@
51000         }
51001         if ((gfp_mask & __GFP_FS) && !(gfp_mask & __GFP_NORETRY))
51002                 out_of_memory();
51003 -       for (zone = cz; zone >= cz->zone_pgdat->node_zones; -- zone)
51004 -               zone_adj_pressure(zone, -1);
51005  out:
51006 +       for (zone = cz; zone >= cz->zone_pgdat->node_zones; --zone)
51007 +               zone->prev_priority = zone->temp_priority;
51008         return ret;
51009  }
51010  
51011 @@ -945,6 +930,12 @@
51012  
51013         inc_page_state(pageoutrun);
51014  
51015 +       for (i = 0; i < pgdat->nr_zones; i++) {
51016 +               struct zone *zone = pgdat->node_zones + i;
51017 +
51018 +               zone->temp_priority = DEF_PRIORITY;
51019 +       }
51020 +
51021         for (priority = DEF_PRIORITY; priority; priority--) {
51022                 int all_zones_ok = 1;
51023  
51024 @@ -961,11 +952,10 @@
51025                                 to_reclaim = min(to_free, SWAP_CLUSTER_MAX*8);
51026                         } else {                        /* Zone balancing */
51027                                 to_reclaim = zone->pages_high-zone->free_pages;
51028 -                               if (to_reclaim <= 0) {
51029 -                                       zone_adj_pressure(zone, priority);
51030 +                               if (to_reclaim <= 0)
51031                                         continue;
51032 -                               }
51033                         }
51034 +                       zone->temp_priority = priority;
51035                         all_zones_ok = 0;
51036                         max_scan = zone->nr_inactive >> priority;
51037                         if (max_scan < to_reclaim * 2)
51038 @@ -989,13 +979,11 @@
51039                 if (to_free > 0)
51040                         blk_congestion_wait(WRITE, HZ/10);
51041         }
51042 -       if (priority < 0) {
51043 -               for (i = 0; i < pgdat->nr_zones; i++) {
51044 -                       struct zone *zone = pgdat->node_zones + i;
51045  
51046 -                       if (zone->free_pages < zone->pages_high)
51047 -                               zone_adj_pressure(zone, -1);
51048 -               }
51049 +       for (i = 0; i < pgdat->nr_zones; i++) {
51050 +               struct zone *zone = pgdat->node_zones + i;
51051 +
51052 +               zone->prev_priority = zone->temp_priority;
51053         }
51054         return nr_pages - to_free;
51055  }
51056 diff -Nru a/net/Kconfig b/net/Kconfig
51057 --- a/net/Kconfig       Tue Aug 19 21:12:36 2003
51058 +++ b/net/Kconfig       Mon Sep  1 01:44:26 2003
51059 @@ -191,9 +191,11 @@
51060           information.
51061  
51062           If you enable iptables support along with the bridge support then you
51063 -         turn your bridge into a bridging firewall.
51064 +         turn your bridge into a bridging IP firewall.
51065           iptables will then see the IP packets being bridged, so you need to
51066           take this into account when setting up your firewall rules.
51067 +         Enabling arptables support when bridging will let arptables see
51068 +         bridged ARP traffic in the arptables FORWARD chain.
51069  
51070           If you want to compile this code as a module ( = code which can be
51071           inserted in and removed from the running kernel whenever you want),
51072 @@ -243,6 +245,12 @@
51073           box can transparently forward the traffic to a local server,
51074           typically a caching proxy server.
51075  
51076 +         Yet another use of Netfilter is building a bridging firewall. Using
51077 +         a bridge with Network packet filtering enabled makes iptables "see"
51078 +         the bridged traffic. For filtering on the lower network and Ethernet
51079 +         protocols over the bridge, use ebtables (under bridge netfilter
51080 +         configuration).
51081 +
51082           Various modules exist for netfilter which replace the previous
51083           masquerading (ipmasqadm), packet filtering (ipchains), transparent
51084           proxying, and portforwarding mechanisms. Please see
51085 @@ -263,6 +271,19 @@
51086         help
51087           You can say Y here if you want to get additional messages useful in
51088           debugging the netfilter code.
51089 +
51090 +config BRIDGE_NETFILTER
51091 +       bool "Bridged IP/ARP packets filtering"
51092 +       depends on BRIDGE && NETFILTER && INET
51093 +       default y
51094 +       ---help---
51095 +         Enabling this option will let arptables resp. iptables see bridged
51096 +         ARP resp. IP traffic. If you want a bridging firewall, you probably
51097 +         want this option enabled.
51098 +         Enabling or disabling this option doesn't enable or disable
51099 +         ebtables.
51100 +
51101 +         If unsure, say N.
51102  
51103  source "net/ipv4/netfilter/Kconfig"
51104  source "net/ipv6/netfilter/Kconfig"
51105 diff -Nru a/net/appletalk/aarp.c b/net/appletalk/aarp.c
51106 --- a/net/appletalk/aarp.c      Wed Jun  4 17:57:07 2003
51107 +++ b/net/appletalk/aarp.c      Sat Aug 30 19:27:36 2003
51108 @@ -37,6 +37,7 @@
51109  #include <linux/atalk.h>
51110  #include <linux/init.h>
51111  #include <linux/proc_fs.h>
51112 +#include <linux/seq_file.h>
51113  
51114  int sysctl_aarp_expiry_time = AARP_EXPIRY_TIME;
51115  int sysctl_aarp_tick_time = AARP_TICK_TIME;
51116 @@ -145,6 +146,7 @@
51117         aarp_dl->request(aarp_dl, skb, aarp_eth_multicast);
51118         /* Update the sending count */
51119         a->xmit_count++;
51120 +       a->last_sent = jiffies;
51121  }
51122  
51123  /* This runs under aarp_lock and in softint context, so only atomic memory
51124 @@ -338,6 +340,32 @@
51125         return NOTIFY_DONE;
51126  }
51127  
51128 +/* Expire all entries in a hash chain */
51129 +static void __aarp_expire_all(struct aarp_entry **n)
51130 +{
51131 +       struct aarp_entry *t;
51132 +
51133 +       while (*n) {
51134 +               t = *n;
51135 +               *n = (*n)->next;
51136 +               __aarp_expire(t);
51137 +       }
51138 +}
51139 +
51140 +/* Cleanup all hash chains -- module unloading */
51141 +static void aarp_purge(void)
51142 +{
51143 +       int ct;
51144 +
51145 +       write_lock_bh(&aarp_lock);
51146 +       for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
51147 +               __aarp_expire_all(&resolved[ct]);
51148 +               __aarp_expire_all(&unresolved[ct]);
51149 +               __aarp_expire_all(&proxies[ct]);
51150 +       }
51151 +       write_unlock_bh(&aarp_lock);
51152 +}
51153 +
51154  /*
51155   *     Create a new aarp entry.  This must use GFP_ATOMIC because it
51156   *     runs while holding spinlocks.
51157 @@ -861,112 +889,181 @@
51158         write_unlock_bh(&aarp_lock);
51159  }
51160  
51161 -/* Called from proc fs */
51162 -static int aarp_get_info(char *buffer, char **start, off_t offset, int length)
51163 +#ifdef CONFIG_PROC_FS
51164 +struct aarp_iter_state {
51165 +       int bucket;
51166 +       struct aarp_entry **table;
51167 +};
51168 +
51169 +/*
51170 + * Get the aarp entry that is in the chain described
51171 + * by the iterator. 
51172 + * If pos is set then skip till that index.
51173 + * pos = 1 is the first entry
51174 + */
51175 +static struct aarp_entry *iter_next(struct aarp_iter_state *iter, loff_t *pos)
51176  {
51177 -       /* we should dump all our AARP entries */
51178 +       int ct = iter->bucket;
51179 +       struct aarp_entry **table = iter->table;
51180 +       loff_t off = 0;
51181         struct aarp_entry *entry;
51182 -       int ct, len = sprintf(buffer,
51183 -                             "%-10.10s  %-10.10s%-18.18s%12.12s%12.12s "
51184 -                             "xmit_count  status\n",
51185 -                             "address", "device", "hw addr", "last_sent",
51186 -                             "expires");
51187 +       
51188 + rescan:
51189 +       while(ct < AARP_HASH_SIZE) {
51190 +               for (entry = table[ct]; entry; entry = entry->next) {
51191 +                       if (!pos || ++off == *pos) {
51192 +                               iter->table = table;
51193 +                               iter->bucket = ct;
51194 +                               return entry;
51195 +                       }
51196 +               }
51197 +               ++ct;
51198 +       }
51199 +
51200 +       if (table == resolved) {
51201 +               ct = 0;
51202 +               table = unresolved;
51203 +               goto rescan;
51204 +       }
51205 +       if (table == unresolved) {
51206 +               ct = 0;
51207 +               table = proxies;
51208 +               goto rescan;
51209 +       }
51210 +       return NULL;
51211 +}
51212 +
51213 +static void *aarp_seq_start(struct seq_file *seq, loff_t *pos)
51214 +{
51215 +       struct aarp_iter_state *iter = seq->private;
51216  
51217         read_lock_bh(&aarp_lock);
51218 +       iter->table     = resolved;
51219 +       iter->bucket    = 0;
51220  
51221 -       for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
51222 -               for (entry = resolved[ct]; entry; entry = entry->next) {
51223 -                       len += sprintf(buffer + len, "%6u:%-3u  ",
51224 -                               (unsigned int)ntohs(entry->target_addr.s_net),
51225 -                               (unsigned int)(entry->target_addr.s_node));
51226 -                       len += sprintf(buffer + len, "%-10.10s",
51227 -                                      entry->dev->name);
51228 -                       len += sprintf(buffer + len,
51229 -                                      "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
51230 -                                      (int)(entry->hwaddr[0] & 0x000000FF),
51231 -                                      (int)(entry->hwaddr[1] & 0x000000FF),
51232 -                                      (int)(entry->hwaddr[2] & 0x000000FF),
51233 -                                      (int)(entry->hwaddr[3] & 0x000000FF),
51234 -                                      (int)(entry->hwaddr[4] & 0x000000FF),
51235 -                                      (int)(entry->hwaddr[5] & 0x000000FF));
51236 -                       len += sprintf(buffer + len, "%12lu ""%12lu ",
51237 -                                      (unsigned long)entry->last_sent,
51238 -                                      (unsigned long)entry->expires_at);
51239 -                       len += sprintf(buffer + len, "%10u",
51240 -                                      (unsigned int)entry->xmit_count);
51241 +       return *pos ? iter_next(iter, pos) : ((void *)1);
51242 +}
51243  
51244 -                       len += sprintf(buffer + len, "   resolved\n");
51245 -               }
51246 -       }
51247 +static void *aarp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
51248 +{
51249 +       struct aarp_entry *entry = v;
51250 +       struct aarp_iter_state *iter = seq->private;
51251  
51252 -       for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
51253 -               for (entry = unresolved[ct]; entry; entry = entry->next) {
51254 -                       len += sprintf(buffer + len, "%6u:%-3u  ",
51255 -                               (unsigned int)ntohs(entry->target_addr.s_net),
51256 -                               (unsigned int)(entry->target_addr.s_node));
51257 -                       len += sprintf(buffer + len, "%-10.10s",
51258 -                                      entry->dev->name);
51259 -                       len += sprintf(buffer + len,
51260 -                                      "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
51261 -                                      (int)(entry->hwaddr[0] & 0x000000FF),
51262 -                                      (int)(entry->hwaddr[1] & 0x000000FF),
51263 -                                      (int)(entry->hwaddr[2] & 0x000000FF),
51264 -                                      (int)(entry->hwaddr[3] & 0x000000FF),
51265 -                                      (int)(entry->hwaddr[4] & 0x000000FF),
51266 -                                      (int)(entry->hwaddr[5] & 0x000000FF));
51267 -                       len += sprintf(buffer + len, "%12lu ""%12lu ",
51268 -                                      (unsigned long)entry->last_sent,
51269 -                                      (unsigned long)entry->expires_at);
51270 -                       len += sprintf(buffer + len, "%10u",
51271 -                                      (unsigned int)entry->xmit_count);
51272 -                       len += sprintf(buffer + len, " unresolved\n");
51273 -               }
51274 -       }
51275 +       ++*pos;
51276  
51277 -       for (ct = 0; ct < AARP_HASH_SIZE; ct++) {
51278 -               for (entry = proxies[ct]; entry; entry = entry->next) {
51279 -                       len += sprintf(buffer + len, "%6u:%-3u  ",
51280 -                               (unsigned int)ntohs(entry->target_addr.s_net),
51281 -                               (unsigned int)(entry->target_addr.s_node));
51282 -                       len += sprintf(buffer + len, "%-10.10s",
51283 -                                      entry->dev->name);
51284 -                       len += sprintf(buffer + len,
51285 -                                      "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
51286 -                                      (int)(entry->hwaddr[0] & 0x000000FF),
51287 -                                      (int)(entry->hwaddr[1] & 0x000000FF),
51288 -                                      (int)(entry->hwaddr[2] & 0x000000FF),
51289 -                                      (int)(entry->hwaddr[3] & 0x000000FF),
51290 -                                      (int)(entry->hwaddr[4] & 0x000000FF),
51291 -                                      (int)(entry->hwaddr[5] & 0x000000FF));
51292 -                       len += sprintf(buffer + len, "%12lu ""%12lu ",
51293 -                                      (unsigned long)entry->last_sent,
51294 -                                      (unsigned long)entry->expires_at);
51295 -                       len += sprintf(buffer + len, "%10u",
51296 -                                      (unsigned int)entry->xmit_count);
51297 -                       len += sprintf(buffer + len, "      proxy\n");
51298 -               }
51299 +       /* first line after header */
51300 +       if (v == ((void *)1)) 
51301 +               entry = iter_next(iter, NULL);
51302 +               
51303 +       /* next entry in current bucket */
51304 +       else if (entry->next)
51305 +               entry = entry->next;
51306 +
51307 +       /* next bucket or table */
51308 +       else {
51309 +               ++iter->bucket;
51310 +               entry = iter_next(iter, NULL);
51311         }
51312 +       return entry;
51313 +}
51314  
51315 +static void aarp_seq_stop(struct seq_file *seq, void *v)
51316 +{
51317         read_unlock_bh(&aarp_lock);
51318 -       return len;
51319  }
51320  
51321 -/* General module cleanup. Called from cleanup_module() in ddp.c. */
51322 -void aarp_cleanup_module(void)
51323 +static const char *dt2str(unsigned long ticks)
51324  {
51325 -       del_timer(&aarp_timer);
51326 -       unregister_netdevice_notifier(&aarp_notifier);
51327 -       unregister_snap_client(aarp_dl);
51328 +       static char buf[32];
51329 +
51330 +       sprintf(buf, "%ld.%02ld", ticks / HZ, ((ticks % HZ) * 100 ) / HZ);
51331 +
51332 +       return buf;
51333  }
51334  
51335 -#ifdef CONFIG_PROC_FS
51336 -void aarp_register_proc_fs(void)
51337 +static int aarp_seq_show(struct seq_file *seq, void *v)
51338  {
51339 -       proc_net_create("aarp", 0, aarp_get_info);
51340 +       struct aarp_iter_state *iter = seq->private;
51341 +       struct aarp_entry *entry = v;
51342 +       unsigned long now = jiffies;
51343 +
51344 +       if (v == ((void *)1))
51345 +               seq_puts(seq, 
51346 +                        "Address  Interface   Hardware Address"
51347 +                        "   Expires LastSend  Retry Status\n");
51348 +       else {
51349 +               seq_printf(seq, "%04X:%02X  %-12s",
51350 +                          ntohs(entry->target_addr.s_net),
51351 +                          (unsigned int) entry->target_addr.s_node,
51352 +                          entry->dev ? entry->dev->name : "????");
51353 +               seq_printf(seq, "%02X:%02X:%02X:%02X:%02X:%02X",
51354 +                          entry->hwaddr[0] & 0xFF,
51355 +                          entry->hwaddr[1] & 0xFF,
51356 +                          entry->hwaddr[2] & 0xFF,
51357 +                          entry->hwaddr[3] & 0xFF,
51358 +                          entry->hwaddr[4] & 0xFF,
51359 +                          entry->hwaddr[5] & 0xFF);
51360 +               seq_printf(seq, " %8s",
51361 +                          dt2str((long)entry->expires_at - (long)now));
51362 +               if (iter->table == unresolved)
51363 +                       seq_printf(seq, " %8s %6hu",
51364 +                                  dt2str(now - entry->last_sent),
51365 +                                  entry->xmit_count);
51366 +               else
51367 +                       seq_puts(seq, "                ");
51368 +               seq_printf(seq, " %s\n",
51369 +                          (iter->table == resolved) ? "resolved"
51370 +                          : (iter->table == unresolved) ? "unresolved"
51371 +                          : (iter->table == proxies) ? "proxies"
51372 +                          : "unknown");
51373 +       }                                
51374 +       return 0;
51375  }
51376  
51377 -void aarp_unregister_proc_fs(void)
51378 +static struct seq_operations aarp_seq_ops = {
51379 +       .start  = aarp_seq_start,
51380 +       .next   = aarp_seq_next,
51381 +       .stop   = aarp_seq_stop,
51382 +       .show   = aarp_seq_show,
51383 +};
51384 +
51385 +static int aarp_seq_open(struct inode *inode, struct file *file)
51386  {
51387 -       proc_net_remove("aarp");
51388 +       struct seq_file *seq;
51389 +       int rc = -ENOMEM;
51390 +       struct aarp_iter_state *s = kmalloc(sizeof(*s), GFP_KERNEL);
51391 +       
51392 +       if (!s)
51393 +               goto out;
51394 +
51395 +       rc = seq_open(file, &aarp_seq_ops);
51396 +       if (rc)
51397 +               goto out_kfree;
51398 +
51399 +       seq          = file->private_data;
51400 +       seq->private = s;
51401 +       memset(s, 0, sizeof(*s));
51402 +out:
51403 +       return rc;
51404 +out_kfree:
51405 +       kfree(s);
51406 +       goto out;
51407  }
51408 +
51409 +struct file_operations atalk_seq_arp_fops = {
51410 +       .owner          = THIS_MODULE,
51411 +       .open           = aarp_seq_open,
51412 +       .read           = seq_read,
51413 +       .llseek         = seq_lseek,
51414 +       .release        = seq_release_private,
51415 +};
51416  #endif
51417 +
51418 +/* General module cleanup. Called from cleanup_module() in ddp.c. */
51419 +void aarp_cleanup_module(void)
51420 +{
51421 +       del_timer_sync(&aarp_timer);
51422 +       unregister_netdevice_notifier(&aarp_notifier);
51423 +       unregister_snap_client(aarp_dl);
51424 +       aarp_purge();
51425 +}
51426 diff -Nru a/net/appletalk/atalk_proc.c b/net/appletalk/atalk_proc.c
51427 --- a/net/appletalk/atalk_proc.c        Mon Jun 16 08:11:36 2003
51428 +++ b/net/appletalk/atalk_proc.c        Sat Aug 30 19:27:36 2003
51429 @@ -16,6 +16,8 @@
51430  #include <linux/atalk.h>
51431  
51432  #ifdef CONFIG_PROC_FS
51433 +extern struct file_operations atalk_seq_arp_fops;
51434 +
51435  static __inline__ struct atalk_iface *atalk_get_interface_idx(loff_t pos)
51436  {
51437         struct atalk_iface *i;
51438 @@ -61,7 +63,7 @@
51439         struct atalk_iface *iface;
51440  
51441         if (v == (void *)1) {
51442 -               seq_puts(seq, "Interface          Address   Networks   "
51443 +               seq_puts(seq, "Interface        Address   Networks  "
51444                               "Status\n");
51445                 goto out;
51446         }
51447 @@ -275,6 +277,7 @@
51448         atalk_proc_dir = proc_mkdir("atalk", proc_net);
51449         if (!atalk_proc_dir)
51450                 goto out;
51451 +       atalk_proc_dir->owner = THIS_MODULE;
51452  
51453         p = create_proc_entry("interface", S_IRUGO, atalk_proc_dir);
51454         if (!p)
51455 @@ -291,9 +294,16 @@
51456                 goto out_socket;
51457         p->proc_fops = &atalk_seq_socket_fops;
51458  
51459 +       p = create_proc_entry("arp", S_IRUGO, atalk_proc_dir);
51460 +       if (!p) 
51461 +               goto out_arp;
51462 +       p->proc_fops = &atalk_seq_arp_fops;
51463 +
51464         rc = 0;
51465  out:
51466         return rc;
51467 +out_arp:
51468 +       remove_proc_entry("socket", atalk_proc_dir);
51469  out_socket:
51470         remove_proc_entry("route", atalk_proc_dir);
51471  out_route:
51472 @@ -308,6 +318,7 @@
51473         remove_proc_entry("interface", atalk_proc_dir);
51474         remove_proc_entry("route", atalk_proc_dir);
51475         remove_proc_entry("socket", atalk_proc_dir);
51476 +       remove_proc_entry("arp", atalk_proc_dir);
51477         remove_proc_entry("atalk", proc_net);
51478  }
51479  
51480 diff -Nru a/net/appletalk/ddp.c b/net/appletalk/ddp.c
51481 --- a/net/appletalk/ddp.c       Mon Jun 16 08:11:36 2003
51482 +++ b/net/appletalk/ddp.c       Sat Aug 30 19:29:20 2003
51483 @@ -61,11 +61,6 @@
51484  #include <net/route.h>
51485  #include <linux/atalk.h>
51486  
51487 -#ifdef CONFIG_PROC_FS
51488 -extern void aarp_register_proc_fs(void);
51489 -extern void aarp_unregister_proc_fs(void);
51490 -#endif
51491 -
51492  extern void aarp_cleanup_module(void);
51493  
51494  extern void aarp_probe_network(struct atalk_iface *atif);
51495 @@ -183,13 +178,12 @@
51496  {
51497         struct sock *sk = (struct sock *)data;
51498  
51499 -       if (!atomic_read(&sk->sk_wmem_alloc) &&
51500 -           !atomic_read(&sk->sk_rmem_alloc) && sock_flag(sk, SOCK_DEAD))
51501 -               sock_put(sk);
51502 -       else {
51503 +       if (atomic_read(&sk->sk_wmem_alloc) ||
51504 +           atomic_read(&sk->sk_rmem_alloc)) {
51505                 sk->sk_timer.expires = jiffies + SOCK_DESTROY_TIME;
51506                 add_timer(&sk->sk_timer);
51507 -       }
51508 +       } else
51509 +               sock_put(sk);
51510  }
51511  
51512  static inline void atalk_destroy_socket(struct sock *sk)
51513 @@ -197,16 +191,15 @@
51514         atalk_remove_socket(sk);
51515         skb_queue_purge(&sk->sk_receive_queue);
51516  
51517 -       if (!atomic_read(&sk->sk_wmem_alloc) &&
51518 -           !atomic_read(&sk->sk_rmem_alloc) && sock_flag(sk, SOCK_DEAD))
51519 -               sock_put(sk);
51520 -       else {
51521 +       if (atomic_read(&sk->sk_wmem_alloc) ||
51522 +           atomic_read(&sk->sk_rmem_alloc)) {
51523                 init_timer(&sk->sk_timer);
51524                 sk->sk_timer.expires    = jiffies + SOCK_DESTROY_TIME;
51525                 sk->sk_timer.function   = atalk_destroy_timer;
51526                 sk->sk_timer.data       = (unsigned long)sk;
51527                 add_timer(&sk->sk_timer);
51528 -       }
51529 +       } else
51530 +               sock_put(sk);
51531  }
51532  
51533  /**************************************************************************\
51534 @@ -239,6 +232,7 @@
51535         while ((tmp = *iface) != NULL) {
51536                 if (tmp->dev == dev) {
51537                         *iface = tmp->next;
51538 +                       dev_put(dev);
51539                         kfree(tmp);
51540                         dev->atalk_ptr = NULL;
51541                 } else
51542 @@ -255,6 +249,7 @@
51543         if (!iface)
51544                 goto out;
51545  
51546 +       dev_hold(dev);
51547         iface->dev = dev;
51548         dev->atalk_ptr = iface;
51549         iface->address = *sa;
51550 @@ -616,6 +611,7 @@
51551                     (!(tmp->flags&RTF_GATEWAY) ||
51552                      tmp->target.s_node == addr->s_node)) {
51553                         *r = tmp->next;
51554 +                       dev_put(tmp->dev);
51555                         kfree(tmp);
51556                         goto out;
51557                 }
51558 @@ -640,6 +636,7 @@
51559         while ((tmp = *r) != NULL) {
51560                 if (tmp->dev == dev) {
51561                         *r = tmp->next;
51562 +                       dev_put(dev);
51563                         kfree(tmp);
51564                 } else
51565                         r = &tmp->next;
51566 @@ -935,24 +932,95 @@
51567   * Checksum: This is 'optional'. It's quite likely also a good
51568   * candidate for assembler hackery 8)
51569   */
51570 -unsigned short atalk_checksum(struct ddpehdr *ddp, int len)
51571 +static unsigned long atalk_sum_partial(const unsigned char *data, 
51572 +                                      int len, unsigned long sum)
51573  {
51574 -       unsigned long sum = 0;  /* Assume unsigned long is >16 bits */
51575 -       unsigned char *data = (unsigned char *)ddp;
51576 -
51577 -       len  -= 4;              /* skip header 4 bytes */
51578 -       data += 4;
51579 -
51580         /* This ought to be unwrapped neatly. I'll trust gcc for now */
51581         while (len--) {
51582 -               sum += *data;
51583 +               sum += *data++;
51584                 sum <<= 1;
51585 -               if (sum & 0x10000) {
51586 -                       sum++;
51587 -                       sum &= 0xFFFF;
51588 +               sum = ((sum >> 16) + sum) & 0xFFFF;
51589 +       }
51590 +       return sum;
51591 +}
51592 +
51593 +/*  Checksum skb data --  similar to skb_checksum  */
51594 +static unsigned long atalk_sum_skb(const struct sk_buff *skb, int offset,
51595 +                                  int len, unsigned long sum)
51596 +{
51597 +       int start = skb_headlen(skb);
51598 +       int i, copy;
51599 +
51600 +       /* checksum stuff in header space */
51601 +       if ( (copy = start - offset) > 0) {
51602 +               if (copy > len)
51603 +                       copy = len;
51604 +               sum = atalk_sum_partial(skb->data + offset, copy, sum);
51605 +               if ( (len -= copy) == 0) 
51606 +                       return sum;
51607 +
51608 +               offset += copy;
51609 +       }
51610 +
51611 +       /* checksum stuff in frags */
51612 +       for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
51613 +               int end;
51614 +
51615 +               BUG_TRAP(start <= offset + len);
51616 +
51617 +               end = start + skb_shinfo(skb)->frags[i].size;
51618 +               if ((copy = end - offset) > 0) {
51619 +                       u8 *vaddr;
51620 +                       skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
51621 +
51622 +                       if (copy > len)
51623 +                               copy = len;
51624 +                       vaddr = kmap_skb_frag(frag);
51625 +                       sum = atalk_sum_partial(vaddr + frag->page_offset +
51626 +                                                 offset - start, copy, sum);
51627 +                       kunmap_skb_frag(vaddr);
51628 +
51629 +                       if (!(len -= copy))
51630 +                               return sum;
51631 +                       offset += copy;
51632 +               }
51633 +               start = end;
51634 +       }
51635 +
51636 +       if (skb_shinfo(skb)->frag_list) {
51637 +               struct sk_buff *list = skb_shinfo(skb)->frag_list;
51638 +
51639 +               for (; list; list = list->next) {
51640 +                       int end;
51641 +
51642 +                       BUG_TRAP(start <= offset + len);
51643 +
51644 +                       end = start + list->len;
51645 +                       if ((copy = end - offset) > 0) {
51646 +                               if (copy > len)
51647 +                                       copy = len;
51648 +                               sum = atalk_sum_skb(list, offset - start,
51649 +                                                   copy, sum);
51650 +                               if ((len -= copy) == 0)
51651 +                                       return sum;
51652 +                               offset += copy;
51653 +                       }
51654 +                       start = end;
51655                 }
51656 -               data++;
51657         }
51658 +
51659 +       BUG_ON(len > 0);
51660 +
51661 +       return sum;
51662 +}
51663 +
51664 +static unsigned short atalk_checksum(const struct sk_buff *skb, int len)
51665 +{
51666 +       unsigned long sum;
51667 +
51668 +       /* skip header 4 bytes */
51669 +       sum = atalk_sum_skb(skb, 4, len-4, 0);
51670 +
51671         /* Use 0xFFFF for 0. 0 itself means none */
51672         return sum ? htons((unsigned short)sum) : 0xFFFF;
51673  }
51674 @@ -983,6 +1051,8 @@
51675         rc = 0;
51676         sock->ops = &atalk_dgram_ops;
51677         sock_init_data(sock, sk);
51678 +       sk_set_owner(sk, THIS_MODULE);
51679 +
51680         /* Checksums on by default */
51681         sk->sk_zapped = 1;
51682  out:
51683 @@ -998,10 +1068,7 @@
51684         struct sock *sk = sock->sk;
51685  
51686         if (sk) {
51687 -               if (!sock_flag(sk, SOCK_DEAD)) {
51688 -                       sk->sk_state_change(sk);
51689 -                       sock_set_flag(sk, SOCK_DEAD);
51690 -               }
51691 +               sock_orphan(sk);
51692                 sock->sk = NULL;
51693                 atalk_destroy_socket(sk);
51694         }
51695 @@ -1335,25 +1402,27 @@
51696  static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
51697                      struct packet_type *pt)
51698  {
51699 -       struct ddpehdr *ddp = ddp_hdr(skb);
51700 +       struct ddpehdr *ddp;
51701         struct sock *sock;
51702         struct atalk_iface *atif;
51703         struct sockaddr_at tosat;
51704          int origlen;
51705          struct ddpebits ddphv;
51706  
51707 -       /* Size check */
51708 -       if (skb->len < sizeof(*ddp))
51709 +       /* Don't mangle buffer if shared */
51710 +       if (!(skb = skb_share_check(skb, GFP_ATOMIC))) 
51711 +               goto out;
51712 +               
51713 +       /* Size check and make sure header is contiguous */
51714 +       if (!pskb_may_pull(skb, sizeof(*ddp)))
51715                 goto freeit;
51716  
51717 +       ddp = ddp_hdr(skb);
51718 +
51719         /*
51720          *      Fix up the length field [Ok this is horrible but otherwise
51721          *      I end up with unions of bit fields and messy bit field order
51722          *      compiler/endian dependencies..]
51723 -        *
51724 -        *      FIXME: This is a write to a shared object. Granted it
51725 -        *      happens to be safe BUT.. (Its safe as user space will not
51726 -        *      run until we put it back)
51727          */
51728         *((__u16 *)&ddphv) = ntohs(*((__u16 *)ddp));
51729  
51730 @@ -1374,7 +1443,7 @@
51731          * valid for net byte orders all over the networking code...
51732          */
51733         if (ddp->deh_sum &&
51734 -           atalk_checksum(ddp, ddphv.deh_len) != ddp->deh_sum)
51735 +           atalk_checksum(skb, ddphv.deh_len) != ddp->deh_sum)
51736                 /* Not a valid AppleTalk frame - dustbin time */
51737                 goto freeit;
51738  
51739 @@ -1433,14 +1502,16 @@
51740  
51741                 if (!ap || skb->len < sizeof(struct ddpshdr))
51742                         goto freeit;
51743 +
51744 +               /* Don't mangle buffer if shared */
51745 +               if (!(skb = skb_share_check(skb, GFP_ATOMIC))) 
51746 +                       return 0;
51747 +
51748                 /*
51749                  * The push leaves us with a ddephdr not an shdr, and
51750                  * handily the port bytes in the right place preset.
51751                  */
51752 -
51753 -               skb_push(skb, sizeof(*ddp) - 4);
51754 -               /* FIXME: use skb->cb to be able to use shared skbs */
51755 -               ddp = (struct ddpehdr *)skb->data;
51756 +               ddp = (struct ddpehdr *) skb_push(skb, sizeof(*ddp) - 4);
51757  
51758                 /* Now fill in the long header */
51759  
51760 @@ -1592,7 +1663,7 @@
51761         if (sk->sk_no_check == 1)
51762                 ddp->deh_sum = 0;
51763         else
51764 -               ddp->deh_sum = atalk_checksum(ddp, len + sizeof(*ddp));
51765 +               ddp->deh_sum = atalk_checksum(skb, len + sizeof(*ddp));
51766  
51767         /*
51768          * Loopback broadcast packets to non gateway targets (ie routes
51769 @@ -1801,11 +1872,13 @@
51770  struct packet_type ltalk_packet_type = {
51771         .type           = __constant_htons(ETH_P_LOCALTALK),
51772         .func           = ltalk_rcv,
51773 +       .data           = (void *)1,
51774  };
51775  
51776  struct packet_type ppptalk_packet_type = {
51777         .type           = __constant_htons(ETH_P_PPPTALK),
51778         .func           = atalk_rcv,
51779 +       .data           = (void *)1,
51780  };
51781  
51782  static unsigned char ddp_snap_id[] = { 0x08, 0x00, 0x07, 0x80, 0x9B };
51783 @@ -1834,9 +1907,6 @@
51784         register_netdevice_notifier(&ddp_notifier);
51785         aarp_proto_init();
51786         atalk_proc_init();
51787 -#ifdef CONFIG_PROC_FS
51788 -       aarp_register_proc_fs();
51789 -#endif /* CONFIG_PROC_FS */
51790         atalk_register_sysctl();
51791         printk(atalk_banner);
51792         return 0;
51793 @@ -1844,13 +1914,10 @@
51794  module_init(atalk_init);
51795  
51796  /*
51797 - * Note on MOD_{INC,DEC}_USE_COUNT:
51798 - *
51799 - * Use counts are incremented/decremented when
51800 - * sockets are created/deleted.
51801 - *
51802 - * AppleTalk interfaces are not incremented until atalkd is run
51803 - * and are only decremented when they are downed.
51804 + * No explicit module reference count manipulation is needed in the
51805 + * protocol. Socket layer sets module reference count for us
51806 + * and interfaces reference counting is done
51807 + * by the network device layer.
51808   *
51809   * Ergo, before the AppleTalk module can be removed, all AppleTalk
51810   * sockets be closed from user space.
51811 @@ -1861,9 +1928,6 @@
51812         atalk_unregister_sysctl();
51813  #endif /* CONFIG_SYSCTL */
51814         atalk_proc_exit();
51815 -#ifdef CONFIG_PROC_FS
51816 -       aarp_unregister_proc_fs();
51817 -#endif /* CONFIG_PROC_FS */
51818         aarp_cleanup_module();  /* General aarp clean-up. */
51819         unregister_netdevice_notifier(&ddp_notifier);
51820         dev_remove_pack(&ltalk_packet_type);
51821 diff -Nru a/net/atm/common.c b/net/atm/common.c
51822 --- a/net/atm/common.c  Tue Aug 19 21:10:45 2003
51823 +++ b/net/atm/common.c  Sat Aug 30 19:13:39 2003
51824 @@ -279,6 +279,7 @@
51825         if (!sk)
51826                 return -ENOMEM;
51827         sock_init_data(sock, sk);
51828 +       sk_set_owner(sk, THIS_MODULE);
51829         sk->sk_state_change = vcc_def_wakeup;
51830         sk->sk_write_space = vcc_write_space;
51831  
51832 diff -Nru a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
51833 --- a/net/ax25/af_ax25.c        Thu Aug 21 11:59:08 2003
51834 +++ b/net/ax25/af_ax25.c        Sun Aug 24 04:34:01 2003
51835 @@ -1842,81 +1842,107 @@
51836         return res;
51837  }
51838  
51839 -static int ax25_get_info(char *buffer, char **start, off_t offset, int length)
51840 +#ifdef CONFIG_PROC_FS
51841 +
51842 +static void *ax25_info_start(struct seq_file *seq, loff_t *pos)
51843  {
51844 -       ax25_cb *ax25;
51845 -       int k;
51846 -       int len = 0;
51847 -       off_t pos = 0;
51848 -       off_t begin = 0;
51849 +       struct ax25_cb *ax25;
51850         struct hlist_node *node;
51851 +       int i = 0;
51852  
51853         spin_lock_bh(&ax25_list_lock);
51854 +       ax25_for_each(ax25, node, &ax25_list) {
51855 +               if (i == *pos)
51856 +                       return ax25;
51857 +               ++i;
51858 +       }
51859 +       return NULL;
51860 +}
51861 +
51862 +static void *ax25_info_next(struct seq_file *seq, void *v, loff_t *pos)
51863 +{
51864 +       ++*pos;
51865 +
51866 +       return hlist_entry( ((struct ax25_cb *)v)->ax25_node.next,
51867 +                           struct ax25_cb, ax25_node);
51868 +}
51869 +       
51870 +static void ax25_info_stop(struct seq_file *seq, void *v)
51871 +{
51872 +       spin_unlock_bh(&ax25_list_lock);
51873 +}
51874 +
51875 +static int ax25_info_show(struct seq_file *seq, void *v)
51876 +{
51877 +       ax25_cb *ax25 = v;
51878 +       int k;
51879 +
51880  
51881         /*
51882          * New format:
51883          * magic dev src_addr dest_addr,digi1,digi2,.. st vs vr va t1 t1 t2 t2 t3 t3 idle idle n2 n2 rtt window paclen Snd-Q Rcv-Q inode
51884          */
51885  
51886 -       ax25_for_each(ax25, node, &ax25_list) {
51887 -               len += sprintf(buffer+len, "%8.8lx %s %s%s ",
51888 -                               (long) ax25,
51889 -                               ax25->ax25_dev == NULL? "???" : ax25->ax25_dev->dev->name,
51890 -                               ax2asc(&ax25->source_addr),
51891 -                               ax25->iamdigi? "*":"");
51892 -
51893 -               len += sprintf(buffer+len, "%s", ax2asc(&ax25->dest_addr));
51894 -
51895 -               for (k=0; (ax25->digipeat != NULL) && (k < ax25->digipeat->ndigi); k++) {
51896 -                       len += sprintf(buffer+len, ",%s%s",
51897 -                                       ax2asc(&ax25->digipeat->calls[k]),
51898 -                                       ax25->digipeat->repeated[k]? "*":"");
51899 -               }
51900 -
51901 -               len += sprintf(buffer+len, " %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %d %d",
51902 -                       ax25->state,
51903 -                       ax25->vs, ax25->vr, ax25->va,
51904 -                       ax25_display_timer(&ax25->t1timer) / HZ, ax25->t1 / HZ,
51905 -                       ax25_display_timer(&ax25->t2timer) / HZ, ax25->t2 / HZ,
51906 -                       ax25_display_timer(&ax25->t3timer) / HZ, ax25->t3 / HZ,
51907 -                       ax25_display_timer(&ax25->idletimer) / (60 * HZ),
51908 -                       ax25->idle / (60 * HZ),
51909 -                       ax25->n2count, ax25->n2,
51910 -                       ax25->rtt / HZ,
51911 -                       ax25->window,
51912 -                       ax25->paclen);
51913 -
51914 -               if (ax25->sk != NULL) {
51915 -                       bh_lock_sock(ax25->sk);
51916 -                       len += sprintf(buffer + len, " %d %d %ld\n",
51917 -                               atomic_read(&ax25->sk->sk_wmem_alloc),
51918 -                               atomic_read(&ax25->sk->sk_rmem_alloc),
51919 -                               ax25->sk->sk_socket != NULL ? SOCK_INODE(ax25->sk->sk_socket)->i_ino : 0L);
51920 -                       bh_unlock_sock(ax25->sk);
51921 -               } else {
51922 -                       len += sprintf(buffer + len, " * * *\n");
51923 -               }
51924 -
51925 -               pos = begin + len;
51926 -
51927 -               if (pos < offset) {
51928 -                       len   = 0;
51929 -                       begin = pos;
51930 -               }
51931 +       seq_printf(seq, "%8.8lx %s %s%s ",
51932 +                  (long) ax25,
51933 +                  ax25->ax25_dev == NULL? "???" : ax25->ax25_dev->dev->name,
51934 +                  ax2asc(&ax25->source_addr),
51935 +                  ax25->iamdigi? "*":"");
51936 +       seq_printf(seq, "%s", ax2asc(&ax25->dest_addr));
51937 +
51938 +       for (k=0; (ax25->digipeat != NULL) && (k < ax25->digipeat->ndigi); k++) {
51939 +               seq_printf(seq, ",%s%s",
51940 +                          ax2asc(&ax25->digipeat->calls[k]),
51941 +                          ax25->digipeat->repeated[k]? "*":"");
51942 +       }
51943  
51944 -               if (pos > offset + length)
51945 -                       break;
51946 +       seq_printf(seq, " %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %d %d",
51947 +                  ax25->state,
51948 +                  ax25->vs, ax25->vr, ax25->va,
51949 +                  ax25_display_timer(&ax25->t1timer) / HZ, ax25->t1 / HZ,
51950 +                  ax25_display_timer(&ax25->t2timer) / HZ, ax25->t2 / HZ,
51951 +                  ax25_display_timer(&ax25->t3timer) / HZ, ax25->t3 / HZ,
51952 +                  ax25_display_timer(&ax25->idletimer) / (60 * HZ),
51953 +                  ax25->idle / (60 * HZ),
51954 +                  ax25->n2count, ax25->n2,
51955 +                  ax25->rtt / HZ,
51956 +                  ax25->window,
51957 +                  ax25->paclen);
51958 +
51959 +       if (ax25->sk != NULL) {
51960 +               bh_lock_sock(ax25->sk);
51961 +               seq_printf(seq," %d %d %ld\n",
51962 +                          atomic_read(&ax25->sk->sk_wmem_alloc),
51963 +                          atomic_read(&ax25->sk->sk_rmem_alloc),
51964 +                          ax25->sk->sk_socket != NULL ? SOCK_INODE(ax25->sk->sk_socket)->i_ino : 0L);
51965 +               bh_unlock_sock(ax25->sk);
51966 +       } else {
51967 +               seq_puts(seq, " * * *\n");
51968         }
51969 +       return 0;
51970 +}
51971  
51972 -       spin_unlock_bh(&ax25_list_lock);
51973 +static struct seq_operations ax25_info_seqops = {
51974 +       .start = ax25_info_start,
51975 +       .next = ax25_info_next,
51976 +       .stop = ax25_info_stop,
51977 +       .show = ax25_info_show,
51978 +};
51979  
51980 -       *start = buffer + (offset - begin);
51981 -       len   -= (offset - begin);
51982 +static int ax25_info_open(struct inode *inode, struct file *file)
51983 +{
51984 +       return seq_open(file, &ax25_info_seqops);
51985 +}
51986  
51987 -       if (len > length) len = length;
51988 +static struct file_operations ax25_info_fops = {
51989 +       .owner = THIS_MODULE,
51990 +       .open = ax25_info_open,
51991 +       .read = seq_read,
51992 +       .llseek = seq_lseek,
51993 +       .release = seq_release,
51994 +};
51995  
51996 -       return(len);
51997 -}
51998 +#endif
51999  
52000  static struct net_proto_family ax25_family_ops = {
52001         .family =       PF_AX25,
52002 @@ -1986,9 +2012,9 @@
52003         register_netdevice_notifier(&ax25_dev_notifier);
52004         ax25_register_sysctl();
52005  
52006 -       proc_net_create("ax25_route", 0, ax25_rt_get_info);
52007 -       proc_net_create("ax25", 0, ax25_get_info);
52008 -       proc_net_create("ax25_calls", 0, ax25_uid_get_info);
52009 +       proc_net_fops_create("ax25_route", S_IRUGO, &ax25_route_fops);
52010 +       proc_net_fops_create("ax25", S_IRUGO, &ax25_info_fops);
52011 +       proc_net_fops_create("ax25_calls", S_IRUGO, &ax25_uid_fops);
52012  
52013         printk(banner);
52014         return 0;
52015 diff -Nru a/net/ax25/ax25_dev.c b/net/ax25/ax25_dev.c
52016 --- a/net/ax25/ax25_dev.c       Thu Jun  5 01:01:36 2003
52017 +++ b/net/ax25/ax25_dev.c       Sun Aug 24 04:32:46 2003
52018 @@ -67,6 +67,7 @@
52019  
52020         dev->ax25_ptr     = ax25_dev;
52021         ax25_dev->dev     = dev;
52022 +       dev_hold(dev);
52023         ax25_dev->forward = NULL;
52024  
52025         ax25_dev->values[AX25_VALUES_IPDEFMODE] = AX25_DEF_IPDEFMODE;
52026 @@ -121,6 +122,7 @@
52027         if ((s = ax25_dev_list) == ax25_dev) {
52028                 ax25_dev_list = s->next;
52029                 spin_unlock_bh(&ax25_dev_lock);
52030 +               dev_put(dev);
52031                 kfree(ax25_dev);
52032                 ax25_register_sysctl();
52033                 return;
52034 @@ -130,6 +132,7 @@
52035                 if (s->next == ax25_dev) {
52036                         s->next = ax25_dev->next;
52037                         spin_unlock_bh(&ax25_dev_lock);
52038 +                       dev_put(dev);
52039                         kfree(ax25_dev);
52040                         ax25_register_sysctl();
52041                         return;
52042 @@ -196,8 +199,8 @@
52043         ax25_dev = ax25_dev_list;
52044         while (ax25_dev != NULL) {
52045                 s        = ax25_dev;
52046 +               dev_put(ax25_dev->dev);
52047                 ax25_dev = ax25_dev->next;
52048 -
52049                 kfree(s);
52050         }
52051         ax25_dev_list = NULL;
52052 diff -Nru a/net/ax25/ax25_route.c b/net/ax25/ax25_route.c
52053 --- a/net/ax25/ax25_route.c     Thu Aug 21 11:59:08 2003
52054 +++ b/net/ax25/ax25_route.c     Sun Aug 24 04:34:01 2003
52055 @@ -34,6 +34,7 @@
52056  #include <linux/mm.h>
52057  #include <linux/interrupt.h>
52058  #include <linux/init.h>
52059 +#include <linux/seq_file.h>
52060  
52061  static ax25_route *ax25_route_list;
52062  static rwlock_t ax25_route_lock = RW_LOCK_UNLOCKED;
52063 @@ -278,66 +279,100 @@
52064         }
52065  }
52066  
52067 -int ax25_rt_get_info(char *buffer, char **start, off_t offset, int length)
52068 -{
52069 -       ax25_route *ax25_rt;
52070 -       int len     = 0;
52071 -       off_t pos   = 0;
52072 -       off_t begin = 0;
52073 -       char *callsign;
52074 -       int i;
52075 +#ifdef CONFIG_PROC_FS
52076  
52077 -       read_lock(&ax25_route_lock);
52078 +#define AX25_PROC_START        ((void *)1)
52079  
52080 -       len += sprintf(buffer, "callsign  dev  mode digipeaters\n");
52081 +static void *ax25_rt_seq_start(struct seq_file *seq, loff_t *pos)
52082 +{
52083 +       struct ax25_route *ax25_rt;
52084 +       int i = 1;
52085
52086 +       read_lock(&ax25_route_lock);
52087 +       if (*pos == 0)
52088 +               return AX25_PROC_START;
52089  
52090         for (ax25_rt = ax25_route_list; ax25_rt != NULL; ax25_rt = ax25_rt->next) {
52091 +               if (i == *pos)
52092 +                       return ax25_rt;
52093 +               ++i;
52094 +       }
52095 +
52096 +       return NULL;
52097 +}
52098 +
52099 +static void *ax25_rt_seq_next(struct seq_file *seq, void *v, loff_t *pos)
52100 +{
52101 +       ++*pos;
52102 +       return (v == AX25_PROC_START) ? ax25_route_list : 
52103 +               ((struct ax25_route *) v)->next;
52104 +}
52105 +
52106 +static void ax25_rt_seq_stop(struct seq_file *seq, void *v)
52107 +{
52108 +       read_unlock(&ax25_route_lock);
52109 +}
52110 +
52111 +static int ax25_rt_seq_show(struct seq_file *seq, void *v)
52112 +{
52113 +       if (v == AX25_PROC_START)
52114 +               seq_puts(seq, "callsign  dev  mode digipeaters\n");
52115 +       else {
52116 +               struct ax25_route *ax25_rt = v;
52117 +               const char *callsign;
52118 +               int i;
52119 +
52120                 if (ax25cmp(&ax25_rt->callsign, &null_ax25_address) == 0)
52121                         callsign = "default";
52122                 else
52123                         callsign = ax2asc(&ax25_rt->callsign);
52124 -               len += sprintf(buffer + len, "%-9s %-4s",
52125 +
52126 +               seq_printf(seq, "%-9s %-4s",
52127                         callsign,
52128                         ax25_rt->dev ? ax25_rt->dev->name : "???");
52129  
52130                 switch (ax25_rt->ip_mode) {
52131                 case 'V':
52132 -                       len += sprintf(buffer + len, "   vc");
52133 +                       seq_puts(seq, "   vc");
52134                         break;
52135                 case 'D':
52136 -                       len += sprintf(buffer + len, "   dg");
52137 +                       seq_puts(seq, "   dg");
52138                         break;
52139                 default:
52140 -                       len += sprintf(buffer + len, "    *");
52141 +                       seq_puts(seq, "    *");
52142                         break;
52143                 }
52144  
52145                 if (ax25_rt->digipeat != NULL)
52146                         for (i = 0; i < ax25_rt->digipeat->ndigi; i++)
52147 -                               len += sprintf(buffer + len, " %s", ax2asc(&ax25_rt->digipeat->calls[i]));
52148 -
52149 -               len += sprintf(buffer + len, "\n");
52150 +                               seq_printf(seq, " %s", ax2asc(&ax25_rt->digipeat->calls[i]));
52151  
52152 -               pos = begin + len;
52153 -
52154 -               if (pos < offset) {
52155 -                       len   = 0;
52156 -                       begin = pos;
52157 -               }
52158 -
52159 -               if (pos > offset + length)
52160 -                       break;
52161 +               seq_puts(seq, "\n");
52162         }
52163 -       read_unlock(&ax25_route_lock);
52164 -
52165 -       *start = buffer + (offset - begin);
52166 -       len   -= (offset - begin);
52167 +       return 0;
52168 +}
52169  
52170 -       if (len > length)
52171 -               len = length;
52172 +static struct seq_operations ax25_rt_seqops = {
52173 +       .start = ax25_rt_seq_start,
52174 +       .next = ax25_rt_seq_next,
52175 +       .stop = ax25_rt_seq_stop,
52176 +       .show = ax25_rt_seq_show,
52177 +};
52178  
52179 -       return len;
52180 +static int ax25_rt_info_open(struct inode *inode, struct file *file)
52181 +{
52182 +       return seq_open(file, &ax25_rt_seqops);
52183  }
52184 +
52185 +struct file_operations ax25_route_fops = {
52186 +       .owner = THIS_MODULE,
52187 +       .open = ax25_rt_info_open,
52188 +       .read = seq_read,
52189 +       .llseek = seq_lseek,
52190 +       .release = seq_release,
52191 +};
52192 +
52193 +#endif
52194  
52195  /*
52196   *     Find AX.25 route
52197 diff -Nru a/net/ax25/ax25_uid.c b/net/ax25/ax25_uid.c
52198 --- a/net/ax25/ax25_uid.c       Mon Aug  5 06:20:38 2002
52199 +++ b/net/ax25/ax25_uid.c       Sun Aug 24 04:34:01 2003
52200 @@ -30,6 +30,7 @@
52201  #include <linux/interrupt.h>
52202  #include <linux/notifier.h>
52203  #include <linux/proc_fs.h>
52204 +#include <linux/seq_file.h>
52205  #include <linux/stat.h>
52206  #include <linux/netfilter.h>
52207  #include <linux/sysctl.h>
52208 @@ -141,39 +142,73 @@
52209         return -EINVAL; /*NOTREACHED */
52210  }
52211  
52212 -int ax25_uid_get_info(char *buffer, char **start, off_t offset, int length)
52213 +#ifdef CONFIG_PROC_FS
52214 +
52215 +#define AX25_PROC_START        ((void *)1)
52216 +
52217 +static void *ax25_uid_seq_start(struct seq_file *seq, loff_t *pos)
52218  {
52219 -       ax25_uid_assoc *pt;
52220 -       int len     = 0;
52221 -       off_t pos   = 0;
52222 -       off_t begin = 0;
52223 +       struct ax25_uid_assoc *pt;
52224 +       int i = 1;
52225  
52226         read_lock(&ax25_uid_lock);
52227 -       len += sprintf(buffer, "Policy: %d\n", ax25_uid_policy);
52228 +       if (*pos == 0)
52229 +               return AX25_PROC_START;
52230  
52231         for (pt = ax25_uid_list; pt != NULL; pt = pt->next) {
52232 -               len += sprintf(buffer + len, "%6d %s\n", pt->uid, ax2asc(&pt->call));
52233 -
52234 -               pos = begin + len;
52235 +               if (i == *pos)
52236 +                       return pt;
52237 +               ++i;
52238 +       }
52239 +       return NULL;
52240 +}
52241  
52242 -               if (pos < offset) {
52243 -                       len = 0;
52244 -                       begin = pos;
52245 -               }
52246 +static void *ax25_uid_seq_next(struct seq_file *seq, void *v, loff_t *pos)
52247 +{
52248 +       ++*pos;
52249 +       return (v == AX25_PROC_START) ? ax25_uid_list : 
52250 +               ((struct ax25_uid_assoc *) v)->next;
52251 +}
52252  
52253 -               if (pos > offset + length)
52254 -                       break;
52255 -       }
52256 +static void ax25_uid_seq_stop(struct seq_file *seq, void *v)
52257 +{
52258         read_unlock(&ax25_uid_lock);
52259 +}
52260 +
52261 +static int ax25_uid_seq_show(struct seq_file *seq, void *v)
52262 +{
52263 +       if (v == AX25_PROC_START)
52264 +               seq_printf(seq, "Policy: %d\n", ax25_uid_policy);
52265 +       else {
52266 +               struct ax25_uid_assoc *pt = v;
52267 +               
52268  
52269 -       *start = buffer + (offset - begin);
52270 -       len   -= offset - begin;
52271 +               seq_printf(seq, "%6d %s\n", pt->uid, ax2asc(&pt->call));
52272 +       }
52273 +       return 0;
52274 +}
52275  
52276 -       if (len > length)
52277 -               len = length;
52278 +static struct seq_operations ax25_uid_seqops = {
52279 +       .start = ax25_uid_seq_start,
52280 +       .next = ax25_uid_seq_next,
52281 +       .stop = ax25_uid_seq_stop,
52282 +       .show = ax25_uid_seq_show,
52283 +};
52284  
52285 -       return len;
52286 +static int ax25_uid_info_open(struct inode *inode, struct file *file)
52287 +{
52288 +       return seq_open(file, &ax25_uid_seqops);
52289  }
52290 +
52291 +struct file_operations ax25_uid_fops = {
52292 +       .owner = THIS_MODULE,
52293 +       .open = ax25_uid_info_open,
52294 +       .read = seq_read,
52295 +       .llseek = seq_lseek,
52296 +       .release = seq_release,
52297 +};
52298 +
52299 +#endif
52300  
52301  /*
52302   *     Free all memory associated with UID/Callsign structures.
52303 diff -Nru a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
52304 --- a/net/bluetooth/af_bluetooth.c      Wed Jun 18 13:59:01 2003
52305 +++ b/net/bluetooth/af_bluetooth.c      Sat Aug 30 19:30:42 2003
52306 @@ -130,6 +130,7 @@
52307         }
52308  
52309         sock_init_data(sock, sk);
52310 +       sk_set_owner(sk, THIS_MODULE);
52311         INIT_LIST_HEAD(&bt_sk(sk)->accept_q);
52312         
52313         sk->sk_zapped   = 0;
52314 diff -Nru a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
52315 --- a/net/bluetooth/l2cap.c     Mon Jun 16 08:11:36 2003
52316 +++ b/net/bluetooth/l2cap.c     Sun Aug 31 16:14:24 2003
52317 @@ -200,7 +200,7 @@
52318   */
52319  static struct sock *__l2cap_get_sock_by_psm(int state, u16 psm, bdaddr_t *src)
52320  {
52321 -       struct sock *sk, *sk1 = NULL;
52322 +       struct sock *sk = NULL, *sk1 = NULL;
52323         struct hlist_node *node;
52324  
52325         sk_for_each(sk, node, &l2cap_sk_list.head) {
52326 diff -Nru a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
52327 --- a/net/bluetooth/rfcomm/sock.c       Fri Jul  4 23:52:58 2003
52328 +++ b/net/bluetooth/rfcomm/sock.c       Sun Aug 31 16:14:24 2003
52329 @@ -114,7 +114,7 @@
52330  /* ---- Socket functions ---- */
52331  static struct sock *__rfcomm_get_sock_by_addr(u8 channel, bdaddr_t *src)
52332  {
52333 -       struct sock *sk;
52334 +       struct sock *sk = NULL;
52335         struct hlist_node *node;
52336  
52337         sk_for_each(sk, node, &rfcomm_sk_list.head) {
52338 @@ -131,7 +131,7 @@
52339   */
52340  static struct sock *__rfcomm_get_sock_by_channel(int state, u8 channel, bdaddr_t *src)
52341  {
52342 -       struct sock *sk, *sk1 = NULL;
52343 +       struct sock *sk = NULL, *sk1 = NULL;
52344         struct hlist_node *node;
52345  
52346         sk_for_each(sk, node, &rfcomm_sk_list.head) {
52347 diff -Nru a/net/bridge/Makefile b/net/bridge/Makefile
52348 --- a/net/bridge/Makefile       Sun Aug  3 15:08:32 2003
52349 +++ b/net/bridge/Makefile       Mon Sep  1 01:44:26 2003
52350 @@ -8,9 +8,6 @@
52351                         br_ioctl.o br_notify.o br_stp.o br_stp_bpdu.o \
52352                         br_stp_if.o br_stp_timer.o
52353  
52354 -# br_netfilter only deals with IPv4 and ARP filtering, both are INET protocols
52355 -ifeq ($(CONFIG_INET),y)
52356 -bridge-$(CONFIG_NETFILTER)     += br_netfilter.o
52357 -endif
52358 +bridge-$(CONFIG_BRIDGE_NETFILTER) += br_netfilter.o
52359  
52360  obj-$(CONFIG_BRIDGE_NF_EBTABLES) += netfilter/
52361 diff -Nru a/net/bridge/br_forward.c b/net/bridge/br_forward.c
52362 --- a/net/bridge/br_forward.c   Sun May 25 20:10:58 2003
52363 +++ b/net/bridge/br_forward.c   Mon Sep  1 01:44:26 2003
52364 @@ -33,7 +33,7 @@
52365  
52366  int br_dev_queue_push_xmit(struct sk_buff *skb)
52367  {
52368 -#ifdef CONFIG_NETFILTER
52369 +#ifdef CONFIG_BRIDGE_NETFILTER
52370         /* ip_refrag calls ip_fragment, which doesn't copy the MAC header. */
52371         if (skb->nf_bridge)
52372                 memcpy(skb->data - 16, skb->nf_bridge->hh, 16);
52373 diff -Nru a/net/bridge/netfilter/Kconfig b/net/bridge/netfilter/Kconfig
52374 --- a/net/bridge/netfilter/Kconfig      Thu Jul 17 23:40:19 2003
52375 +++ b/net/bridge/netfilter/Kconfig      Sat Aug 30 20:40:35 2003
52376 @@ -1,9 +1,30 @@
52377  #
52378  # Bridge netfilter configuration
52379  #
52380 +
52381 +menu "Bridge: Netfilter Configuration"
52382 +       depends on BRIDGE && NETFILTER
52383 +
52384  config BRIDGE_NF_EBTABLES
52385 -       tristate "Bridge: ebtables"
52386 -       depends on NETFILTER && BRIDGE
52387 +       tristate "Ethernet Bridge tables (ebtables) support"
52388 +       help
52389 +         ebtables is a general, extensible frame/packet identification
52390 +         framework. Say 'Y' or 'M' here if you want to do Ethernet
52391 +         filtering/NAT/brouting on the Ethernet bridge.
52392 +#
52393 +# tables
52394 +#
52395 +config BRIDGE_EBT_BROUTE
52396 +       tristate "ebt: broute table support"
52397 +       depends on BRIDGE_NF_EBTABLES
52398 +       help
52399 +         The ebtables broute table is used to define rules that decide between
52400 +         bridging and routing frames, giving Linux the functionality of a
52401 +         brouter. See the man page for ebtables(8) and examples on the ebtables
52402 +         website.
52403 +
52404 +         If you want to compile it as a module, say M here and read
52405 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
52406  
52407  config BRIDGE_EBT_T_FILTER
52408         tristate "ebt: filter table support"
52409 @@ -26,35 +47,14 @@
52410  
52411           If you want to compile it as a module, say M here and read
52412           <file:Documentation/modules.txt>.  If unsure, say `N'.
52413 -
52414 -config BRIDGE_EBT_BROUTE
52415 -       tristate "ebt: broute table support"
52416 +#
52417 +# matches
52418 +#
52419 +config BRIDGE_EBT_802_3
52420 +       tristate "ebt: 802.3 filter support"
52421         depends on BRIDGE_NF_EBTABLES
52422         help
52423 -         The ebtables broute table is used to define rules that decide between
52424 -         bridging and routing frames, giving Linux the functionality of a
52425 -         brouter. See the man page for ebtables(8) and examples on the ebtables
52426 -         website.
52427 -
52428 -         If you want to compile it as a module, say M here and read
52429 -         <file:Documentation/modules.txt>.  If unsure, say `N'.
52430 -
52431 -config BRIDGE_EBT_LOG
52432 -       tristate "ebt: log support"
52433 -       depends on BRIDGE_NF_EBTABLES
52434 -       help
52435 -         This option adds the log target, that you can use in any rule in
52436 -         any ebtables table. It records the frame header to the syslog.
52437 -
52438 -         If you want to compile it as a module, say M here and read
52439 -         <file:Documentation/modules.txt>.  If unsure, say `N'.
52440 -
52441 -config BRIDGE_EBT_IP
52442 -       tristate "ebt: IP filter support"
52443 -       depends on BRIDGE_NF_EBTABLES
52444 -       help
52445 -         This option adds the IP match, which allows basic IP header field
52446 -         filtering.
52447 +         This option adds matching support for 802.3 Ethernet frames.
52448  
52449           If you want to compile it as a module, say M here and read
52450           <file:Documentation/modules.txt>.  If unsure, say `N'.
52451 @@ -69,12 +69,12 @@
52452           If you want to compile it as a module, say M here and read
52453           <file:Documentation/modules.txt>.  If unsure, say `N'.
52454  
52455 -config BRIDGE_EBT_VLAN
52456 -       tristate "ebt: 802.1Q VLAN filter support"
52457 +config BRIDGE_EBT_IP
52458 +       tristate "ebt: IP filter support"
52459         depends on BRIDGE_NF_EBTABLES
52460         help
52461 -         This option adds the 802.1Q vlan match, which allows the filtering of
52462 -         802.1Q vlan fields.
52463 +         This option adds the IP match, which allows basic IP header field
52464 +         filtering.
52465  
52466           If you want to compile it as a module, say M here and read
52467           <file:Documentation/modules.txt>.  If unsure, say `N'.
52468 @@ -113,12 +113,24 @@
52469           If you want to compile it as a module, say M here and read
52470           <file:Documentation/modules.txt>.  If unsure, say `N'.
52471  
52472 -config BRIDGE_EBT_SNAT
52473 -       tristate "ebt: snat target support"
52474 +config BRIDGE_EBT_VLAN
52475 +       tristate "ebt: 802.1Q VLAN filter support"
52476         depends on BRIDGE_NF_EBTABLES
52477         help
52478 -         This option adds the MAC SNAT target, which allows altering the MAC
52479 -         source address of frames.
52480 +         This option adds the 802.1Q vlan match, which allows the filtering of
52481 +         802.1Q vlan fields.
52482 +
52483 +         If you want to compile it as a module, say M here and read
52484 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
52485 +#
52486 +# targets
52487 +#
52488 +config BRIDGE_EBT_ARPREPLY
52489 +       tristate "ebt: arp reply target support"
52490 +       depends on BRIDGE_NF_EBTABLES
52491 +       help
52492 +         This option adds the arp reply target, which allows
52493 +         automatically sending arp replies to arp requests.
52494  
52495           If you want to compile it as a module, say M here and read
52496           <file:Documentation/modules.txt>.  If unsure, say `N'.
52497 @@ -133,6 +145,18 @@
52498           If you want to compile it as a module, say M here and read
52499           <file:Documentation/modules.txt>.  If unsure, say `N'.
52500  
52501 +config BRIDGE_EBT_MARK_T
52502 +       tristate "ebt: mark target support"
52503 +       depends on BRIDGE_NF_EBTABLES
52504 +       help
52505 +         This option adds the mark target, which allows marking frames by
52506 +         setting the 'nfmark' value in the frame.
52507 +         This value is the same as the one used in the iptables mark match and
52508 +         target.
52509 +
52510 +         If you want to compile it as a module, say M here and read
52511 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
52512 +
52513  config BRIDGE_EBT_REDIRECT
52514         tristate "ebt: redirect target support"
52515         depends on BRIDGE_NF_EBTABLES
52516 @@ -143,15 +167,26 @@
52517           If you want to compile it as a module, say M here and read
52518           <file:Documentation/modules.txt>.  If unsure, say `N'.
52519  
52520 -config BRIDGE_EBT_MARK_T
52521 -       tristate "ebt: mark target support"
52522 +config BRIDGE_EBT_SNAT
52523 +       tristate "ebt: snat target support"
52524         depends on BRIDGE_NF_EBTABLES
52525         help
52526 -         This option adds the mark target, which allows marking frames by
52527 -         setting the 'nfmark' value in the frame.
52528 -         This value is the same as the one used in the iptables mark match and
52529 -         target.
52530 +         This option adds the MAC SNAT target, which allows altering the MAC
52531 +         source address of frames.
52532 +
52533 +         If you want to compile it as a module, say M here and read
52534 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
52535 +#
52536 +# watchers
52537 +#
52538 +config BRIDGE_EBT_LOG
52539 +       tristate "ebt: log support"
52540 +       depends on BRIDGE_NF_EBTABLES
52541 +       help
52542 +         This option adds the log target, that you can use in any rule in
52543 +         any ebtables table. It records the frame header to the syslog.
52544  
52545           If you want to compile it as a module, say M here and read
52546           <file:Documentation/modules.txt>.  If unsure, say `N'.
52547  
52548 +endmenu
52549 diff -Nru a/net/bridge/netfilter/Makefile b/net/bridge/netfilter/Makefile
52550 --- a/net/bridge/netfilter/Makefile     Thu Jul 17 23:40:19 2003
52551 +++ b/net/bridge/netfilter/Makefile     Sat Aug 30 20:40:35 2003
52552 @@ -3,17 +3,27 @@
52553  #
52554  
52555  obj-$(CONFIG_BRIDGE_NF_EBTABLES) += ebtables.o
52556 +
52557 +# tables
52558 +obj-$(CONFIG_BRIDGE_EBT_BROUTE) += ebtable_broute.o
52559  obj-$(CONFIG_BRIDGE_EBT_T_FILTER) += ebtable_filter.o
52560  obj-$(CONFIG_BRIDGE_EBT_T_NAT) += ebtable_nat.o
52561 -obj-$(CONFIG_BRIDGE_EBT_BROUTE) += ebtable_broute.o
52562 -obj-$(CONFIG_BRIDGE_EBT_IP) += ebt_ip.o
52563 +
52564 +#matches
52565 +obj-$(CONFIG_BRIDGE_EBT_802_3) += ebt_802_3.o
52566  obj-$(CONFIG_BRIDGE_EBT_ARP) += ebt_arp.o
52567 -obj-$(CONFIG_BRIDGE_EBT_VLAN) += ebt_vlan.o
52568 +obj-$(CONFIG_BRIDGE_EBT_IP) += ebt_ip.o
52569  obj-$(CONFIG_BRIDGE_EBT_MARK) += ebt_mark_m.o
52570  obj-$(CONFIG_BRIDGE_EBT_PKTTYPE) += ebt_pkttype.o
52571  obj-$(CONFIG_BRIDGE_EBT_STP) += ebt_stp.o
52572 -obj-$(CONFIG_BRIDGE_EBT_LOG) += ebt_log.o
52573 -obj-$(CONFIG_BRIDGE_EBT_SNAT) += ebt_snat.o
52574 +obj-$(CONFIG_BRIDGE_EBT_VLAN) += ebt_vlan.o
52575 +
52576 +# targets
52577 +obj-$(CONFIG_BRIDGE_EBT_ARPREPLY) += ebt_arpreply.o
52578 +obj-$(CONFIG_BRIDGE_EBT_MARK_T) += ebt_mark.o
52579  obj-$(CONFIG_BRIDGE_EBT_DNAT) += ebt_dnat.o
52580  obj-$(CONFIG_BRIDGE_EBT_REDIRECT) += ebt_redirect.o
52581 -obj-$(CONFIG_BRIDGE_EBT_MARK_T) += ebt_mark.o
52582 +obj-$(CONFIG_BRIDGE_EBT_SNAT) += ebt_snat.o
52583 +
52584 +# watchers
52585 +obj-$(CONFIG_BRIDGE_EBT_LOG) += ebt_log.o
52586 diff -Nru a/net/bridge/netfilter/ebt_802_3.c b/net/bridge/netfilter/ebt_802_3.c
52587 --- /dev/null   Wed Dec 31 16:00:00 1969
52588 +++ b/net/bridge/netfilter/ebt_802_3.c  Sat Aug 30 20:40:29 2003
52589 @@ -0,0 +1,73 @@
52590 +/*
52591 + * 802_3
52592 + *
52593 + * Author:
52594 + * Chris Vitale csv@bluetail.com
52595 + *
52596 + * May 2003
52597 + * 
52598 + */
52599 +
52600 +#include <linux/netfilter_bridge/ebtables.h>
52601 +#include <linux/netfilter_bridge/ebt_802_3.h>
52602 +#include <linux/module.h>
52603 +
52604 +static int ebt_filter_802_3(const struct sk_buff *skb, const struct net_device *in,
52605 +   const struct net_device *out, const void *data, unsigned int datalen)
52606 +{
52607 +       struct ebt_802_3_info *info = (struct ebt_802_3_info *)data;
52608 +       struct ebt_802_3_hdr *hdr = (struct ebt_802_3_hdr *)skb->mac.ethernet;
52609 +       uint16_t type = hdr->llc.ui.ctrl & IS_UI ? hdr->llc.ui.type : hdr->llc.ni.type;
52610 +
52611 +       if (info->bitmask & EBT_802_3_SAP) {
52612 +               if (FWINV(info->sap != hdr->llc.ui.ssap, EBT_802_3_SAP)) 
52613 +                               return EBT_NOMATCH;
52614 +               if (FWINV(info->sap != hdr->llc.ui.dsap, EBT_802_3_SAP))
52615 +                               return EBT_NOMATCH;
52616 +       }
52617 +
52618 +       if (info->bitmask & EBT_802_3_TYPE) {
52619 +               if (!(hdr->llc.ui.dsap == CHECK_TYPE && hdr->llc.ui.ssap == CHECK_TYPE))
52620 +                       return EBT_NOMATCH;
52621 +               if (FWINV(info->type != type, EBT_802_3_TYPE)) 
52622 +                       return EBT_NOMATCH;
52623 +       }
52624 +
52625 +       return EBT_MATCH;
52626 +}
52627 +
52628 +static struct ebt_match filter_802_3;
52629 +static int ebt_802_3_check(const char *tablename, unsigned int hookmask,
52630 +   const struct ebt_entry *e, void *data, unsigned int datalen)
52631 +{
52632 +       struct ebt_802_3_info *info = (struct ebt_802_3_info *)data;
52633 +
52634 +       if (datalen < sizeof(struct ebt_802_3_info))
52635 +               return -EINVAL;
52636 +       if (info->bitmask & ~EBT_802_3_MASK || info->invflags & ~EBT_802_3_MASK)
52637 +               return -EINVAL;
52638 +
52639 +       return 0;
52640 +}
52641 +
52642 +static struct ebt_match filter_802_3 =
52643 +{
52644 +       .name           = EBT_802_3_MATCH,
52645 +       .match          = ebt_filter_802_3,
52646 +       .check          = ebt_802_3_check,
52647 +       .me             = THIS_MODULE,
52648 +};
52649 +
52650 +static int __init init(void)
52651 +{
52652 +       return ebt_register_match(&filter_802_3);
52653 +}
52654 +
52655 +static void __exit fini(void)
52656 +{
52657 +       ebt_unregister_match(&filter_802_3);
52658 +}
52659 +
52660 +module_init(init);
52661 +module_exit(fini);
52662 +MODULE_LICENSE("GPL");
52663 diff -Nru a/net/bridge/netfilter/ebt_arpreply.c b/net/bridge/netfilter/ebt_arpreply.c
52664 --- /dev/null   Wed Dec 31 16:00:00 1969
52665 +++ b/net/bridge/netfilter/ebt_arpreply.c       Sun Aug 24 04:31:46 2003
52666 @@ -0,0 +1,89 @@
52667 +/*
52668 + *  ebt_arpreply
52669 + *
52670 + *     Authors:
52671 + *     Grzegorz Borowiak <grzes@gnu.univ.gda.pl>
52672 + *     Bart De Schuymer <bdschuym@pandora.be>
52673 + *
52674 + *  August, 2003
52675 + *
52676 + */
52677 +
52678 +#include <linux/netfilter_bridge/ebtables.h>
52679 +#include <linux/netfilter_bridge/ebt_arpreply.h>
52680 +#include <linux/if_arp.h>
52681 +#include <net/arp.h>
52682 +#include <linux/module.h>
52683 +
52684 +static int ebt_target_reply(struct sk_buff **pskb, unsigned int hooknr,
52685 +   const struct net_device *in, const struct net_device *out,
52686 +   const void *data, unsigned int datalen)
52687 +{
52688 +       struct ebt_arpreply_info *info = (struct ebt_arpreply_info *)data;
52689 +       u32 sip, dip;
52690 +       struct arphdr ah;
52691 +       unsigned char sha[ETH_ALEN];
52692 +       struct sk_buff *skb = *pskb;
52693 +
52694 +       if (skb_copy_bits(skb, 0, &ah, sizeof(ah)))
52695 +               return EBT_DROP;
52696 +
52697 +       if (ah.ar_op != __constant_htons(ARPOP_REQUEST) || ah.ar_hln != ETH_ALEN
52698 +           || ah.ar_pro != __constant_htons(ETH_P_IP) || ah.ar_pln != 4)
52699 +               return EBT_CONTINUE;
52700 +
52701 +       if (skb_copy_bits(skb, sizeof(ah), &sha, ETH_ALEN))
52702 +               return EBT_DROP;
52703 +
52704 +       if (skb_copy_bits(skb, sizeof(ah) + ETH_ALEN, &sip, sizeof(sip)))
52705 +               return EBT_DROP;
52706 +
52707 +       if (skb_copy_bits(skb, sizeof(ah) + 2 * ETH_ALEN + sizeof(sip),
52708 +           &dip, sizeof(dip)))
52709 +               return EBT_DROP;
52710 +
52711 +       arp_send(ARPOP_REPLY, ETH_P_ARP, sip, (struct net_device *)in,
52712 +                dip, sha, info->mac, sha);
52713 +
52714 +       return info->target;
52715 +}
52716 +
52717 +static int ebt_target_reply_check(const char *tablename, unsigned int hookmask,
52718 +   const struct ebt_entry *e, void *data, unsigned int datalen)
52719 +{
52720 +       struct ebt_arpreply_info *info = (struct ebt_arpreply_info *)data;
52721 +
52722 +       if (datalen != EBT_ALIGN(sizeof(struct ebt_arpreply_info)))
52723 +               return -EINVAL;
52724 +       if (BASE_CHAIN && info->target == EBT_RETURN)
52725 +               return -EINVAL;
52726 +       if (e->ethproto != __constant_htons(ETH_P_ARP) ||
52727 +           e->invflags & EBT_IPROTO)
52728 +               return -EINVAL;
52729 +       CLEAR_BASE_CHAIN_BIT;
52730 +       if (strcmp(tablename, "nat") || hookmask & ~(1 << NF_BR_PRE_ROUTING))
52731 +               return -EINVAL;
52732 +       return 0;
52733 +}
52734 +
52735 +static struct ebt_target reply_target =
52736 +{
52737 +       .name           = EBT_ARPREPLY_TARGET,
52738 +       .target         = ebt_target_reply,
52739 +       .check          = ebt_target_reply_check,
52740 +       .me             = THIS_MODULE,
52741 +};
52742 +
52743 +static int __init init(void)
52744 +{
52745 +       return ebt_register_target(&reply_target);
52746 +}
52747 +
52748 +static void __exit fini(void)
52749 +{
52750 +       ebt_unregister_target(&reply_target);
52751 +}
52752 +
52753 +module_init(init);
52754 +module_exit(fini);
52755 +MODULE_LICENSE("GPL");
52756 diff -Nru a/net/core/dev.c b/net/core/dev.c
52757 --- a/net/core/dev.c    Tue Aug 19 21:04:26 2003
52758 +++ b/net/core/dev.c    Mon Sep  1 12:14:20 2003
52759 @@ -845,11 +845,7 @@
52760          * engine, but this requires more changes in devices. */
52761  
52762         smp_mb__after_clear_bit(); /* Commit netif_running(). */
52763 -       while (test_bit(__LINK_STATE_RX_SCHED, &dev->state)) {
52764 -               /* No hurry. */
52765 -               current->state = TASK_INTERRUPTIBLE;
52766 -               schedule_timeout(1);
52767 -       }
52768 +       netif_poll_disable(dev);
52769  
52770         /*
52771          *      Call the device specific close. This cannot fail.
52772 @@ -1210,7 +1206,7 @@
52773  int lo_cong = 100;
52774  int mod_cong = 290;
52775  
52776 -struct netif_rx_stats netdev_rx_stat[NR_CPUS];
52777 +DEFINE_PER_CPU(struct netif_rx_stats, netdev_rx_stat) = { 0, };
52778  
52779  
52780  #ifdef CONFIG_NET_HW_FLOWCONTROL
52781 @@ -1359,7 +1355,7 @@
52782         this_cpu = smp_processor_id();
52783         queue = &__get_cpu_var(softnet_data);
52784  
52785 -       netdev_rx_stat[this_cpu].total++;
52786 +       __get_cpu_var(netdev_rx_stat).total++;
52787         if (queue->input_pkt_queue.qlen <= netdev_max_backlog) {
52788                 if (queue->input_pkt_queue.qlen) {
52789                         if (queue->throttle)
52790 @@ -1389,14 +1385,14 @@
52791  
52792         if (!queue->throttle) {
52793                 queue->throttle = 1;
52794 -               netdev_rx_stat[this_cpu].throttled++;
52795 +               __get_cpu_var(netdev_rx_stat).throttled++;
52796  #ifdef CONFIG_NET_HW_FLOWCONTROL
52797                 atomic_inc(&netdev_dropping);
52798  #endif
52799         }
52800  
52801  drop:
52802 -       netdev_rx_stat[this_cpu].dropped++;
52803 +       __get_cpu_var(netdev_rx_stat).dropped++;
52804         local_irq_restore(flags);
52805  
52806         kfree_skb(skb);
52807 @@ -1537,11 +1533,11 @@
52808  
52809         skb_bond(skb);
52810  
52811 -       netdev_rx_stat[smp_processor_id()].total++;
52812 +       __get_cpu_var(netdev_rx_stat).total++;
52813  
52814  #ifdef CONFIG_NET_FASTROUTE
52815         if (skb->pkt_type == PACKET_FASTROUTE) {
52816 -               netdev_rx_stat[smp_processor_id()].fastroute_deferred_out++;
52817 +               __get_cpu_var(netdev_rx_stat).fastroute_deferred_out++;
52818                 return dev_queue_xmit(skb);
52819         }
52820  #endif
52821 @@ -1657,7 +1653,7 @@
52822  
52823         list_del(&backlog_dev->poll_list);
52824         smp_mb__before_clear_bit();
52825 -       clear_bit(__LINK_STATE_RX_SCHED, &backlog_dev->state);
52826 +       netif_poll_enable(backlog_dev);
52827  
52828         if (queue->throttle) {
52829                 queue->throttle = 0;
52830 @@ -1672,7 +1668,6 @@
52831  
52832  static void net_rx_action(struct softirq_action *h)
52833  {
52834 -       int this_cpu = smp_processor_id();
52835         struct softnet_data *queue = &__get_cpu_var(softnet_data);
52836         unsigned long start_time = jiffies;
52837         int budget = netdev_max_backlog;
52838 @@ -1711,7 +1706,7 @@
52839         return;
52840  
52841  softnet_break:
52842 -       netdev_rx_stat[this_cpu].time_squeeze++;
52843 +       __get_cpu_var(netdev_rx_stat).time_squeeze++;
52844         __raise_softirq_irqoff(NET_RX_SOFTIRQ);
52845         goto out;
52846  }
52847 @@ -1912,7 +1907,7 @@
52848  
52849         while (*pos < NR_CPUS)
52850                 if (cpu_online(*pos)) {
52851 -                       rc = &netdev_rx_stat[*pos];
52852 +                       rc = &per_cpu(netdev_rx_stat, *pos);
52853                         break;
52854                 } else
52855                         ++*pos;
52856 diff -Nru a/net/core/ethtool.c b/net/core/ethtool.c
52857 --- a/net/core/ethtool.c        Thu Aug  7 13:16:02 2003
52858 +++ b/net/core/ethtool.c        Mon Sep  1 17:25:54 2003
52859 @@ -13,6 +13,7 @@
52860  #include <linux/errno.h>
52861  #include <linux/ethtool.h>
52862  #include <linux/netdevice.h>
52863 +#include <asm/uaccess.h>
52864  
52865  /* 
52866   * Some useful ethtool_ops methods that're device independent.
52867 @@ -30,6 +31,16 @@
52868         return (dev->features & NETIF_F_IP_CSUM) != 0;
52869  }
52870  
52871 +int ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
52872 +{
52873 +       if (data)
52874 +               dev->features |= NETIF_F_IP_CSUM;
52875 +       else
52876 +               dev->features &= ~NETIF_F_IP_CSUM;
52877 +
52878 +       return 0;
52879 +}
52880 +
52881  u32 ethtool_op_get_sg(struct net_device *dev)
52882  {
52883         return (dev->features & NETIF_F_SG) != 0;
52884 @@ -45,6 +56,21 @@
52885         return 0;
52886  }
52887  
52888 +u32 ethtool_op_get_tso(struct net_device *dev)
52889 +{
52890 +       return (dev->features & NETIF_F_TSO) != 0;
52891 +}
52892 +
52893 +int ethtool_op_set_tso(struct net_device *dev, u32 data)
52894 +{
52895 +       if (data)
52896 +               dev->features |= NETIF_F_TSO;
52897 +       else
52898 +               dev->features &= ~NETIF_F_TSO;
52899 +
52900 +       return 0;
52901 +}
52902 +
52903  /* Handlers for each ethtool command */
52904  
52905  static int ethtool_get_settings(struct net_device *dev, void *useraddr)
52906 @@ -454,6 +480,33 @@
52907         return dev->ethtool_ops->set_sg(dev, edata.data);
52908  }
52909  
52910 +static int ethtool_get_tso(struct net_device *dev, char *useraddr)
52911 +{
52912 +       struct ethtool_value edata = { ETHTOOL_GTSO };
52913 +
52914 +       if (!dev->ethtool_ops->get_tso)
52915 +               return -EOPNOTSUPP;
52916 +
52917 +       edata.data = dev->ethtool_ops->get_tso(dev);
52918 +
52919 +       if (copy_to_user(useraddr, &edata, sizeof(edata)))
52920 +               return -EFAULT;
52921 +       return 0;
52922 +}
52923 +
52924 +static int ethtool_set_tso(struct net_device *dev, char *useraddr)
52925 +{
52926 +       struct ethtool_value edata;
52927 +
52928 +       if (!dev->ethtool_ops->set_tso)
52929 +               return -EOPNOTSUPP;
52930 +
52931 +       if (copy_from_user(&edata, useraddr, sizeof(edata)))
52932 +               return -EFAULT;
52933 +
52934 +       return dev->ethtool_ops->set_tso(dev, edata.data);
52935 +}
52936 +
52937  static int ethtool_self_test(struct net_device *dev, char *useraddr)
52938  {
52939         struct ethtool_test test;
52940 @@ -502,15 +555,15 @@
52941  
52942         switch (gstrings.string_set) {
52943         case ETH_SS_TEST:
52944 -               if (ops->self_test_count)
52945 -                       gstrings.len = ops->self_test_count(dev);
52946 -               else
52947 +               if (!ops->self_test_count)
52948                         return -EOPNOTSUPP;
52949 +               gstrings.len = ops->self_test_count(dev);
52950 +               break;
52951         case ETH_SS_STATS:
52952 -               if (ops->get_stats_count)
52953 -                       gstrings.len = ops->get_stats_count(dev);
52954 -               else
52955 +               if (!ops->get_stats_count)
52956                         return -EOPNOTSUPP;
52957 +               gstrings.len = ops->get_stats_count(dev);
52958 +               break;
52959         default:
52960                 return -EINVAL;
52961         }
52962 @@ -653,6 +706,10 @@
52963                 return ethtool_get_sg(dev, useraddr);
52964         case ETHTOOL_SSG:
52965                 return ethtool_set_sg(dev, useraddr);
52966 +       case ETHTOOL_GTSO:
52967 +               return ethtool_get_tso(dev, useraddr);
52968 +       case ETHTOOL_STSO:
52969 +               return ethtool_set_tso(dev, useraddr);
52970         case ETHTOOL_TEST:
52971                 return ethtool_self_test(dev, useraddr);
52972         case ETHTOOL_GSTRINGS:
52973 diff -Nru a/net/core/netfilter.c b/net/core/netfilter.c
52974 --- a/net/core/netfilter.c      Wed Jul 30 16:57:26 2003
52975 +++ b/net/core/netfilter.c      Mon Sep  1 01:44:26 2003
52976 @@ -430,7 +430,7 @@
52977  {
52978         int status;
52979         struct nf_info *info;
52980 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
52981 +#ifdef CONFIG_BRIDGE_NETFILTER
52982         struct net_device *physindev = NULL;
52983         struct net_device *physoutdev = NULL;
52984  #endif
52985 @@ -467,7 +467,7 @@
52986         if (indev) dev_hold(indev);
52987         if (outdev) dev_hold(outdev);
52988  
52989 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
52990 +#ifdef CONFIG_BRIDGE_NETFILTER
52991         if (skb->nf_bridge) {
52992                 physindev = skb->nf_bridge->physindev;
52993                 if (physindev) dev_hold(physindev);
52994 @@ -483,7 +483,7 @@
52995                 /* James M doesn't say fuck enough. */
52996                 if (indev) dev_put(indev);
52997                 if (outdev) dev_put(outdev);
52998 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
52999 +#ifdef CONFIG_BRIDGE_NETFILTER
53000                 if (physindev) dev_put(physindev);
53001                 if (physoutdev) dev_put(physoutdev);
53002  #endif
53003 @@ -560,7 +560,7 @@
53004         /* Release those devices we held, or Alexey will kill me. */
53005         if (info->indev) dev_put(info->indev);
53006         if (info->outdev) dev_put(info->outdev);
53007 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
53008 +#ifdef CONFIG_BRIDGE_NETFILTER
53009         if (skb->nf_bridge) {
53010                 if (skb->nf_bridge->physindev)
53011                         dev_put(skb->nf_bridge->physindev);
53012 diff -Nru a/net/core/scm.c b/net/core/scm.c
53013 --- a/net/core/scm.c    Sun Mar 23 22:06:53 2003
53014 +++ b/net/core/scm.c    Sun Aug 24 05:14:27 2003
53015 @@ -41,7 +41,7 @@
53016  
53017  static __inline__ int scm_check_creds(struct ucred *creds)
53018  {
53019 -       if ((creds->pid == current->pid || capable(CAP_SYS_ADMIN)) &&
53020 +       if ((creds->pid == current->tgid || capable(CAP_SYS_ADMIN)) &&
53021             ((creds->uid == current->uid || creds->uid == current->euid ||
53022               creds->uid == current->suid) || capable(CAP_SETUID)) &&
53023             ((creds->gid == current->gid || creds->gid == current->egid ||
53024 diff -Nru a/net/core/skbuff.c b/net/core/skbuff.c
53025 --- a/net/core/skbuff.c Sat Aug  9 02:14:55 2003
53026 +++ b/net/core/skbuff.c Mon Sep  1 01:44:26 2003
53027 @@ -236,7 +236,7 @@
53028         }
53029  #ifdef CONFIG_NETFILTER
53030         nf_conntrack_put(skb->nfct);
53031 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
53032 +#ifdef CONFIG_BRIDGE_NETFILTER
53033         nf_bridge_put(skb->nf_bridge);
53034  #endif
53035  #endif
53036 @@ -301,7 +301,7 @@
53037  #ifdef CONFIG_NETFILTER_DEBUG
53038         C(nf_debug);
53039  #endif
53040 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
53041 +#ifdef CONFIG_BRIDGE_NETFILTER
53042         C(nf_bridge);
53043         nf_bridge_get(skb->nf_bridge);
53044  #endif
53045 @@ -359,7 +359,7 @@
53046  #ifdef CONFIG_NETFILTER_DEBUG
53047         new->nf_debug   = old->nf_debug;
53048  #endif
53049 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
53050 +#ifdef CONFIG_BRIDGE_NETFILTER
53051         new->nf_bridge  = old->nf_bridge;
53052         nf_bridge_get(old->nf_bridge);
53053  #endif
53054 diff -Nru a/net/econet/af_econet.c b/net/econet/af_econet.c
53055 --- a/net/econet/af_econet.c    Wed Jun 18 13:59:01 2003
53056 +++ b/net/econet/af_econet.c    Sat Aug 30 19:12:14 2003
53057 @@ -562,6 +562,7 @@
53058         sk->sk_reuse = 1;
53059         sock->ops = &econet_ops;
53060         sock_init_data(sock,sk);
53061 +       sk_set_owner(sk, THIS_MODULE);
53062  
53063         eo = ec_sk(sk) = kmalloc(sizeof(*eo), GFP_KERNEL);
53064         if (!eo)
53065 diff -Nru a/net/ipv4/igmp.c b/net/ipv4/igmp.c
53066 --- a/net/ipv4/igmp.c   Wed Aug 20 10:42:42 2003
53067 +++ b/net/ipv4/igmp.c   Wed Aug 27 23:45:13 2003
53068 @@ -2122,6 +2122,7 @@
53069                         break;
53070                 }
53071                 read_unlock(&in_dev->lock);
53072 +               in_dev_put(in_dev);
53073         }
53074         return im;
53075  }
53076 @@ -2181,7 +2182,9 @@
53077         if (likely(state->in_dev != NULL)) {
53078                 read_unlock(&state->in_dev->lock);
53079                 in_dev_put(state->in_dev);
53080 +               state->in_dev = NULL;
53081         }
53082 +       state->dev = NULL;
53083         read_unlock(&dev_base_lock);
53084  }
53085  
53086 @@ -2284,6 +2287,7 @@
53087                         spin_unlock_bh(&im->lock);
53088                 }
53089                 read_unlock_bh(&idev->lock);
53090 +               in_dev_put(idev);
53091         }
53092         return psf;
53093  }
53094 @@ -2350,12 +2354,16 @@
53095  static void igmp_mcf_seq_stop(struct seq_file *seq, void *v)
53096  {
53097         struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq);
53098 -       if (likely(state->im != NULL))
53099 +       if (likely(state->im != NULL)) {
53100                 spin_unlock_bh(&state->im->lock);
53101 +               state->im = NULL;
53102 +       }
53103         if (likely(state->idev != NULL)) {
53104                 read_unlock_bh(&state->idev->lock);
53105                 in_dev_put(state->idev);
53106 +               state->idev = NULL;
53107         }
53108 +       state->dev = NULL;
53109         read_unlock(&dev_base_lock);
53110  }
53111  
53112 diff -Nru a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
53113 --- a/net/ipv4/ip_output.c      Fri Jul 25 13:42:43 2003
53114 +++ b/net/ipv4/ip_output.c      Mon Sep  1 01:44:26 2003
53115 @@ -414,7 +414,7 @@
53116         /* Connection association is same as pre-frag packet */
53117         to->nfct = from->nfct;
53118         nf_conntrack_get(to->nfct);
53119 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
53120 +#ifdef CONFIG_BRIDGE_NETFILTER
53121         to->nf_bridge = from->nf_bridge;
53122         nf_bridge_get(to->nf_bridge);
53123  #endif
53124 diff -Nru a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c
53125 --- a/net/ipv4/ipvs/ip_vs_conn.c        Mon Jul 21 02:35:25 2003
53126 +++ b/net/ipv4/ipvs/ip_vs_conn.c        Thu Aug 28 01:21:50 2003
53127 @@ -837,7 +837,7 @@
53128                    "(size=%d, memory=%ldKbytes)\n",
53129                    IP_VS_CONN_TAB_SIZE,
53130                    (long)(IP_VS_CONN_TAB_SIZE*sizeof(struct list_head))/1024);
53131 -       IP_VS_DBG(0, "Each connection entry needs %d bytes at least\n",
53132 +       IP_VS_DBG(0, "Each connection entry needs %Zd bytes at least\n",
53133                   sizeof(struct ip_vs_conn));
53134  
53135         for (idx = 0; idx < IP_VS_CONN_TAB_SIZE; idx++) {
53136 diff -Nru a/net/ipv4/ipvs/ip_vs_dh.c b/net/ipv4/ipvs/ip_vs_dh.c
53137 --- a/net/ipv4/ipvs/ip_vs_dh.c  Sat Jul 12 22:20:28 2003
53138 +++ b/net/ipv4/ipvs/ip_vs_dh.c  Thu Aug 28 01:21:50 2003
53139 @@ -147,7 +147,7 @@
53140                 return -ENOMEM;
53141         }
53142         svc->sched_data = tbl;
53143 -       IP_VS_DBG(6, "DH hash table (memory=%dbytes) allocated for "
53144 +       IP_VS_DBG(6, "DH hash table (memory=%Zdbytes) allocated for "
53145                   "current service\n",
53146                   sizeof(struct ip_vs_dh_bucket)*IP_VS_DH_TAB_SIZE);
53147  
53148 @@ -167,7 +167,7 @@
53149  
53150         /* release the table itself */
53151         kfree(svc->sched_data);
53152 -       IP_VS_DBG(6, "DH hash table (memory=%dbytes) released\n",
53153 +       IP_VS_DBG(6, "DH hash table (memory=%Zdbytes) released\n",
53154                   sizeof(struct ip_vs_dh_bucket)*IP_VS_DH_TAB_SIZE);
53155  
53156         return 0;
53157 diff -Nru a/net/ipv4/ipvs/ip_vs_lblc.c b/net/ipv4/ipvs/ip_vs_lblc.c
53158 --- a/net/ipv4/ipvs/ip_vs_lblc.c        Sat Jul 12 22:20:28 2003
53159 +++ b/net/ipv4/ipvs/ip_vs_lblc.c        Thu Aug 28 01:21:50 2003
53160 @@ -396,7 +396,7 @@
53161                 return -ENOMEM;
53162         }
53163         svc->sched_data = tbl;
53164 -       IP_VS_DBG(6, "LBLC hash table (memory=%dbytes) allocated for "
53165 +       IP_VS_DBG(6, "LBLC hash table (memory=%Zdbytes) allocated for "
53166                   "current service\n",
53167                   sizeof(struct ip_vs_lblc_table));
53168  
53169 @@ -436,7 +436,7 @@
53170  
53171         /* release the table itself */
53172         kfree(svc->sched_data);
53173 -       IP_VS_DBG(6, "LBLC hash table (memory=%dbytes) released\n",
53174 +       IP_VS_DBG(6, "LBLC hash table (memory=%Zdbytes) released\n",
53175                   sizeof(struct ip_vs_lblc_table));
53176  
53177         return 0;
53178 diff -Nru a/net/ipv4/ipvs/ip_vs_lblcr.c b/net/ipv4/ipvs/ip_vs_lblcr.c
53179 --- a/net/ipv4/ipvs/ip_vs_lblcr.c       Sat Jul 12 22:20:28 2003
53180 +++ b/net/ipv4/ipvs/ip_vs_lblcr.c       Thu Aug 28 01:21:50 2003
53181 @@ -649,7 +649,7 @@
53182                 return -ENOMEM;
53183         }
53184         svc->sched_data = tbl;
53185 -       IP_VS_DBG(6, "LBLCR hash table (memory=%dbytes) allocated for "
53186 +       IP_VS_DBG(6, "LBLCR hash table (memory=%Zdbytes) allocated for "
53187                   "current service\n",
53188                   sizeof(struct ip_vs_lblcr_table));
53189  
53190 @@ -692,7 +692,7 @@
53191  
53192         /* release the table itself */
53193         kfree(svc->sched_data);
53194 -       IP_VS_DBG(6, "LBLCR hash table (memory=%dbytes) released\n",
53195 +       IP_VS_DBG(6, "LBLCR hash table (memory=%Zdbytes) released\n",
53196                   sizeof(struct ip_vs_lblcr_table));
53197  
53198         return 0;
53199 diff -Nru a/net/ipv4/ipvs/ip_vs_sh.c b/net/ipv4/ipvs/ip_vs_sh.c
53200 --- a/net/ipv4/ipvs/ip_vs_sh.c  Sat Jul 12 22:20:28 2003
53201 +++ b/net/ipv4/ipvs/ip_vs_sh.c  Thu Aug 28 01:21:50 2003
53202 @@ -144,7 +144,7 @@
53203                 return -ENOMEM;
53204         }
53205         svc->sched_data = tbl;
53206 -       IP_VS_DBG(6, "SH hash table (memory=%dbytes) allocated for "
53207 +       IP_VS_DBG(6, "SH hash table (memory=%Zdbytes) allocated for "
53208                   "current service\n",
53209                   sizeof(struct ip_vs_sh_bucket)*IP_VS_SH_TAB_SIZE);
53210  
53211 @@ -164,7 +164,7 @@
53212  
53213         /* release the table itself */
53214         kfree(svc->sched_data);
53215 -       IP_VS_DBG(6, "SH hash table (memory=%dbytes) released\n",
53216 +       IP_VS_DBG(6, "SH hash table (memory=%Zdbytes) released\n",
53217                   sizeof(struct ip_vs_sh_bucket)*IP_VS_SH_TAB_SIZE);
53218  
53219         return 0;
53220 diff -Nru a/net/ipv4/ipvs/ip_vs_sync.c b/net/ipv4/ipvs/ip_vs_sync.c
53221 --- a/net/ipv4/ipvs/ip_vs_sync.c        Sat Jul 12 22:20:28 2003
53222 +++ b/net/ipv4/ipvs/ip_vs_sync.c        Thu Aug 28 01:21:50 2003
53223 @@ -851,7 +851,7 @@
53224                 return -EEXIST;
53225  
53226         IP_VS_DBG(7, "%s: pid %d\n", __FUNCTION__, current->pid);
53227 -       IP_VS_DBG(7, "Each ip_vs_sync_conn entry need %d bytes\n",
53228 +       IP_VS_DBG(7, "Each ip_vs_sync_conn entry need %Zd bytes\n",
53229                   sizeof(struct ip_vs_sync_conn));
53230  
53231         ip_vs_sync_state |= state;
53232 diff -Nru a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig
53233 --- a/net/ipv4/netfilter/Kconfig        Wed Jun 25 23:28:43 2003
53234 +++ b/net/ipv4/netfilter/Kconfig        Mon Sep  1 01:44:26 2003
53235 @@ -74,8 +74,7 @@
53236           <file:Documentation/modules.txt>.  If unsure, say `Y'.
53237  
53238  config IP_NF_QUEUE
53239 -       tristate "Userspace queueing via NETLINK (EXPERIMENTAL)"
53240 -       depends on EXPERIMENTAL
53241 +       tristate "Userspace queueing via NETLINK"
53242         help
53243           Netfilter has the ability to queue packets to user space: the
53244           netlink device can be used to access them using this driver.
53245 @@ -106,6 +105,16 @@
53246           If you want to compile it as a module, say M here and read
53247           <file:Documentation/modules.txt>.  If unsure, say `N'.
53248  
53249 +config IP_NF_MATCH_IPRANGE
53250 +       tristate "IP range match support"
53251 +       depends on IP_NF_IPTABLES
53252 +       help
53253 +         This option makes possible to match IP addresses against IP address
53254 +         ranges.
53255 +
53256 +         If you want to compile it as a module, say M here and read
53257 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
53258 +
53259  config IP_NF_MATCH_MAC
53260         tristate "MAC address match support"
53261         depends on IP_NF_IPTABLES
53262 @@ -239,7 +248,7 @@
53263  
53264  config IP_NF_MATCH_HELPER
53265         tristate "Helper match support"
53266 -       depends on IP_NF_CONNTRACK!=n && IP_NF_IPTABLES
53267 +       depends on IP_NF_CONNTRACK && IP_NF_IPTABLES
53268         help
53269           Helper matching allows you to match packets in dynamic connections
53270           tracked by a conntrack-helper, ie. ip_conntrack_ftp
53271 @@ -271,19 +280,9 @@
53272           If you want to compile it as a module, say M here and read
53273           Documentation/modules.txt.  If unsure, say `N'.
53274  
53275 -config IP_NF_MATCH_UNCLEAN
53276 -       tristate "Unclean match support (EXPERIMENTAL)"
53277 -       depends on EXPERIMENTAL && IP_NF_IPTABLES
53278 -       help
53279 -         Unclean packet matching matches any strange or invalid packets, by
53280 -         looking at a series of fields in the IP, TCP, UDP and ICMP headers.
53281 -
53282 -         If you want to compile it as a module, say M here and read
53283 -         <file:Documentation/modules.txt>.  If unsure, say `N'.
53284 -
53285  config IP_NF_MATCH_OWNER
53286 -       tristate "Owner match support (EXPERIMENTAL)"
53287 -       depends on EXPERIMENTAL && IP_NF_IPTABLES
53288 +       tristate "Owner match support"
53289 +       depends on IP_NF_IPTABLES
53290         help
53291           Packet owner matching allows you to match locally-generated packets
53292           based on who created them: the user, group, process or session.
53293 @@ -293,7 +292,7 @@
53294  
53295  config IP_NF_MATCH_PHYSDEV
53296         tristate "Physdev match support"
53297 -       depends on IP_NF_IPTABLES!=n && BRIDGE!=n
53298 +       depends on IP_NF_IPTABLES!=n && BRIDGE_NETFILTER
53299         help
53300           Physdev packet matching matches against the physical bridge ports
53301           the IP packet arrived on or will leave by.
53302 @@ -324,16 +323,6 @@
53303           If you want to compile it as a module, say M here and read
53304           <file:Documentation/modules.txt>.  If unsure, say `N'.
53305  
53306 -config IP_NF_TARGET_MIRROR
53307 -       tristate "MIRROR target support (EXPERIMENTAL)"
53308 -       depends on EXPERIMENTAL && IP_NF_FILTER
53309 -       help
53310 -         The MIRROR target allows a filtering rule to specify that an
53311 -         incoming packet should be bounced back to the sender.
53312 -
53313 -         If you want to compile it as a module, say M here and read
53314 -         <file:Documentation/modules.txt>.  If unsure, say `N'.
53315 -
53316  config IP_NF_NAT
53317         tristate "Full NAT"
53318         depends on IP_NF_IPTABLES && IP_NF_CONNTRACK
53319 @@ -375,6 +364,28 @@
53320           If you want to compile it as a module, say M here and read
53321           <file:Documentation/modules.txt>.  If unsure, say `N'.
53322  
53323 +config IP_NF_TARGET_NETMAP
53324 +       tristate "NETMAP target support"
53325 +       depends on IP_NF_NAT
53326 +       help
53327 +         NETMAP is an implementation of static 1:1 NAT mapping of network
53328 +         addresses. It maps the network address part, while keeping the host
53329 +         address part intact. It is similar to Fast NAT, except that
53330 +         Netfilter's connection tracking doesn't work well with Fast NAT.
53331 +
53332 +         If you want to compile it as a module, say M here and read
53333 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
53334 +
53335 +config IP_NF_TARGET_SAME
53336 +       tristate "SAME target support"
53337 +       depends on IP_NF_NAT
53338 +       help
53339 +         This option adds a `SAME' target, which works like the standard SNAT
53340 +         target, but attempts to give clients the same IP for all connections.
53341 +
53342 +         If you want to compile it as a module, say M here and read
53343 +         Documentation/modules.txt.  If unsure, say `N'.
53344 +
53345  config IP_NF_NAT_LOCAL
53346         bool "NAT of local connections (READ HELP)"
53347         depends on IP_NF_NAT
53348 @@ -490,6 +501,19 @@
53349           the routing method (see `Use netfilter MARK value as routing
53350           key') and can also be used by other subsystems to change their
53351           behavior.
53352 +
53353 +         If you want to compile it as a module, say M here and read
53354 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
53355 +
53356 +config IP_NF_TARGET_CLASSIFY
53357 +       tristate "CLASSIFY target support"
53358 +       depends on IP_NF_MANGLE
53359 +       help
53360 +         This option adds a `CLASSIFY' target, which enables the user to set
53361 +         the priority of a packet. Some qdiscs can use this value for
53362 +         classification, among these are:
53363 +
53364 +         atm, cbq, dsmark, pfifo_fast, htb, prio
53365  
53366           If you want to compile it as a module, say M here and read
53367           <file:Documentation/modules.txt>.  If unsure, say `N'.
53368 diff -Nru a/net/ipv4/netfilter/Makefile b/net/ipv4/netfilter/Makefile
53369 --- a/net/ipv4/netfilter/Makefile       Wed Jun 25 23:28:43 2003
53370 +++ b/net/ipv4/netfilter/Makefile       Sun Aug 24 17:25:23 2003
53371 @@ -44,6 +44,7 @@
53372  obj-$(CONFIG_IP_NF_MATCH_LIMIT) += ipt_limit.o
53373  obj-$(CONFIG_IP_NF_MATCH_MARK) += ipt_mark.o
53374  obj-$(CONFIG_IP_NF_MATCH_MAC) += ipt_mac.o
53375 +obj-$(CONFIG_IP_NF_MATCH_IPRANGE) += ipt_iprange.o
53376  
53377  obj-$(CONFIG_IP_NF_MATCH_PKTTYPE) += ipt_pkttype.o
53378  obj-$(CONFIG_IP_NF_MATCH_MULTIPORT) += ipt_multiport.o
53379 @@ -61,20 +62,21 @@
53380  obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o
53381  obj-$(CONFIG_IP_NF_MATCH_STATE) += ipt_state.o
53382  obj-$(CONFIG_IP_NF_MATCH_CONNTRACK) += ipt_conntrack.o
53383 -obj-$(CONFIG_IP_NF_MATCH_UNCLEAN) += ipt_unclean.o
53384  obj-$(CONFIG_IP_NF_MATCH_TCPMSS) += ipt_tcpmss.o
53385  
53386  obj-$(CONFIG_IP_NF_MATCH_PHYSDEV) += ipt_physdev.o
53387  
53388  # targets
53389  obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o
53390 -obj-$(CONFIG_IP_NF_TARGET_MIRROR) += ipt_MIRROR.o
53391  obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o
53392  obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
53393  obj-$(CONFIG_IP_NF_TARGET_DSCP) += ipt_DSCP.o
53394  obj-$(CONFIG_IP_NF_TARGET_MARK) += ipt_MARK.o
53395  obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
53396  obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
53397 +obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o
53398 +obj-$(CONFIG_IP_NF_TARGET_SAME) += ipt_SAME.o
53399 +obj-$(CONFIG_IP_NF_TARGET_CLASSIFY) += ipt_CLASSIFY.o
53400  obj-$(CONFIG_IP_NF_NAT_SNMP_BASIC) += ip_nat_snmp_basic.o
53401  obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o
53402  obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o
53403 diff -Nru a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
53404 --- a/net/ipv4/netfilter/arp_tables.c   Sat Aug  2 18:29:28 2003
53405 +++ b/net/ipv4/netfilter/arp_tables.c   Sun Aug 24 05:00:28 2003
53406 @@ -25,6 +25,10 @@
53407  
53408  #include <linux/netfilter_arp/arp_tables.h>
53409  
53410 +MODULE_LICENSE("GPL");
53411 +MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
53412 +MODULE_DESCRIPTION("arptables core");
53413 +
53414  /*#define DEBUG_ARP_TABLES*/
53415  /*#define DEBUG_ARP_TABLES_USER*/
53416  
53417 @@ -1324,4 +1328,3 @@
53418  
53419  module_init(init);
53420  module_exit(fini);
53421 -MODULE_LICENSE("GPL");
53422 diff -Nru a/net/ipv4/netfilter/arpt_mangle.c b/net/ipv4/netfilter/arpt_mangle.c
53423 --- a/net/ipv4/netfilter/arpt_mangle.c  Wed Jun 25 23:28:48 2003
53424 +++ b/net/ipv4/netfilter/arpt_mangle.c  Sun Aug 24 05:00:28 2003
53425 @@ -3,6 +3,10 @@
53426  #include <linux/netfilter_arp/arpt_mangle.h>
53427  #include <net/sock.h>
53428  
53429 +MODULE_LICENSE("GPL");
53430 +MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
53431 +MODULE_DESCRIPTION("arptables mangle table");
53432 +
53433  static unsigned int
53434  target(struct sk_buff **pskb, unsigned int hooknum, const struct net_device *in,
53435     const struct net_device *out, const void *targinfo, void *userinfo)
53436 @@ -98,4 +102,3 @@
53437  
53438  module_init(init);
53439  module_exit(fini);
53440 -MODULE_LICENSE("GPL");
53441 diff -Nru a/net/ipv4/netfilter/arptable_filter.c b/net/ipv4/netfilter/arptable_filter.c
53442 --- a/net/ipv4/netfilter/arptable_filter.c      Thu Jun 19 12:42:06 2003
53443 +++ b/net/ipv4/netfilter/arptable_filter.c      Sun Aug 24 05:00:28 2003
53444 @@ -8,6 +8,10 @@
53445  #include <linux/module.h>
53446  #include <linux/netfilter_arp/arp_tables.h>
53447  
53448 +MODULE_LICENSE("GPL");
53449 +MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
53450 +MODULE_DESCRIPTION("arptables filter table");
53451 +
53452  #define FILTER_VALID_HOOKS ((1 << NF_ARP_IN) | (1 << NF_ARP_OUT) | \
53453                            (1 << NF_ARP_FORWARD))
53454  
53455 @@ -209,4 +213,3 @@
53456  
53457  module_init(init);
53458  module_exit(fini);
53459 -MODULE_LICENSE("GPL");
53460 diff -Nru a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
53461 --- a/net/ipv4/netfilter/ip_conntrack_core.c    Sat Aug  2 18:29:28 2003
53462 +++ b/net/ipv4/netfilter/ip_conntrack_core.c    Sat Aug 30 20:35:04 2003
53463 @@ -13,7 +13,6 @@
53464   *     - export ip_conntrack[_expect]_{find_get,put} functions
53465   * */
53466  
53467 -#include <linux/version.h>
53468  #include <linux/config.h>
53469  #include <linux/types.h>
53470  #include <linux/icmp.h>
53471 @@ -285,14 +284,15 @@
53472  static void
53473  clean_from_lists(struct ip_conntrack *ct)
53474  {
53475 +       unsigned int ho, hr;
53476 +       
53477         DEBUGP("clean_from_lists(%p)\n", ct);
53478         MUST_BE_WRITE_LOCKED(&ip_conntrack_lock);
53479 -       LIST_DELETE(&ip_conntrack_hash
53480 -                   [hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple)],
53481 -                   &ct->tuplehash[IP_CT_DIR_ORIGINAL]);
53482 -       LIST_DELETE(&ip_conntrack_hash
53483 -                   [hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple)],
53484 -                   &ct->tuplehash[IP_CT_DIR_REPLY]);
53485 +
53486 +       ho = hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
53487 +       hr = hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
53488 +       LIST_DELETE(&ip_conntrack_hash[ho], &ct->tuplehash[IP_CT_DIR_ORIGINAL]);
53489 +       LIST_DELETE(&ip_conntrack_hash[hr], &ct->tuplehash[IP_CT_DIR_REPLY]);
53490  
53491         /* Destroy all un-established, pending expectations */
53492         remove_expectations(ct, 1);
53493 @@ -364,9 +364,10 @@
53494                     const struct ip_conntrack *ignored_conntrack)
53495  {
53496         struct ip_conntrack_tuple_hash *h;
53497 +       unsigned int hash = hash_conntrack(tuple);
53498  
53499         MUST_BE_READ_LOCKED(&ip_conntrack_lock);
53500 -       h = LIST_FIND(&ip_conntrack_hash[hash_conntrack(tuple)],
53501 +       h = LIST_FIND(&ip_conntrack_hash[hash],
53502                       conntrack_tuple_cmp,
53503                       struct ip_conntrack_tuple_hash *,
53504                       tuple, ignored_conntrack);
53505 diff -Nru a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_conntrack_ftp.c
53506 --- a/net/ipv4/netfilter/ip_conntrack_ftp.c     Sat Aug  2 18:29:28 2003
53507 +++ b/net/ipv4/netfilter/ip_conntrack_ftp.c     Sun Aug 24 05:00:28 2003
53508 @@ -11,6 +11,10 @@
53509  #include <linux/netfilter_ipv4/ip_conntrack_helper.h>
53510  #include <linux/netfilter_ipv4/ip_conntrack_ftp.h>
53511  
53512 +MODULE_LICENSE("GPL");
53513 +MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
53514 +MODULE_DESCRIPTION("ftp connection tracking helper");
53515 +
53516  /* This is slow, but it's simple. --RR */
53517  static char ftp_buffer[65536];
53518  
53519 @@ -439,6 +443,5 @@
53520  PROVIDES_CONNTRACK(ftp);
53521  EXPORT_SYMBOL(ip_ftp_lock);
53522  
53523 -MODULE_LICENSE("GPL");
53524  module_init(init);
53525  module_exit(fini);
53526 diff -Nru a/net/ipv4/netfilter/ip_conntrack_irc.c b/net/ipv4/netfilter/ip_conntrack_irc.c
53527 --- a/net/ipv4/netfilter/ip_conntrack_irc.c     Sat Aug  2 18:29:28 2003
53528 +++ b/net/ipv4/netfilter/ip_conntrack_irc.c     Sun Aug 24 05:00:28 2003
53529 @@ -41,8 +41,8 @@
53530  /* This is slow, but it's simple. --RR */
53531  static char irc_buffer[65536];
53532  
53533 -MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
53534 -MODULE_DESCRIPTION("IRC (DCC) connection tracking module");
53535 +MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
53536 +MODULE_DESCRIPTION("IRC (DCC) connection tracking helper");
53537  MODULE_LICENSE("GPL");
53538  #ifdef MODULE_PARM
53539  MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i");
53540 diff -Nru a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
53541 --- a/net/ipv4/netfilter/ip_conntrack_standalone.c      Mon Apr 28 02:27:56 2003
53542 +++ b/net/ipv4/netfilter/ip_conntrack_standalone.c      Sat Aug 30 20:35:04 2003
53543 @@ -14,7 +14,6 @@
53544  #include <linux/module.h>
53545  #include <linux/skbuff.h>
53546  #include <linux/proc_fs.h>
53547 -#include <linux/version.h>
53548  #include <net/checksum.h>
53549  
53550  #define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_conntrack_lock)
53551 diff -Nru a/net/ipv4/netfilter/ip_conntrack_tftp.c b/net/ipv4/netfilter/ip_conntrack_tftp.c
53552 --- a/net/ipv4/netfilter/ip_conntrack_tftp.c    Sat Aug  2 18:29:28 2003
53553 +++ b/net/ipv4/netfilter/ip_conntrack_tftp.c    Sun Aug 24 05:00:28 2003
53554 @@ -17,7 +17,7 @@
53555  #include <linux/netfilter_ipv4/ip_conntrack_tftp.h>
53556  
53557  MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
53558 -MODULE_DESCRIPTION("Netfilter connection tracking module for tftp");
53559 +MODULE_DESCRIPTION("tftp connection tracking helper");
53560  MODULE_LICENSE("GPL");
53561  
53562  #define MAX_PORTS 8
53563 @@ -44,7 +44,7 @@
53564  
53565         if (skb_copy_bits(skb, skb->nh.iph->ihl * 4 + sizeof(struct udphdr),
53566                           &tftph, sizeof(tftph)) != 0)
53567 -               return -1;
53568 +               return NF_ACCEPT;
53569  
53570         switch (ntohs(tftph.opcode)) {
53571         /* RRQ and WRQ works the same way */
53572 diff -Nru a/net/ipv4/netfilter/ip_fw_compat_masq.c b/net/ipv4/netfilter/ip_fw_compat_masq.c
53573 --- a/net/ipv4/netfilter/ip_fw_compat_masq.c    Sun May 11 22:12:07 2003
53574 +++ b/net/ipv4/netfilter/ip_fw_compat_masq.c    Sat Aug 30 20:35:04 2003
53575 @@ -13,7 +13,6 @@
53576  #include <linux/netdevice.h>
53577  #include <linux/inetdevice.h>
53578  #include <linux/proc_fs.h>
53579 -#include <linux/version.h>
53580  #include <linux/module.h>
53581  #include <net/route.h>
53582  
53583 diff -Nru a/net/ipv4/netfilter/ip_nat_amanda.c b/net/ipv4/netfilter/ip_nat_amanda.c
53584 --- a/net/ipv4/netfilter/ip_nat_amanda.c        Tue Jun 24 15:34:39 2003
53585 +++ b/net/ipv4/netfilter/ip_nat_amanda.c        Sun Aug 24 05:00:28 2003
53586 @@ -35,7 +35,7 @@
53587  #endif
53588  
53589  MODULE_AUTHOR("Brian J. Murrell <netfilter@interlinx.bc.ca>");
53590 -MODULE_DESCRIPTION("Amanda network address translation module");
53591 +MODULE_DESCRIPTION("Amanda NAT helper");
53592  MODULE_LICENSE("GPL");
53593  
53594  /* protects amanda part of conntracks */
53595 diff -Nru a/net/ipv4/netfilter/ip_nat_core.c b/net/ipv4/netfilter/ip_nat_core.c
53596 --- a/net/ipv4/netfilter/ip_nat_core.c  Sat Aug  2 18:29:28 2003
53597 +++ b/net/ipv4/netfilter/ip_nat_core.c  Sat Aug 30 20:35:04 2003
53598 @@ -2,7 +2,6 @@
53599  
53600  /* (c) 1999 Paul `Rusty' Russell.  Licenced under the GNU General
53601     Public Licence. */
53602 -#include <linux/version.h>
53603  #include <linux/module.h>
53604  #include <linux/types.h>
53605  #include <linux/timer.h>
53606 @@ -68,6 +67,7 @@
53607  static void ip_nat_cleanup_conntrack(struct ip_conntrack *conn)
53608  {
53609         struct ip_nat_info *info = &conn->nat.info;
53610 +       unsigned int hs, hp;
53611  
53612         if (!info->initialized)
53613                 return;
53614 @@ -75,21 +75,18 @@
53615         IP_NF_ASSERT(info->bysource.conntrack);
53616         IP_NF_ASSERT(info->byipsproto.conntrack);
53617  
53618 +       hs = hash_by_src(&conn->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src,
53619 +                        conn->tuplehash[IP_CT_DIR_ORIGINAL]
53620 +                        .tuple.dst.protonum);
53621 +
53622 +       hp = hash_by_ipsproto(conn->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip,
53623 +                             conn->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip,
53624 +                             conn->tuplehash[IP_CT_DIR_REPLY]
53625 +                             .tuple.dst.protonum);
53626 +
53627         WRITE_LOCK(&ip_nat_lock);
53628 -       LIST_DELETE(&bysource[hash_by_src(&conn->tuplehash[IP_CT_DIR_ORIGINAL]
53629 -                                         .tuple.src,
53630 -                                         conn->tuplehash[IP_CT_DIR_ORIGINAL]
53631 -                                         .tuple.dst.protonum)],
53632 -                   &info->bysource);
53633 -
53634 -       LIST_DELETE(&byipsproto
53635 -                   [hash_by_ipsproto(conn->tuplehash[IP_CT_DIR_REPLY]
53636 -                                     .tuple.src.ip,
53637 -                                     conn->tuplehash[IP_CT_DIR_REPLY]
53638 -                                     .tuple.dst.ip,
53639 -                                     conn->tuplehash[IP_CT_DIR_REPLY]
53640 -                                     .tuple.dst.protonum)],
53641 -                   &info->byipsproto);
53642 +       LIST_DELETE(&bysource[hs], &info->bysource);
53643 +       LIST_DELETE(&byipsproto[hp], &info->byipsproto);
53644         WRITE_UNLOCK(&ip_nat_lock);
53645  }
53646  
53647 @@ -246,11 +243,12 @@
53648            const struct ip_conntrack *conntrack)
53649  {
53650         unsigned int score = 0;
53651 +       unsigned int h;
53652  
53653         MUST_BE_READ_LOCKED(&ip_nat_lock);
53654 -       LIST_FIND(&byipsproto[hash_by_ipsproto(src, dst, protonum)],
53655 -                 fake_cmp, struct ip_nat_hash *, src, dst, protonum, &score,
53656 -                 conntrack);
53657 +       h = hash_by_ipsproto(src, dst, protonum);
53658 +       LIST_FIND(&byipsproto[h], fake_cmp, struct ip_nat_hash *,
53659 +                 src, dst, protonum, &score, conntrack);
53660  
53661         return score;
53662  }
53663 diff -Nru a/net/ipv4/netfilter/ip_nat_ftp.c b/net/ipv4/netfilter/ip_nat_ftp.c
53664 --- a/net/ipv4/netfilter/ip_nat_ftp.c   Sat Aug  2 18:29:28 2003
53665 +++ b/net/ipv4/netfilter/ip_nat_ftp.c   Sun Aug 24 05:00:28 2003
53666 @@ -10,6 +10,10 @@
53667  #include <linux/netfilter_ipv4/ip_conntrack_ftp.h>
53668  #include <linux/netfilter_ipv4/ip_conntrack_helper.h>
53669  
53670 +MODULE_LICENSE("GPL");
53671 +MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
53672 +MODULE_DESCRIPTION("ftp NAT helper");
53673 +
53674  #if 0
53675  #define DEBUGP printk
53676  #else
53677 @@ -342,4 +346,3 @@
53678  
53679  module_init(init);
53680  module_exit(fini);
53681 -MODULE_LICENSE("GPL");
53682 diff -Nru a/net/ipv4/netfilter/ip_nat_helper.c b/net/ipv4/netfilter/ip_nat_helper.c
53683 --- a/net/ipv4/netfilter/ip_nat_helper.c        Thu Jul 17 14:50:26 2003
53684 +++ b/net/ipv4/netfilter/ip_nat_helper.c        Sat Aug 30 20:35:04 2003
53685 @@ -12,7 +12,6 @@
53686   *             - make ip_nat_resize_packet more generic (TCP and UDP)
53687   *             - add ip_nat_mangle_udp_packet
53688   */
53689 -#include <linux/version.h>
53690  #include <linux/config.h>
53691  #include <linux/module.h>
53692  #include <linux/kmod.h>
53693 diff -Nru a/net/ipv4/netfilter/ip_nat_irc.c b/net/ipv4/netfilter/ip_nat_irc.c
53694 --- a/net/ipv4/netfilter/ip_nat_irc.c   Sat Aug  2 18:29:28 2003
53695 +++ b/net/ipv4/netfilter/ip_nat_irc.c   Sun Aug 24 05:00:28 2003
53696 @@ -39,7 +39,7 @@
53697  static int ports_c;
53698  
53699  MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
53700 -MODULE_DESCRIPTION("IRC (DCC) network address translation module");
53701 +MODULE_DESCRIPTION("IRC (DCC) NAT helper");
53702  MODULE_LICENSE("GPL");
53703  #ifdef MODULE_PARM
53704  MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i");
53705 diff -Nru a/net/ipv4/netfilter/ip_nat_rule.c b/net/ipv4/netfilter/ip_nat_rule.c
53706 --- a/net/ipv4/netfilter/ip_nat_rule.c  Wed May 21 16:29:38 2003
53707 +++ b/net/ipv4/netfilter/ip_nat_rule.c  Sat Aug 30 20:35:04 2003
53708 @@ -9,7 +9,6 @@
53709  #include <linux/proc_fs.h>
53710  #include <net/checksum.h>
53711  #include <linux/bitops.h>
53712 -#include <linux/version.h>
53713  
53714  #define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_nat_lock)
53715  #define ASSERT_WRITE_LOCK(x) MUST_BE_WRITE_LOCKED(&ip_nat_lock)
53716 diff -Nru a/net/ipv4/netfilter/ip_nat_snmp_basic.c b/net/ipv4/netfilter/ip_nat_snmp_basic.c
53717 --- a/net/ipv4/netfilter/ip_nat_snmp_basic.c    Sat Aug  2 18:29:28 2003
53718 +++ b/net/ipv4/netfilter/ip_nat_snmp_basic.c    Sun Aug 24 05:00:28 2003
53719 @@ -56,7 +56,9 @@
53720  #include <asm/uaccess.h>
53721  #include <asm/checksum.h>
53722  
53723 -
53724 +MODULE_LICENSE("GPL");
53725 +MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");
53726 +MODULE_DESCRIPTION("Basic SNMP Application Layer Gateway");
53727  
53728  #define SNMP_PORT 161
53729  #define SNMP_TRAP_PORT 162
53730 @@ -1357,5 +1359,3 @@
53731  module_exit(fini);
53732  
53733  MODULE_PARM(debug, "i");
53734 -MODULE_DESCRIPTION("Basic SNMP Application Layer Gateway");
53735 -MODULE_LICENSE("GPL");
53736 diff -Nru a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c
53737 --- a/net/ipv4/netfilter/ip_nat_standalone.c    Sat May 17 22:10:44 2003
53738 +++ b/net/ipv4/netfilter/ip_nat_standalone.c    Sat Aug 30 20:35:04 2003
53739 @@ -23,7 +23,6 @@
53740  #include <linux/proc_fs.h>
53741  #include <net/checksum.h>
53742  #include <linux/spinlock.h>
53743 -#include <linux/version.h>
53744  
53745  #define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_nat_lock)
53746  #define ASSERT_WRITE_LOCK(x) MUST_BE_WRITE_LOCKED(&ip_nat_lock)
53747 diff -Nru a/net/ipv4/netfilter/ip_nat_tftp.c b/net/ipv4/netfilter/ip_nat_tftp.c
53748 --- a/net/ipv4/netfilter/ip_nat_tftp.c  Tue May  6 01:04:01 2003
53749 +++ b/net/ipv4/netfilter/ip_nat_tftp.c  Sun Aug 24 05:00:28 2003
53750 @@ -30,7 +30,7 @@
53751  #include <linux/netfilter_ipv4/ip_nat_rule.h>
53752  
53753  MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
53754 -MODULE_DESCRIPTION("Netfilter NAT helper for tftp");
53755 +MODULE_DESCRIPTION("tfpt NAT helper");
53756  MODULE_LICENSE("GPL");
53757  
53758  #define MAX_PORTS 8
53759 diff -Nru a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
53760 --- a/net/ipv4/netfilter/ip_tables.c    Sat Aug  2 18:29:28 2003
53761 +++ b/net/ipv4/netfilter/ip_tables.c    Sun Aug 24 05:00:28 2003
53762 @@ -25,6 +25,10 @@
53763  
53764  #include <linux/netfilter_ipv4/ip_tables.h>
53765  
53766 +MODULE_LICENSE("GPL");
53767 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
53768 +MODULE_DESCRIPTION("IPv4 packet filter");
53769 +
53770  /*#define DEBUG_IP_FIREWALL*/
53771  /*#define DEBUG_ALLOW_ALL*/ /* Useful for remote debugging */
53772  /*#define DEBUG_IP_FIREWALL_USER*/
53773 @@ -1845,4 +1849,3 @@
53774  
53775  module_init(init);
53776  module_exit(fini);
53777 -MODULE_LICENSE("GPL");
53778 diff -Nru a/net/ipv4/netfilter/ipchains_core.c b/net/ipv4/netfilter/ipchains_core.c
53779 --- a/net/ipv4/netfilter/ipchains_core.c        Wed Jun  4 17:57:08 2003
53780 +++ b/net/ipv4/netfilter/ipchains_core.c        Sun Aug 24 05:00:28 2003
53781 @@ -100,6 +100,9 @@
53782  #include <linux/proc_fs.h>
53783  #include <linux/stat.h>
53784  
53785 +MODULE_LICENSE("Dual BSD/GPL");
53786 +MODULE_DESCRIPTION("ipchains backwards compatibility layer");
53787 +
53788  /* Understanding locking in this code: (thanks to Alan Cox for using
53789   * little words to explain this to me). -- PR
53790   *
53791 @@ -1842,4 +1845,3 @@
53792  #endif
53793         return ret;
53794  }
53795 -MODULE_LICENSE("Dual BSD/GPL");
53796 diff -Nru a/net/ipv4/netfilter/ipfwadm_core.c b/net/ipv4/netfilter/ipfwadm_core.c
53797 --- a/net/ipv4/netfilter/ipfwadm_core.c Wed Jun  4 17:57:08 2003
53798 +++ b/net/ipv4/netfilter/ipfwadm_core.c Sat Aug 30 20:35:04 2003
53799 @@ -131,9 +131,9 @@
53800  #include <net/checksum.h>
53801  #include <linux/proc_fs.h>
53802  #include <linux/stat.h>
53803 -#include <linux/version.h>
53804  
53805  MODULE_LICENSE("Dual BSD/GPL");
53806 +MODULE_DESCRIPTION("ipfwadm backwards compatibility layer");
53807  
53808  /*
53809   *     Implement IP packet firewall
53810 diff -Nru a/net/ipv4/netfilter/ipt_CLASSIFY.c b/net/ipv4/netfilter/ipt_CLASSIFY.c
53811 --- /dev/null   Wed Dec 31 16:00:00 1969
53812 +++ b/net/ipv4/netfilter/ipt_CLASSIFY.c Sun Aug 24 19:51:27 2003
53813 @@ -0,0 +1,86 @@
53814 +/*
53815 + * This is a module which is used for setting the skb->priority field
53816 + * of an skb for qdisc classification.
53817 + */
53818 +
53819 +#include <linux/module.h>
53820 +#include <linux/skbuff.h>
53821 +#include <linux/ip.h>
53822 +#include <net/checksum.h>
53823 +
53824 +#include <linux/netfilter_ipv4/ip_tables.h>
53825 +#include <linux/netfilter_ipv4/ipt_CLASSIFY.h>
53826 +
53827 +MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
53828 +MODULE_LICENSE("GPL");
53829 +MODULE_DESCRIPTION("iptables qdisc classification target module");
53830 +
53831 +static unsigned int
53832 +target(struct sk_buff **pskb,
53833 +       const struct net_device *in,
53834 +       const struct net_device *out,
53835 +       unsigned int hooknum,
53836 +       const void *targinfo,
53837 +       void *userinfo)
53838 +{
53839 +       const struct ipt_classify_target_info *clinfo = targinfo;
53840 +
53841 +       if((*pskb)->priority != clinfo->priority) {
53842 +               (*pskb)->priority = clinfo->priority;
53843 +               (*pskb)->nfcache |= NFC_ALTERED;
53844 +       }
53845 +
53846 +       return IPT_CONTINUE;
53847 +}
53848 +
53849 +static int
53850 +checkentry(const char *tablename,
53851 +           const struct ipt_entry *e,
53852 +           void *targinfo,
53853 +           unsigned int targinfosize,
53854 +           unsigned int hook_mask)
53855 +{
53856 +       if (targinfosize != IPT_ALIGN(sizeof(struct ipt_classify_target_info))){
53857 +               printk(KERN_ERR "CLASSIFY: invalid size (%u != %Zu).\n",
53858 +                      targinfosize,
53859 +                      IPT_ALIGN(sizeof(struct ipt_classify_target_info)));
53860 +               return 0;
53861 +       }
53862 +       
53863 +       if (hook_mask & ~(1 << NF_IP_POST_ROUTING)) {
53864 +               printk(KERN_ERR "CLASSIFY: only valid in POST_ROUTING.\n");
53865 +               return 0;
53866 +       }
53867 +
53868 +       if (strcmp(tablename, "mangle") != 0) {
53869 +               printk(KERN_WARNING "CLASSIFY: can only be called from "
53870 +                                   "\"mangle\" table, not \"%s\".\n",
53871 +                                   tablename);
53872 +               return 0;
53873 +       }
53874 +
53875 +       return 1;
53876 +}
53877 +
53878 +static struct ipt_target ipt_classify_reg = { 
53879 +       .name           = "CLASSIFY", 
53880 +       .target         = target,
53881 +       .checkentry     = checkentry,
53882 +       .me             = THIS_MODULE,
53883 +};
53884 +
53885 +static int __init init(void)
53886 +{
53887 +       if (ipt_register_target(&ipt_classify_reg))
53888 +               return -EINVAL;
53889 +
53890 +       return 0;
53891 +}
53892 +
53893 +static void __exit fini(void)
53894 +{
53895 +       ipt_unregister_target(&ipt_classify_reg);
53896 +}
53897 +
53898 +module_init(init);
53899 +module_exit(fini);
53900 diff -Nru a/net/ipv4/netfilter/ipt_DSCP.c b/net/ipv4/netfilter/ipt_DSCP.c
53901 --- a/net/ipv4/netfilter/ipt_DSCP.c     Wed May 21 16:36:54 2003
53902 +++ b/net/ipv4/netfilter/ipt_DSCP.c     Sun Aug 24 05:00:28 2003
53903 @@ -17,8 +17,8 @@
53904  #include <linux/netfilter_ipv4/ip_tables.h>
53905  #include <linux/netfilter_ipv4/ipt_DSCP.h>
53906  
53907 -MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
53908 -MODULE_DESCRIPTION("IP tables DSCP modification module");
53909 +MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
53910 +MODULE_DESCRIPTION("iptables DSCP modification module");
53911  MODULE_LICENSE("GPL");
53912  
53913  static unsigned int
53914 diff -Nru a/net/ipv4/netfilter/ipt_ECN.c b/net/ipv4/netfilter/ipt_ECN.c
53915 --- a/net/ipv4/netfilter/ipt_ECN.c      Wed May 21 16:36:54 2003
53916 +++ b/net/ipv4/netfilter/ipt_ECN.c      Sun Aug 24 05:00:28 2003
53917 @@ -17,6 +17,8 @@
53918  #include <linux/netfilter_ipv4/ipt_ECN.h>
53919  
53920  MODULE_LICENSE("GPL");
53921 +MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
53922 +MODULE_DESCRIPTION("iptables ECN modification module");
53923  
53924  /* set ECT codepoint from IP header.
53925   *     return 0 if there was an error. */
53926 diff -Nru a/net/ipv4/netfilter/ipt_LOG.c b/net/ipv4/netfilter/ipt_LOG.c
53927 --- a/net/ipv4/netfilter/ipt_LOG.c      Sat Aug  2 22:47:01 2003
53928 +++ b/net/ipv4/netfilter/ipt_LOG.c      Mon Sep  1 01:44:26 2003
53929 @@ -13,6 +13,10 @@
53930  #include <linux/netfilter_ipv4/ip_tables.h>
53931  #include <linux/netfilter_ipv4/ipt_LOG.h>
53932  
53933 +MODULE_LICENSE("GPL");
53934 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
53935 +MODULE_DESCRIPTION("iptables syslog logging module");
53936 +
53937  #if 0
53938  #define DEBUGP printk
53939  #else
53940 @@ -329,7 +333,7 @@
53941                loginfo->prefix,
53942                in ? in->name : "",
53943                out ? out->name : "");
53944 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
53945 +#ifdef CONFIG_BRIDGE_NETFILTER
53946         if ((*pskb)->nf_bridge) {
53947                 struct net_device *physindev = (*pskb)->nf_bridge->physindev;
53948                 struct net_device *physoutdev = (*pskb)->nf_bridge->physoutdev;
53949 @@ -413,4 +417,3 @@
53950  
53951  module_init(init);
53952  module_exit(fini);
53953 -MODULE_LICENSE("GPL");
53954 diff -Nru a/net/ipv4/netfilter/ipt_MARK.c b/net/ipv4/netfilter/ipt_MARK.c
53955 --- a/net/ipv4/netfilter/ipt_MARK.c     Wed May 21 16:36:54 2003
53956 +++ b/net/ipv4/netfilter/ipt_MARK.c     Sun Aug 24 05:00:28 2003
53957 @@ -7,6 +7,10 @@
53958  #include <linux/netfilter_ipv4/ip_tables.h>
53959  #include <linux/netfilter_ipv4/ipt_MARK.h>
53960  
53961 +MODULE_LICENSE("GPL");
53962 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
53963 +MODULE_DESCRIPTION("iptables MARK modification module");
53964 +
53965  static unsigned int
53966  target(struct sk_buff **pskb,
53967         const struct net_device *in,
53968 @@ -68,4 +72,3 @@
53969  
53970  module_init(init);
53971  module_exit(fini);
53972 -MODULE_LICENSE("GPL");
53973 diff -Nru a/net/ipv4/netfilter/ipt_MASQUERADE.c b/net/ipv4/netfilter/ipt_MASQUERADE.c
53974 --- a/net/ipv4/netfilter/ipt_MASQUERADE.c       Mon Aug 11 22:46:31 2003
53975 +++ b/net/ipv4/netfilter/ipt_MASQUERADE.c       Sun Aug 24 05:00:28 2003
53976 @@ -12,6 +12,10 @@
53977  #include <linux/netfilter_ipv4/ip_nat_rule.h>
53978  #include <linux/netfilter_ipv4/ip_tables.h>
53979  
53980 +MODULE_LICENSE("GPL");
53981 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
53982 +MODULE_DESCRIPTION("iptables MASQUERADE target module");
53983 +
53984  #if 0
53985  #define DEBUGP printk
53986  #else
53987 @@ -213,4 +217,3 @@
53988  
53989  module_init(init);
53990  module_exit(fini);
53991 -MODULE_LICENSE("GPL");
53992 diff -Nru a/net/ipv4/netfilter/ipt_MIRROR.c b/net/ipv4/netfilter/ipt_MIRROR.c
53993 --- a/net/ipv4/netfilter/ipt_MIRROR.c   Fri Jul 25 15:22:30 2003
53994 +++ /dev/null   Wed Dec 31 16:00:00 1969
53995 @@ -1,222 +0,0 @@
53996 -/*
53997 -  This is a module which is used for resending packets with inverted src and dst.
53998 -
53999 -  Based on code from: ip_nat_dumb.c,v 1.9 1999/08/20
54000 -  and various sources.
54001 -
54002 -  Copyright (C) 2000 Emmanuel Roger <winfield@freegates.be>
54003 -
54004 -  Changes:
54005 -       25 Aug 2001 Harald Welte <laforge@gnumonks.org>
54006 -               - decrement and check TTL if not called from FORWARD hook
54007 -       18 Jul 2003 Harald Welte <laforge@netfilter.org>
54008 -               - merge Patrick McHardy's mirror fixes from 2.4.22 to
54009 -                 2.6.0-test1
54010 -       19 Jul 2003 Harald Welte <laforge@netfilter.org>
54011 -               - merge Patrick McHardy's rp_filter fixes from 2.4.22 to
54012 -                 2.6.0-test1
54013 -
54014 -  This program is free software; you can redistribute it and/or modify it
54015 -  under the terms of the GNU General Public License as published by the
54016 -  Free Software Foundation; either version 2 of the License, or (at your
54017 -  option) any later version.
54018 -
54019 -  This program is distributed in the hope that it will be useful, but
54020 -  WITHOUT ANY WARRANTY; without even the implied warranty of
54021 -  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
54022 -  General Public License for more details.
54023 -
54024 -  You should have received a copy of the GNU General Public License
54025 -  along with this program; if not, write to the Free Software Foundation,
54026 -  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
54027 - */
54028 -#include <linux/module.h>
54029 -#include <linux/skbuff.h>
54030 -#include <linux/ip.h>
54031 -#include <net/ip.h>
54032 -#include <net/icmp.h>
54033 -#include <linux/netfilter_ipv4/ip_tables.h>
54034 -#include <linux/netdevice.h>
54035 -#include <linux/route.h>
54036 -#include <net/route.h>
54037 -
54038 -#if 0
54039 -#define DEBUGP printk
54040 -#else
54041 -#define DEBUGP(format, args...)
54042 -#endif
54043 -
54044 -static inline struct rtable *route_mirror(struct sk_buff *skb, int local)
54045 -{
54046 -        struct iphdr *iph = skb->nh.iph;
54047 -       struct dst_entry *odst;
54048 -       struct flowi fl = {};
54049 -       struct rtable *rt;
54050 -
54051 -       if (local) {
54052 -               fl.nl_u.ip4_u.daddr = iph->saddr;
54053 -               fl.nl_u.ip4_u.saddr = iph->daddr;
54054 -               fl.nl_u.ip4_u.tos = RT_TOS(iph->tos);
54055 -
54056 -               if (ip_route_output_key(&rt, &fl) != 0)
54057 -                       return NULL;
54058 -       } else {
54059 -               /* non-local src, find valid iif to satisfy
54060 -                * rp-filter when calling ip_route_input(). */
54061 -               fl.nl_u.ip4_u.daddr = iph->daddr;
54062 -               if (ip_route_output_key(&rt, &fl) != 0)
54063 -                       return NULL;
54064 -
54065 -               odst = skb->dst;
54066 -               if (ip_route_input(skb, iph->saddr, iph->daddr,
54067 -                                       RT_TOS(iph->tos), rt->u.dst.dev) != 0) {
54068 -                       dst_release(&rt->u.dst);
54069 -                       return NULL;
54070 -               }
54071 -               dst_release(&rt->u.dst);
54072 -               rt = (struct rtable *)skb->dst;
54073 -               skb->dst = odst;
54074 -       }
54075 -
54076 -       if (rt->u.dst.error) {
54077 -               dst_release(&rt->u.dst);
54078 -               rt = NULL;
54079 -       }
54080 -
54081 -       return rt;
54082 -}
54083 -
54084 -static inline void ip_rewrite(struct sk_buff *skb)
54085 -{
54086 -       u32 odaddr, osaddr;
54087 -
54088 -       odaddr = skb->nh.iph->saddr;
54089 -       osaddr = skb->nh.iph->daddr;
54090 -
54091 -       skb->nfcache |= NFC_ALTERED;
54092 -
54093 -       /* Rewrite IP header */
54094 -       skb->nh.iph->daddr = odaddr;
54095 -       skb->nh.iph->saddr = osaddr;
54096 -}
54097 -
54098 -/* Stolen from ip_finish_output2 */
54099 -static void ip_direct_send(struct sk_buff *skb)
54100 -{
54101 -       struct dst_entry *dst = skb->dst;
54102 -       struct hh_cache *hh = dst->hh;
54103 -
54104 -       if (hh) {
54105 -               int hh_alen;
54106 -
54107 -               read_lock_bh(&hh->hh_lock);
54108 -               hh_alen = HH_DATA_ALIGN(hh->hh_len);
54109 -               memcpy(skb->data - hh_alen, hh->hh_data, hh_alen);
54110 -               read_unlock_bh(&hh->hh_lock);
54111 -               skb_push(skb, hh->hh_len);
54112 -               hh->hh_output(skb);
54113 -       } else if (dst->neighbour)
54114 -               dst->neighbour->output(skb);
54115 -       else {
54116 -               printk(KERN_DEBUG "khm in MIRROR\n");
54117 -               kfree_skb(skb);
54118 -       }
54119 -}
54120 -
54121 -static unsigned int ipt_mirror_target(struct sk_buff **pskb,
54122 -                                     const struct net_device *in,
54123 -                                     const struct net_device *out,
54124 -                                     unsigned int hooknum,
54125 -                                     const void *targinfo,
54126 -                                     void *userinfo)
54127 -{
54128 -       struct rtable *rt;
54129 -       struct sk_buff *nskb;
54130 -       unsigned int hh_len;
54131 -
54132 -       /* Make skb writable */
54133 -       if (!skb_ip_make_writable(pskb, sizeof(struct iphdr)))
54134 -               return 0;
54135 -
54136 -       /* If we are not at FORWARD hook (INPUT/PREROUTING),
54137 -        * the TTL isn't decreased by the IP stack */
54138 -       if (hooknum != NF_IP_FORWARD) {
54139 -               if ((*pskb)->nh.iph->ttl <= 1) {
54140 -                       /* this will traverse normal stack, and 
54141 -                        * thus call conntrack on the icmp packet */
54142 -                       icmp_send(*pskb, ICMP_TIME_EXCEEDED, 
54143 -                                 ICMP_EXC_TTL, 0);
54144 -                       return NF_DROP;
54145 -               }
54146 -               ip_decrease_ttl((*pskb)->nh.iph);
54147 -       }
54148 -
54149 -       if ((rt = route_mirror(*pskb, hooknum == NF_IP_LOCAL_IN)) == NULL)
54150 -               return NF_DROP;
54151 -
54152 -       hh_len = (rt->u.dst.dev->hard_header_len + 15) & ~15;
54153 -
54154 -       /* Copy skb (even if skb is about to be dropped, we can't just
54155 -        * clone it because there may be other things, such as tcpdump,
54156 -        * interested in it). We also need to expand headroom in case
54157 -        * hh_len of incoming interface < hh_len of outgoing interface */
54158 -       nskb = skb_copy_expand(*pskb, hh_len, skb_tailroom(*pskb), GFP_ATOMIC);
54159 -       if (nskb == NULL) {
54160 -               dst_release(&rt->u.dst);
54161 -               return NF_DROP;
54162 -       }
54163 -
54164 -       dst_release(nskb->dst);
54165 -       nskb->dst = &rt->u.dst;
54166 -
54167 -       ip_rewrite(nskb);
54168 -       /* Don't let conntrack code see this packet:
54169 -        * it will think we are starting a new
54170 -        * connection! --RR */
54171 -       ip_direct_send(nskb);
54172 -
54173 -       return NF_DROP;
54174 -}
54175 -
54176 -static int ipt_mirror_checkentry(const char *tablename,
54177 -                                const struct ipt_entry *e,
54178 -                                void *targinfo,
54179 -                                unsigned int targinfosize,
54180 -                                unsigned int hook_mask)
54181 -{
54182 -       /* Only on INPUT, FORWARD or PRE_ROUTING, otherwise loop danger. */
54183 -       if (hook_mask & ~((1 << NF_IP_PRE_ROUTING)
54184 -                         | (1 << NF_IP_FORWARD)
54185 -                         | (1 << NF_IP_LOCAL_IN))) {
54186 -               DEBUGP("MIRROR: bad hook\n");
54187 -               return 0;
54188 -       }
54189 -
54190 -       if (targinfosize != IPT_ALIGN(0)) {
54191 -               DEBUGP("MIRROR: targinfosize %u != 0\n", targinfosize);
54192 -               return 0;
54193 -       }
54194 -
54195 -       return 1;
54196 -}
54197 -
54198 -static struct ipt_target ipt_mirror_reg = {
54199 -       .name           = "MIRROR",
54200 -       .target         = ipt_mirror_target,
54201 -       .checkentry     = ipt_mirror_checkentry,
54202 -       .me             = THIS_MODULE,
54203 -};
54204 -
54205 -static int __init init(void)
54206 -{
54207 -       return ipt_register_target(&ipt_mirror_reg);
54208 -}
54209 -
54210 -static void __exit fini(void)
54211 -{
54212 -       ipt_unregister_target(&ipt_mirror_reg);
54213 -}
54214 -
54215 -module_init(init);
54216 -module_exit(fini);
54217 -MODULE_LICENSE("GPL");
54218 diff -Nru a/net/ipv4/netfilter/ipt_NETMAP.c b/net/ipv4/netfilter/ipt_NETMAP.c
54219 --- /dev/null   Wed Dec 31 16:00:00 1969
54220 +++ b/net/ipv4/netfilter/ipt_NETMAP.c   Sun Aug 24 17:25:18 2003
54221 @@ -0,0 +1,112 @@
54222 +/* NETMAP - static NAT mapping of IP network addresses (1:1).
54223 +   The mapping can be applied to source (POSTROUTING),
54224 +   destination (PREROUTING), or both (with separate rules).
54225 +
54226 +   Author: Svenning Soerensen <svenning@post5.tele.dk>
54227 +*/
54228 +
54229 +#include <linux/config.h>
54230 +#include <linux/ip.h>
54231 +#include <linux/module.h>
54232 +#include <linux/netdevice.h>
54233 +#include <linux/netfilter.h>
54234 +#include <linux/netfilter_ipv4.h>
54235 +#include <linux/netfilter_ipv4/ip_nat_rule.h>
54236 +
54237 +#define MODULENAME "NETMAP"
54238 +MODULE_LICENSE("GPL");
54239 +MODULE_AUTHOR("Svenning Soerensen <svenning@post5.tele.dk>");
54240 +MODULE_DESCRIPTION("iptables 1:1 NAT mapping of IP networks target");
54241 +
54242 +#if 0
54243 +#define DEBUGP printk
54244 +#else
54245 +#define DEBUGP(format, args...)
54246 +#endif
54247 +
54248 +static int
54249 +check(const char *tablename,
54250 +      const struct ipt_entry *e,
54251 +      void *targinfo,
54252 +      unsigned int targinfosize,
54253 +      unsigned int hook_mask)
54254 +{
54255 +       const struct ip_nat_multi_range *mr = targinfo;
54256 +
54257 +       if (strcmp(tablename, "nat") != 0) {
54258 +               DEBUGP(MODULENAME":check: bad table `%s'.\n", tablename);
54259 +               return 0;
54260 +       }
54261 +       if (targinfosize != IPT_ALIGN(sizeof(*mr))) {
54262 +               DEBUGP(MODULENAME":check: size %u.\n", targinfosize);
54263 +               return 0;
54264 +       }
54265 +       if (hook_mask & ~((1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_POST_ROUTING))) {
54266 +               DEBUGP(MODULENAME":check: bad hooks %x.\n", hook_mask);
54267 +               return 0;
54268 +       }
54269 +       if (!(mr->range[0].flags & IP_NAT_RANGE_MAP_IPS)) {
54270 +               DEBUGP(MODULENAME":check: bad MAP_IPS.\n");
54271 +               return 0;
54272 +       }
54273 +       if (mr->rangesize != 1) {
54274 +               DEBUGP(MODULENAME":check: bad rangesize %u.\n", mr->rangesize);
54275 +               return 0;
54276 +       }
54277 +       return 1;
54278 +}
54279 +
54280 +static unsigned int
54281 +target(struct sk_buff **pskb,
54282 +       const struct net_device *in,
54283 +       const struct net_device *out,
54284 +       unsigned int hooknum,
54285 +       const void *targinfo,
54286 +       void *userinfo)
54287 +{
54288 +       struct ip_conntrack *ct;
54289 +       enum ip_conntrack_info ctinfo;
54290 +       u_int32_t new_ip, netmask;
54291 +       const struct ip_nat_multi_range *mr = targinfo;
54292 +       struct ip_nat_multi_range newrange;
54293 +
54294 +       IP_NF_ASSERT(hooknum == NF_IP_PRE_ROUTING
54295 +                    || hooknum == NF_IP_POST_ROUTING);
54296 +       ct = ip_conntrack_get(*pskb, &ctinfo);
54297 +
54298 +       netmask = ~(mr->range[0].min_ip ^ mr->range[0].max_ip);
54299 +
54300 +       if (hooknum == NF_IP_PRE_ROUTING)
54301 +               new_ip = (*pskb)->nh.iph->daddr & ~netmask;
54302 +       else
54303 +               new_ip = (*pskb)->nh.iph->saddr & ~netmask;
54304 +       new_ip |= mr->range[0].min_ip & netmask;
54305 +
54306 +       newrange = ((struct ip_nat_multi_range)
54307 +       { 1, { { mr->range[0].flags | IP_NAT_RANGE_MAP_IPS,
54308 +                new_ip, new_ip,
54309 +                mr->range[0].min, mr->range[0].max } } });
54310 +
54311 +       /* Hand modified range to generic setup. */
54312 +       return ip_nat_setup_info(ct, &newrange, hooknum);
54313 +}
54314 +
54315 +static struct ipt_target target_module = { 
54316 +       .name           = MODULENAME,
54317 +       .target         = target, 
54318 +       .checkentry     = check,
54319 +       .me             = THIS_MODULE 
54320 +};
54321 +
54322 +static int __init init(void)
54323 +{
54324 +       return ipt_register_target(&target_module);
54325 +}
54326 +
54327 +static void __exit fini(void)
54328 +{
54329 +       ipt_unregister_target(&target_module);
54330 +}
54331 +
54332 +module_init(init);
54333 +module_exit(fini);
54334 diff -Nru a/net/ipv4/netfilter/ipt_REDIRECT.c b/net/ipv4/netfilter/ipt_REDIRECT.c
54335 --- a/net/ipv4/netfilter/ipt_REDIRECT.c Wed May 21 16:36:54 2003
54336 +++ b/net/ipv4/netfilter/ipt_REDIRECT.c Sun Aug 24 05:00:28 2003
54337 @@ -12,6 +12,10 @@
54338  #include <linux/netfilter_ipv4.h>
54339  #include <linux/netfilter_ipv4/ip_nat_rule.h>
54340  
54341 +MODULE_LICENSE("GPL");
54342 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
54343 +MODULE_DESCRIPTION("iptables REDIRECT target module");
54344 +
54345  #if 0
54346  #define DEBUGP printk
54347  #else
54348 @@ -115,4 +119,3 @@
54349  
54350  module_init(init);
54351  module_exit(fini);
54352 -MODULE_LICENSE("GPL");
54353 diff -Nru a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c
54354 --- a/net/ipv4/netfilter/ipt_REJECT.c   Sun Jul 27 16:03:33 2003
54355 +++ b/net/ipv4/netfilter/ipt_REJECT.c   Sun Aug 24 05:00:28 2003
54356 @@ -16,6 +16,10 @@
54357  #include <linux/netfilter_ipv4/ip_tables.h>
54358  #include <linux/netfilter_ipv4/ipt_REJECT.h>
54359  
54360 +MODULE_LICENSE("GPL");
54361 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
54362 +MODULE_DESCRIPTION("iptables REJECT target module");
54363 +
54364  #if 0
54365  #define DEBUGP printk
54366  #else
54367 @@ -137,6 +141,10 @@
54368         nskb->nf_debug = 0;
54369  #endif
54370         nskb->nfmark = 0;
54371 +#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
54372 +       nf_bridge_put(nskb->nf_bridge);
54373 +       nskb->nf_bridge = NULL;
54374 +#endif
54375  
54376         tcph = (struct tcphdr *)((u_int32_t*)nskb->nh.iph + nskb->nh.iph->ihl);
54377  
54378 @@ -462,4 +470,3 @@
54379  
54380  module_init(init);
54381  module_exit(fini);
54382 -MODULE_LICENSE("GPL");
54383 diff -Nru a/net/ipv4/netfilter/ipt_SAME.c b/net/ipv4/netfilter/ipt_SAME.c
54384 --- /dev/null   Wed Dec 31 16:00:00 1969
54385 +++ b/net/ipv4/netfilter/ipt_SAME.c     Sun Aug 24 17:25:18 2003
54386 @@ -0,0 +1,206 @@
54387 +/* Same.  Just like SNAT, only try to make the connections
54388 + *       between client A and server B always have the same source ip.
54389 + *
54390 + * (C) 2000 Rusty Russell.  GPL.
54391 + *
54392 + * 010320 Martin Josefsson <gandalf@wlug.westbo.se>
54393 + *     * copied ipt_BALANCE.c to ipt_SAME.c and changed a few things.
54394 + * 010728 Martin Josefsson <gandalf@wlug.westbo.se>
54395 + *     * added --nodst to not include destination-ip in new source
54396 + *       calculations.
54397 + *     * added some more sanity-checks.
54398 + * 010729 Martin Josefsson <gandalf@wlug.westbo.se>
54399 + *     * fixed a buggy if-statement in same_check(), should have
54400 + *       used ntohl() but didn't.
54401 + *     * added support for multiple ranges. IPT_SAME_MAX_RANGE is
54402 + *       defined in linux/include/linux/netfilter_ipv4/ipt_SAME.h
54403 + *       and is currently set to 10.
54404 + *     * added support for 1-address range, nice to have now that
54405 + *       we have multiple ranges.
54406 + */
54407 +#include <linux/types.h>
54408 +#include <linux/ip.h>
54409 +#include <linux/timer.h>
54410 +#include <linux/module.h>
54411 +#include <linux/netfilter.h>
54412 +#include <linux/netdevice.h>
54413 +#include <linux/if.h>
54414 +#include <linux/inetdevice.h>
54415 +#include <net/protocol.h>
54416 +#include <net/checksum.h>
54417 +#include <linux/netfilter_ipv4.h>
54418 +#include <linux/netfilter_ipv4/ip_nat_rule.h>
54419 +#include <linux/netfilter_ipv4/ipt_SAME.h>
54420 +
54421 +MODULE_LICENSE("GPL");
54422 +MODULE_AUTHOR("Martin Josefsson <gandalf@wlug.westbo.se>");
54423 +MODULE_DESCRIPTION("iptables special SNAT module for consistent sourceip");
54424 +
54425 +#if 0
54426 +#define DEBUGP printk
54427 +#else
54428 +#define DEBUGP(format, args...)
54429 +#endif
54430 +
54431 +static int
54432 +same_check(const char *tablename,
54433 +             const struct ipt_entry *e,
54434 +             void *targinfo,
54435 +             unsigned int targinfosize,
54436 +             unsigned int hook_mask)
54437 +{
54438 +       unsigned int count, countess, rangeip, index = 0;
54439 +       struct ipt_same_info *mr = targinfo;
54440 +
54441 +       mr->ipnum = 0;
54442 +
54443 +       if (strcmp(tablename, "nat") != 0) {
54444 +               DEBUGP("same_check: bad table `%s'.\n", tablename);
54445 +               return 0;
54446 +       }
54447 +       if (targinfosize != IPT_ALIGN(sizeof(*mr))) {
54448 +               DEBUGP("same_check: size %u.\n", targinfosize);
54449 +               return 0;
54450 +       }
54451 +       if (hook_mask & ~(1 << NF_IP_PRE_ROUTING | 1 << NF_IP_POST_ROUTING)) {
54452 +               DEBUGP("same_check: bad hooks %x.\n", hook_mask);
54453 +               return 0;
54454 +       }
54455 +       if (mr->rangesize < 1) {
54456 +               DEBUGP("same_check: need at least one dest range.\n");
54457 +               return 0;
54458 +       }
54459 +       if (mr->rangesize > IPT_SAME_MAX_RANGE) {
54460 +               DEBUGP("same_check: too many ranges specified, maximum "
54461 +                               "is %u ranges\n",
54462 +                               IPT_SAME_MAX_RANGE);
54463 +               return 0;
54464 +       }
54465 +       for (count = 0; count < mr->rangesize; count++) {
54466 +               if (ntohl(mr->range[count].min_ip) >
54467 +                               ntohl(mr->range[count].max_ip)) {
54468 +                       DEBUGP("same_check: min_ip is larger than max_ip in "
54469 +                               "range `%u.%u.%u.%u-%u.%u.%u.%u'.\n",
54470 +                               NIPQUAD(mr->range[count].min_ip),
54471 +                               NIPQUAD(mr->range[count].max_ip));
54472 +                       return 0;
54473 +               }
54474 +               if (!(mr->range[count].flags & IP_NAT_RANGE_MAP_IPS)) {
54475 +                       DEBUGP("same_check: bad MAP_IPS.\n");
54476 +                       return 0;
54477 +               }
54478 +               rangeip = (ntohl(mr->range[count].max_ip) - 
54479 +                                       ntohl(mr->range[count].min_ip) + 1);
54480 +               mr->ipnum += rangeip;
54481 +               
54482 +               DEBUGP("same_check: range %u, ipnum = %u\n", count, rangeip);
54483 +       }
54484 +       DEBUGP("same_check: total ipaddresses = %u\n", mr->ipnum);
54485 +       
54486 +       mr->iparray = kmalloc((sizeof(u_int32_t) * mr->ipnum), GFP_KERNEL);
54487 +       if (!mr->iparray) {
54488 +               DEBUGP("same_check: Couldn't allocate %u bytes "
54489 +                       "for %u ipaddresses!\n", 
54490 +                       (sizeof(u_int32_t) * mr->ipnum), mr->ipnum);
54491 +               return 0;
54492 +       }
54493 +       DEBUGP("same_check: Allocated %u bytes for %u ipaddresses.\n",
54494 +                       (sizeof(u_int32_t) * mr->ipnum), mr->ipnum);
54495 +       
54496 +       for (count = 0; count < mr->rangesize; count++) {
54497 +               for (countess = ntohl(mr->range[count].min_ip);
54498 +                               countess <= ntohl(mr->range[count].max_ip);
54499 +                                       countess++) {
54500 +                       mr->iparray[index] = countess;
54501 +                       DEBUGP("same_check: Added ipaddress `%u.%u.%u.%u' "
54502 +                               "in index %u.\n",
54503 +                               HIPQUAD(countess), index);
54504 +                       index++;
54505 +               }
54506 +       }
54507 +       return 1;
54508 +}
54509 +
54510 +static void 
54511 +same_destroy(void *targinfo,
54512 +               unsigned int targinfosize)
54513 +{
54514 +       struct ipt_same_info *mr = targinfo;
54515 +
54516 +       kfree(mr->iparray);
54517 +       
54518 +       DEBUGP("same_destroy: Deallocated %u bytes for %u ipaddresses.\n",
54519 +                       (sizeof(u_int32_t) * mr->ipnum), mr->ipnum);
54520 +}
54521 +
54522 +static unsigned int
54523 +same_target(struct sk_buff **pskb,
54524 +               const struct net_device *in,
54525 +               const struct net_device *out,
54526 +               unsigned int hooknum,
54527 +               const void *targinfo,
54528 +               void *userinfo)
54529 +{
54530 +       struct ip_conntrack *ct;
54531 +       enum ip_conntrack_info ctinfo;
54532 +       u_int32_t tmpip, aindex, new_ip;
54533 +       const struct ipt_same_info *mr = targinfo;
54534 +       struct ip_nat_multi_range newrange;
54535 +       const struct ip_conntrack_tuple *t;
54536 +
54537 +       IP_NF_ASSERT(hooknum == NF_IP_PRE_ROUTING ||
54538 +                       hooknum == NF_IP_POST_ROUTING);
54539 +       ct = ip_conntrack_get(*pskb, &ctinfo);
54540 +
54541 +       t = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
54542 +
54543 +       /* Base new source on real src ip and optionally dst ip,
54544 +          giving some hope for consistency across reboots.
54545 +          Here we calculate the index in mr->iparray which
54546 +          holds the ipaddress we should use */
54547 +       
54548 +       tmpip = ntohl(t->src.ip);
54549 +
54550 +       if (!(mr->info & IPT_SAME_NODST))
54551 +               tmpip += ntohl(t->dst.ip);
54552 +       
54553 +       aindex = tmpip % mr->ipnum;
54554 +               
54555 +       new_ip = htonl(mr->iparray[aindex]);
54556 +
54557 +       DEBUGP("ipt_SAME: src=%u.%u.%u.%u dst=%u.%u.%u.%u, "
54558 +                       "new src=%u.%u.%u.%u\n",
54559 +                       NIPQUAD(t->src.ip), NIPQUAD(t->dst.ip),
54560 +                       NIPQUAD(new_ip));
54561 +
54562 +       /* Transfer from original range. */
54563 +       newrange = ((struct ip_nat_multi_range)
54564 +               { 1, { { mr->range[0].flags | IP_NAT_RANGE_MAP_IPS,
54565 +                        new_ip, new_ip,
54566 +                        mr->range[0].min, mr->range[0].max } } });
54567 +
54568 +       /* Hand modified range to generic setup. */
54569 +       return ip_nat_setup_info(ct, &newrange, hooknum);
54570 +}
54571 +
54572 +static struct ipt_target same_reg = { 
54573 +       .name           = "SAME",
54574 +       .target         = same_target,
54575 +       .checkentry     = same_check,
54576 +       .destroy        = same_destroy,
54577 +       .me             = THIS_MODULE,
54578 +};
54579 +
54580 +static int __init init(void)
54581 +{
54582 +       return ipt_register_target(&same_reg);
54583 +}
54584 +
54585 +static void __exit fini(void)
54586 +{
54587 +       ipt_unregister_target(&same_reg);
54588 +}
54589 +
54590 +module_init(init);
54591 +module_exit(fini);
54592 +
54593 diff -Nru a/net/ipv4/netfilter/ipt_TCPMSS.c b/net/ipv4/netfilter/ipt_TCPMSS.c
54594 --- a/net/ipv4/netfilter/ipt_TCPMSS.c   Wed May 21 16:36:54 2003
54595 +++ b/net/ipv4/netfilter/ipt_TCPMSS.c   Sun Aug 24 05:00:28 2003
54596 @@ -12,6 +12,10 @@
54597  #include <linux/netfilter_ipv4/ip_tables.h>
54598  #include <linux/netfilter_ipv4/ipt_TCPMSS.h>
54599  
54600 +MODULE_LICENSE("GPL");
54601 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
54602 +MODULE_DESCRIPTION("iptables TCP MSS modification module");
54603 +
54604  #if 0
54605  #define DEBUGP printk
54606  #else
54607 @@ -250,4 +254,3 @@
54608  
54609  module_init(init);
54610  module_exit(fini);
54611 -MODULE_LICENSE("GPL");
54612 diff -Nru a/net/ipv4/netfilter/ipt_TOS.c b/net/ipv4/netfilter/ipt_TOS.c
54613 --- a/net/ipv4/netfilter/ipt_TOS.c      Wed May 21 16:36:54 2003
54614 +++ b/net/ipv4/netfilter/ipt_TOS.c      Sun Aug 24 05:00:28 2003
54615 @@ -7,6 +7,10 @@
54616  #include <linux/netfilter_ipv4/ip_tables.h>
54617  #include <linux/netfilter_ipv4/ipt_TOS.h>
54618  
54619 +MODULE_LICENSE("GPL");
54620 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
54621 +MODULE_DESCRIPTION("iptables TOS mangling module");
54622 +
54623  static unsigned int
54624  target(struct sk_buff **pskb,
54625         const struct net_device *in,
54626 @@ -93,4 +97,3 @@
54627  
54628  module_init(init);
54629  module_exit(fini);
54630 -MODULE_LICENSE("GPL");
54631 diff -Nru a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
54632 --- a/net/ipv4/netfilter/ipt_ULOG.c     Tue Jun 24 15:36:11 2003
54633 +++ b/net/ipv4/netfilter/ipt_ULOG.c     Sat Aug 30 20:35:04 2003
54634 @@ -36,7 +36,6 @@
54635   */
54636  
54637  #include <linux/module.h>
54638 -#include <linux/version.h>
54639  #include <linux/config.h>
54640  #include <linux/spinlock.h>
54641  #include <linux/socket.h>
54642 @@ -55,7 +54,7 @@
54643  
54644  MODULE_LICENSE("GPL");
54645  MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
54646 -MODULE_DESCRIPTION("IP tables userspace logging module");
54647 +MODULE_DESCRIPTION("iptables userspace logging module");
54648  
54649  #define ULOG_NL_EVENT          111             /* Harald's favorite number */
54650  #define ULOG_MAXNLGROUPS       32              /* numer of nlgroups */
54651 diff -Nru a/net/ipv4/netfilter/ipt_ah.c b/net/ipv4/netfilter/ipt_ah.c
54652 --- a/net/ipv4/netfilter/ipt_ah.c       Sat Aug  2 22:49:54 2003
54653 +++ b/net/ipv4/netfilter/ipt_ah.c       Sun Aug 24 05:00:28 2003
54654 @@ -7,6 +7,8 @@
54655  #include <linux/netfilter_ipv4/ip_tables.h>
54656  
54657  MODULE_LICENSE("GPL");
54658 +MODULE_AUTHOR("Yon Uriarte <yon@astaro.de>");
54659 +MODULE_DESCRIPTION("iptables AH SPI match module");
54660  
54661  #ifdef DEBUG_CONNTRACK
54662  #define duprintf(format, args...) printk(format , ## args)
54663 diff -Nru a/net/ipv4/netfilter/ipt_conntrack.c b/net/ipv4/netfilter/ipt_conntrack.c
54664 --- a/net/ipv4/netfilter/ipt_conntrack.c        Wed May 21 16:35:36 2003
54665 +++ b/net/ipv4/netfilter/ipt_conntrack.c        Sun Aug 24 05:00:28 2003
54666 @@ -8,6 +8,10 @@
54667  #include <linux/netfilter_ipv4/ip_tables.h>
54668  #include <linux/netfilter_ipv4/ipt_conntrack.h>
54669  
54670 +MODULE_LICENSE("GPL");
54671 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
54672 +MODULE_DESCRIPTION("iptables connection tracking match module");
54673 +
54674  static int
54675  match(const struct sk_buff *skb,
54676        const struct net_device *in,
54677 @@ -122,4 +126,3 @@
54678  
54679  module_init(init);
54680  module_exit(fini);
54681 -MODULE_LICENSE("GPL");
54682 diff -Nru a/net/ipv4/netfilter/ipt_dscp.c b/net/ipv4/netfilter/ipt_dscp.c
54683 --- a/net/ipv4/netfilter/ipt_dscp.c     Wed May 21 16:35:36 2003
54684 +++ b/net/ipv4/netfilter/ipt_dscp.c     Sun Aug 24 05:00:28 2003
54685 @@ -13,8 +13,8 @@
54686  #include <linux/netfilter_ipv4/ipt_dscp.h>
54687  #include <linux/netfilter_ipv4/ip_tables.h>
54688  
54689 -MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
54690 -MODULE_DESCRIPTION("IP tables DSCP matching module");
54691 +MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
54692 +MODULE_DESCRIPTION("iptables DSCP matching module");
54693  MODULE_LICENSE("GPL");
54694  
54695  static int match(const struct sk_buff *skb, const struct net_device *in,
54696 diff -Nru a/net/ipv4/netfilter/ipt_ecn.c b/net/ipv4/netfilter/ipt_ecn.c
54697 --- a/net/ipv4/netfilter/ipt_ecn.c      Wed May 21 16:35:36 2003
54698 +++ b/net/ipv4/netfilter/ipt_ecn.c      Sun Aug 24 05:00:28 2003
54699 @@ -14,8 +14,8 @@
54700  #include <linux/netfilter_ipv4/ip_tables.h>
54701  #include <linux/netfilter_ipv4/ipt_ecn.h>
54702  
54703 -MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
54704 -MODULE_DESCRIPTION("IP tables ECN matching module");
54705 +MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
54706 +MODULE_DESCRIPTION("iptables ECN matching module");
54707  MODULE_LICENSE("GPL");
54708  
54709  static inline int match_ip(const struct sk_buff *skb,
54710 diff -Nru a/net/ipv4/netfilter/ipt_esp.c b/net/ipv4/netfilter/ipt_esp.c
54711 --- a/net/ipv4/netfilter/ipt_esp.c      Sat Aug  2 22:51:04 2003
54712 +++ b/net/ipv4/netfilter/ipt_esp.c      Sun Aug 24 05:00:28 2003
54713 @@ -7,6 +7,8 @@
54714  #include <linux/netfilter_ipv4/ip_tables.h>
54715  
54716  MODULE_LICENSE("GPL");
54717 +MODULE_AUTHOR("Yon Uriarte <yon@astaro.de>");
54718 +MODULE_DESCRIPTION("iptables ESP SPI match module");
54719  
54720  #ifdef DEBUG_CONNTRACK
54721  #define duprintf(format, args...) printk(format , ## args)
54722 diff -Nru a/net/ipv4/netfilter/ipt_helper.c b/net/ipv4/netfilter/ipt_helper.c
54723 --- a/net/ipv4/netfilter/ipt_helper.c   Fri Aug  1 03:02:18 2003
54724 +++ b/net/ipv4/netfilter/ipt_helper.c   Sun Aug 24 05:00:28 2003
54725 @@ -17,6 +17,8 @@
54726  #include <linux/netfilter_ipv4/ipt_helper.h>
54727  
54728  MODULE_LICENSE("GPL");
54729 +MODULE_AUTHOR("Martin Josefsson <gandalf@netfilter.org>");
54730 +MODULE_DESCRIPTION("iptables helper match module");
54731  
54732  #if 0
54733  #define DEBUGP printk
54734 diff -Nru a/net/ipv4/netfilter/ipt_iprange.c b/net/ipv4/netfilter/ipt_iprange.c
54735 --- /dev/null   Wed Dec 31 16:00:00 1969
54736 +++ b/net/ipv4/netfilter/ipt_iprange.c  Sun Aug 24 17:25:18 2003
54737 @@ -0,0 +1,97 @@
54738 +/*
54739 + * iptables module to match IP address ranges
54740 + *   (c) 2003 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
54741 + *
54742 + * Released under the terms of GNU GPLv2.
54743 + *
54744 + */
54745 +#include <linux/module.h>
54746 +#include <linux/skbuff.h>
54747 +#include <linux/ip.h>
54748 +#include <linux/netfilter_ipv4/ip_tables.h>
54749 +#include <linux/netfilter_ipv4/ipt_iprange.h>
54750 +
54751 +MODULE_LICENSE("GPL");
54752 +MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>");
54753 +MODULE_DESCRIPTION("iptables arbitrary IP range match module");
54754 +
54755 +#if 0
54756 +#define DEBUGP printk
54757 +#else
54758 +#define DEBUGP(format, args...)
54759 +#endif
54760 +
54761 +static int
54762 +match(const struct sk_buff *skb,
54763 +      const struct net_device *in,
54764 +      const struct net_device *out,
54765 +      const void *matchinfo,
54766 +      int offset, int *hotdrop)
54767 +{
54768 +       const struct ipt_iprange_info *info = matchinfo;
54769 +       const struct iphdr *iph = skb->nh.iph;
54770 +
54771 +       if (info->flags & IPRANGE_SRC) {
54772 +               if (((ntohl(iph->saddr) < ntohl(info->src.min_ip))
54773 +                         || (ntohl(iph->saddr) > ntohl(info->src.max_ip)))
54774 +                        ^ !!(info->flags & IPRANGE_SRC_INV)) {
54775 +                       DEBUGP("src IP %u.%u.%u.%u NOT in range %s"
54776 +                              "%u.%u.%u.%u-%u.%u.%u.%u\n",
54777 +                               NIPQUAD(iph->saddr),
54778 +                               info->flags & IPRANGE_SRC_INV ? "(INV) " : "",
54779 +                               NIPQUAD(info->src.min_ip),
54780 +                               NIPQUAD(info->src.max_ip));
54781 +                       return 0;
54782 +               }
54783 +       }
54784 +       if (info->flags & IPRANGE_DST) {
54785 +               if (((ntohl(iph->daddr) < ntohl(info->dst.min_ip))
54786 +                         || (ntohl(iph->daddr) > ntohl(info->dst.max_ip)))
54787 +                        ^ !!(info->flags & IPRANGE_DST_INV)) {
54788 +                       DEBUGP("dst IP %u.%u.%u.%u NOT in range %s"
54789 +                              "%u.%u.%u.%u-%u.%u.%u.%u\n",
54790 +                               NIPQUAD(iph->daddr),
54791 +                               info->flags & IPRANGE_DST_INV ? "(INV) " : "",
54792 +                               NIPQUAD(info->dst.min_ip),
54793 +                               NIPQUAD(info->dst.max_ip));
54794 +                       return 0;
54795 +               }
54796 +       }
54797 +       return 1;
54798 +}
54799 +
54800 +static int check(const char *tablename,
54801 +                const struct ipt_ip *ip,
54802 +                void *matchinfo,
54803 +                unsigned int matchsize,
54804 +                unsigned int hook_mask)
54805 +{
54806 +       /* verify size */
54807 +       if (matchsize != IPT_ALIGN(sizeof(struct ipt_iprange_info)))
54808 +               return 0;
54809 +
54810 +       return 1;
54811 +}
54812 +
54813 +static struct ipt_match iprange_match = 
54814 +{ 
54815 +       .list = { NULL, NULL }, 
54816 +       .name = "iprange", 
54817 +       .match = &match, 
54818 +       .checkentry = &check, 
54819 +       .destroy = NULL, 
54820 +       .me = THIS_MODULE
54821 +};
54822 +
54823 +static int __init init(void)
54824 +{
54825 +       return ipt_register_match(&iprange_match);
54826 +}
54827 +
54828 +static void __exit fini(void)
54829 +{
54830 +       ipt_unregister_match(&iprange_match);
54831 +}
54832 +
54833 +module_init(init);
54834 +module_exit(fini);
54835 diff -Nru a/net/ipv4/netfilter/ipt_limit.c b/net/ipv4/netfilter/ipt_limit.c
54836 --- a/net/ipv4/netfilter/ipt_limit.c    Wed May 21 16:35:36 2003
54837 +++ b/net/ipv4/netfilter/ipt_limit.c    Sun Aug 24 05:00:28 2003
54838 @@ -15,6 +15,10 @@
54839  #include <linux/netfilter_ipv4/ip_tables.h>
54840  #include <linux/netfilter_ipv4/ipt_limit.h>
54841  
54842 +MODULE_LICENSE("GPL");
54843 +MODULE_AUTHOR("Herve Eychenne <rv@wallfire.org>");
54844 +MODULE_DESCRIPTION("iptables rate limit match");
54845 +
54846  /* The algorithm used is the Simple Token Bucket Filter (TBF)
54847   * see net/sched/sch_tbf.c in the linux source tree
54848   */
54849 @@ -134,4 +138,3 @@
54850  
54851  module_init(init);
54852  module_exit(fini);
54853 -MODULE_LICENSE("GPL");
54854 diff -Nru a/net/ipv4/netfilter/ipt_mac.c b/net/ipv4/netfilter/ipt_mac.c
54855 --- a/net/ipv4/netfilter/ipt_mac.c      Wed May 21 16:35:36 2003
54856 +++ b/net/ipv4/netfilter/ipt_mac.c      Sun Aug 24 05:00:28 2003
54857 @@ -6,6 +6,10 @@
54858  #include <linux/netfilter_ipv4/ipt_mac.h>
54859  #include <linux/netfilter_ipv4/ip_tables.h>
54860  
54861 +MODULE_LICENSE("GPL");
54862 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
54863 +MODULE_DESCRIPTION("iptables mac matching module");
54864 +
54865  static int
54866  match(const struct sk_buff *skb,
54867        const struct net_device *in,
54868 @@ -64,4 +68,3 @@
54869  
54870  module_init(init);
54871  module_exit(fini);
54872 -MODULE_LICENSE("GPL");
54873 diff -Nru a/net/ipv4/netfilter/ipt_mark.c b/net/ipv4/netfilter/ipt_mark.c
54874 --- a/net/ipv4/netfilter/ipt_mark.c     Wed May 21 16:35:36 2003
54875 +++ b/net/ipv4/netfilter/ipt_mark.c     Sun Aug 24 05:00:28 2003
54876 @@ -5,6 +5,10 @@
54877  #include <linux/netfilter_ipv4/ipt_mark.h>
54878  #include <linux/netfilter_ipv4/ip_tables.h>
54879  
54880 +MODULE_LICENSE("GPL");
54881 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
54882 +MODULE_DESCRIPTION("iptables mark matching module");
54883 +
54884  static int
54885  match(const struct sk_buff *skb,
54886        const struct net_device *in,
54887 @@ -50,4 +54,3 @@
54888  
54889  module_init(init);
54890  module_exit(fini);
54891 -MODULE_LICENSE("GPL");
54892 diff -Nru a/net/ipv4/netfilter/ipt_multiport.c b/net/ipv4/netfilter/ipt_multiport.c
54893 --- a/net/ipv4/netfilter/ipt_multiport.c        Wed May 21 16:35:36 2003
54894 +++ b/net/ipv4/netfilter/ipt_multiport.c        Sun Aug 24 05:00:28 2003
54895 @@ -8,6 +8,10 @@
54896  #include <linux/netfilter_ipv4/ipt_multiport.h>
54897  #include <linux/netfilter_ipv4/ip_tables.h>
54898  
54899 +MODULE_LICENSE("GPL");
54900 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
54901 +MODULE_DESCRIPTION("iptables multiple port match module");
54902 +
54903  #if 0
54904  #define duprintf(format, args...) printk(format , ## args)
54905  #else
54906 @@ -106,4 +110,3 @@
54907  
54908  module_init(init);
54909  module_exit(fini);
54910 -MODULE_LICENSE("GPL");
54911 diff -Nru a/net/ipv4/netfilter/ipt_owner.c b/net/ipv4/netfilter/ipt_owner.c
54912 --- a/net/ipv4/netfilter/ipt_owner.c    Wed Jun  4 17:57:08 2003
54913 +++ b/net/ipv4/netfilter/ipt_owner.c    Sun Aug 24 05:00:28 2003
54914 @@ -11,6 +11,10 @@
54915  #include <linux/netfilter_ipv4/ipt_owner.h>
54916  #include <linux/netfilter_ipv4/ip_tables.h>
54917  
54918 +MODULE_LICENSE("GPL");
54919 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
54920 +MODULE_DESCRIPTION("iptables owner match");
54921 +
54922  static int
54923  match_comm(const struct sk_buff *skb, const char *comm)
54924  {
54925 @@ -198,4 +202,3 @@
54926  
54927  module_init(init);
54928  module_exit(fini);
54929 -MODULE_LICENSE("GPL");
54930 diff -Nru a/net/ipv4/netfilter/ipt_physdev.c b/net/ipv4/netfilter/ipt_physdev.c
54931 --- a/net/ipv4/netfilter/ipt_physdev.c  Sat Aug  2 18:29:28 2003
54932 +++ b/net/ipv4/netfilter/ipt_physdev.c  Sat Aug 30 20:47:18 2003
54933 @@ -8,6 +8,10 @@
54934  #define MATCH   1
54935  #define NOMATCH 0
54936  
54937 +MODULE_LICENSE("GPL");
54938 +MODULE_AUTHOR("Bart De Schuymer <bdschuym@pandora.be>");
54939 +MODULE_DESCRIPTION("iptables bridge physical device match module");
54940 +
54941  static int
54942  match(const struct sk_buff *skb,
54943        const struct net_device *in,
54944 @@ -120,4 +124,3 @@
54945  
54946  module_init(init);
54947  module_exit(fini);
54948 -MODULE_LICENSE("GPL");
54949 diff -Nru a/net/ipv4/netfilter/ipt_state.c b/net/ipv4/netfilter/ipt_state.c
54950 --- a/net/ipv4/netfilter/ipt_state.c    Wed May 21 16:35:36 2003
54951 +++ b/net/ipv4/netfilter/ipt_state.c    Sun Aug 24 05:00:28 2003
54952 @@ -7,6 +7,10 @@
54953  #include <linux/netfilter_ipv4/ip_tables.h>
54954  #include <linux/netfilter_ipv4/ipt_state.h>
54955  
54956 +MODULE_LICENSE("GPL");
54957 +MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
54958 +MODULE_DESCRIPTION("iptables connection tracking state match module");
54959 +
54960  static int
54961  match(const struct sk_buff *skb,
54962        const struct net_device *in,
54963 @@ -59,4 +63,3 @@
54964  
54965  module_init(init);
54966  module_exit(fini);
54967 -MODULE_LICENSE("GPL");
54968 diff -Nru a/net/ipv4/netfilter/ipt_tcpmss.c b/net/ipv4/netfilter/ipt_tcpmss.c
54969 --- a/net/ipv4/netfilter/ipt_tcpmss.c   Wed May 21 16:35:36 2003
54970 +++ b/net/ipv4/netfilter/ipt_tcpmss.c   Sun Aug 24 05:00:28 2003
54971 @@ -8,6 +8,10 @@
54972  
54973  #define TH_SYN 0x02
54974  
54975 +MODULE_LICENSE("GPL");
54976 +MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
54977 +MODULE_DESCRIPTION("iptables TCP MSS match module");
54978 +
54979  /* Returns 1 if the mss option is set and matched by the range, 0 otherwise */
54980  static inline int
54981  mssoption_match(u_int16_t min, u_int16_t max,
54982 @@ -117,4 +121,3 @@
54983  
54984  module_init(init);
54985  module_exit(fini);
54986 -MODULE_LICENSE("GPL");
54987 diff -Nru a/net/ipv4/netfilter/ipt_tos.c b/net/ipv4/netfilter/ipt_tos.c
54988 --- a/net/ipv4/netfilter/ipt_tos.c      Wed May 21 16:35:36 2003
54989 +++ b/net/ipv4/netfilter/ipt_tos.c      Sun Aug 24 05:00:28 2003
54990 @@ -5,6 +5,9 @@
54991  #include <linux/netfilter_ipv4/ipt_tos.h>
54992  #include <linux/netfilter_ipv4/ip_tables.h>
54993  
54994 +MODULE_LICENSE("GPL");
54995 +MODULE_DESCRIPTION("iptables TOS match module");
54996 +
54997  static int
54998  match(const struct sk_buff *skb,
54999        const struct net_device *in,
55000 @@ -50,4 +53,3 @@
55001  
55002  module_init(init);
55003  module_exit(fini);
55004 -MODULE_LICENSE("GPL");
55005 diff -Nru a/net/ipv4/netfilter/ipt_unclean.c b/net/ipv4/netfilter/ipt_unclean.c
55006 --- a/net/ipv4/netfilter/ipt_unclean.c  Wed May 21 16:35:36 2003
55007 +++ /dev/null   Wed Dec 31 16:00:00 1969
55008 @@ -1,610 +0,0 @@
55009 -/* Kernel module to match suspect packets. */
55010 -#include <linux/module.h>
55011 -#include <linux/skbuff.h>
55012 -#include <linux/ip.h>
55013 -#include <linux/udp.h>
55014 -#include <linux/tcp.h>
55015 -#include <linux/icmp.h>
55016 -#include <net/checksum.h>
55017 -
55018 -#include <linux/netfilter_ipv4/ip_tables.h>
55019 -
55020 -#define limpk(format, args...)                                          \
55021 -do {                                                                    \
55022 -       if (net_ratelimit())                                             \
55023 -               printk("ipt_unclean: %s" format,                         \
55024 -                      embedded ? "(embedded packet) " : "" , ## args);  \
55025 -} while(0)
55026 -
55027 -enum icmp_error_status
55028 -{
55029 -       ICMP_MAY_BE_ERROR,
55030 -       ICMP_IS_ERROR,
55031 -       ICMP_NOT_ERROR
55032 -};
55033 -
55034 -struct icmp_info
55035 -{
55036 -       size_t min_len, max_len;
55037 -       enum icmp_error_status err;
55038 -       u_int8_t min_code, max_code;
55039 -};
55040 -
55041 -static int
55042 -check_ip(const struct sk_buff *skb, unsigned int offset);
55043 -
55044 -/* ICMP-specific checks. */
55045 -static int
55046 -check_icmp(const struct sk_buff *skb,
55047 -          unsigned int offset,
55048 -          unsigned int fragoff,
55049 -          int more_frags,
55050 -          int embedded)
55051 -{
55052 -       struct icmphdr icmph;
55053 -       static struct icmp_info info[]
55054 -               = { [ICMP_ECHOREPLY]
55055 -                   = { 8, 65536, ICMP_NOT_ERROR, 0, 0 },
55056 -                   [ICMP_DEST_UNREACH]
55057 -                   = { 8 + 28, 65536, ICMP_IS_ERROR, 0, 15 },
55058 -                   [ICMP_SOURCE_QUENCH]
55059 -                   = { 8 + 28, 65536, ICMP_IS_ERROR, 0, 0 },
55060 -                   [ICMP_REDIRECT]
55061 -                   = { 8 + 28, 65536, ICMP_IS_ERROR, 0, 3 },
55062 -                   [ICMP_ECHO]
55063 -                   = { 8, 65536, ICMP_NOT_ERROR, 0, 0  },
55064 -                   /* Router advertisement. */
55065 -                   [9]
55066 -                   = { 8, 8 + 255 * 8, ICMP_NOT_ERROR, 0, 0 },
55067 -                   /* Router solicitation. */
55068 -                   [10]
55069 -                   = { 8, 8, ICMP_NOT_ERROR, 0, 0 },
55070 -                   [ICMP_TIME_EXCEEDED]
55071 -                   = { 8 + 28, 65536, ICMP_IS_ERROR, 0, 1  },
55072 -                   [ICMP_PARAMETERPROB]
55073 -                   = { 8 + 28, 65536, ICMP_IS_ERROR, 0, 1 },
55074 -                   [ICMP_TIMESTAMP]
55075 -                   = { 20, 20, ICMP_NOT_ERROR, 0, 0 },
55076 -                   [ICMP_TIMESTAMPREPLY]
55077 -                   = { 20, 20, ICMP_NOT_ERROR, 0, 0 },
55078 -                   [ICMP_INFO_REQUEST]
55079 -                   = { 8, 65536, ICMP_NOT_ERROR, 0, 0 },
55080 -                   [ICMP_INFO_REPLY]
55081 -                   = { 8, 65536, ICMP_NOT_ERROR, 0, 0 },
55082 -                   [ICMP_ADDRESS]
55083 -                   = { 12, 12, ICMP_NOT_ERROR, 0, 0 },
55084 -                   [ICMP_ADDRESSREPLY]
55085 -                   = { 12, 12, ICMP_NOT_ERROR, 0, 0 } };
55086 -
55087 -       /* Can't do anything if it's a fragment. */
55088 -       if (fragoff)
55089 -               return 1;
55090 -
55091 -       /* CHECK: Must have whole header.. */
55092 -       if (skb_copy_bits(skb, offset, &icmph, sizeof(icmph)) < 0) {
55093 -               limpk("ICMP len=%u too short\n", skb->len - offset);
55094 -               return 0;
55095 -       }
55096 -
55097 -       /* If not embedded in an ICMP error already. */
55098 -       if (!embedded) {
55099 -               /* CHECK: Truncated ICMP (even if first fragment). */
55100 -               if (icmph.type < sizeof(info)/sizeof(struct icmp_info)
55101 -                   && info[icmph.type].min_len != 0
55102 -                   && skb->len - offset < info[icmph.type].min_len) {
55103 -                       limpk("ICMP type %u len %u too short\n",
55104 -                             icmph.type, skb->len - offset);
55105 -                       return 0;
55106 -               }
55107 -
55108 -               /* CHECK: Check within known error ICMPs. */
55109 -               if (icmph.type < sizeof(info)/sizeof(struct icmp_info)
55110 -                   && info[icmph.type].err == ICMP_IS_ERROR) {
55111 -                       /* Max IP header size = 60 */
55112 -                       char inner[60 + 8];
55113 -                       struct iphdr *inner_ip = (struct iphdr *)inner;
55114 -
55115 -                       /* CHECK: Embedded packet must be at least
55116 -                          length of iph + 8 bytes. */
55117 -                       if (skb_copy_bits(skb, offset + sizeof(icmph),
55118 -                                         inner, sizeof(struct iphdr)+8) < 0) {
55119 -                               limpk("ICMP error internal way too short\n");
55120 -                               return 0;
55121 -                       }
55122 -
55123 -                       /* iphhdr may actually be longer: still need 8
55124 -                           actual protocol bytes. */
55125 -                       if (offset + sizeof(icmph) + inner_ip->ihl*4 + 8
55126 -                           > skb->len) {
55127 -                               limpk("ICMP error internal too short\n");
55128 -                               return 0;
55129 -                       }
55130 -                       if (!check_ip(skb, offset + sizeof(icmph)))
55131 -                               return 0;
55132 -               }
55133 -       } else {
55134 -               /* CHECK: Can't embed ICMP unless known non-error. */
55135 -               if (icmph.type >= sizeof(info)/sizeof(struct icmp_info)
55136 -                   || info[icmph.type].err != ICMP_NOT_ERROR) {
55137 -                       limpk("ICMP type %u not embeddable\n",
55138 -                             icmph.type);
55139 -                       return 0;
55140 -               }
55141 -       }
55142 -
55143 -       /* CHECK: Invalid ICMP codes. */
55144 -       if (icmph.type < sizeof(info)/sizeof(struct icmp_info)
55145 -           && (icmph.code < info[icmph.type].min_code
55146 -               || icmph.code > info[icmph.type].max_code)) {
55147 -               limpk("ICMP type=%u code=%u\n",
55148 -                     icmph.type, icmph.code);
55149 -               return 0;
55150 -       }
55151 -
55152 -       /* CHECK: Above maximum length. */
55153 -       if (icmph.type < sizeof(info)/sizeof(struct icmp_info)
55154 -           && info[icmph.type].max_len != 0
55155 -           && skb->len - offset > info[icmph.type].max_len) {
55156 -               limpk("ICMP type=%u too long: %u bytes\n",
55157 -                     icmph.type, skb->len - offset);
55158 -               return 0;
55159 -       }
55160 -
55161 -       switch (icmph.type) {
55162 -       case ICMP_PARAMETERPROB: {
55163 -               /* CHECK: Problem param must be within error packet's
55164 -                * IP header. */
55165 -               u_int32_t arg = ntohl(icmph.un.gateway);
55166 -
55167 -               if (icmph.code == 0) {
55168 -                       /* We've already made sure it's long enough. */
55169 -                       struct iphdr iph;
55170 -                       skb_copy_bits(skb, offset + sizeof(icmph), &iph,
55171 -                                     sizeof(iph));
55172 -                       /* Code 0 means that upper 8 bits is pointer
55173 -                           to problem. */
55174 -                       if ((arg >> 24) >= iph.ihl*4) {
55175 -                               limpk("ICMP PARAMETERPROB ptr = %u\n",
55176 -                                     ntohl(icmph.un.gateway) >> 24);
55177 -                               return 0;
55178 -                       }
55179 -                       arg &= 0x00FFFFFF;
55180 -               }
55181 -
55182 -               /* CHECK: Rest must be zero. */
55183 -               if (arg) {
55184 -                       limpk("ICMP PARAMETERPROB nonzero arg = %u\n",
55185 -                             arg);
55186 -                       return 0;
55187 -               }
55188 -               break;
55189 -       }
55190 -
55191 -       case ICMP_TIME_EXCEEDED:
55192 -       case ICMP_SOURCE_QUENCH:
55193 -               /* CHECK: Unused must be zero. */
55194 -               if (icmph.un.gateway != 0) {
55195 -                       limpk("ICMP type=%u unused = %u\n",
55196 -                             icmph.type, ntohl(icmph.un.gateway));
55197 -                       return 0;
55198 -               }
55199 -               break;
55200 -       }
55201 -
55202 -       return 1;
55203 -}
55204 -
55205 -/* UDP-specific checks. */
55206 -static int
55207 -check_udp(const struct sk_buff *skb,
55208 -         unsigned int offset,
55209 -         unsigned int fragoff,
55210 -         int more_frags,
55211 -         int embedded)
55212 -{
55213 -       struct udphdr udph;
55214 -
55215 -       /* Can't do anything if it's a fragment. */
55216 -       if (fragoff)
55217 -               return 1;
55218 -
55219 -       /* CHECK: Must cover UDP header. */
55220 -       if (skb_copy_bits(skb, offset, &udph, sizeof(udph)) < 0) {
55221 -               limpk("UDP len=%u too short\n", skb->len - offset);
55222 -               return 0;
55223 -       }
55224 -
55225 -       /* CHECK: Destination port can't be zero. */
55226 -       if (!udph.dest) {
55227 -               limpk("UDP zero destination port\n");
55228 -               return 0;
55229 -       }
55230 -
55231 -       if (!more_frags) {
55232 -               if (!embedded) {
55233 -                       /* CHECK: UDP length must match. */
55234 -                       if (ntohs(udph.len) != skb->len - offset) {
55235 -                               limpk("UDP len too short %u vs %u\n",
55236 -                                     ntohs(udph.len), skb->len - offset);
55237 -                               return 0;
55238 -                       }
55239 -               } else {
55240 -                       /* CHECK: UDP length be >= this truncated pkt. */
55241 -                       if (ntohs(udph.len) < skb->len - offset) {
55242 -                               limpk("UDP len too long %u vs %u\n",
55243 -                                     ntohs(udph.len), skb->len - offset);
55244 -                               return 0;
55245 -                       }
55246 -               }
55247 -       } else {
55248 -               /* CHECK: UDP length must be > this frag's length. */
55249 -               if (ntohs(udph.len) <= skb->len - offset) {
55250 -                       limpk("UDP fragment len too short %u vs %u\n",
55251 -                             ntohs(udph.len), skb->len - offset);
55252 -                       return 0;
55253 -               }
55254 -       }
55255 -
55256 -       return 1;
55257 -}
55258 -
55259 -/* TCP-specific checks. */
55260 -static int
55261 -check_tcp(const struct sk_buff *skb,
55262 -         unsigned int offset,
55263 -         unsigned int fragoff,
55264 -         int more_frags,
55265 -         int embedded)
55266 -{
55267 -       struct tcphdr tcph; 
55268 -       unsigned char opt[15 * 4 - sizeof(struct tcphdr)];
55269 -       u32 tcpflags;
55270 -       int end_of_options = 0;
55271 -       unsigned int i, optlen;
55272 -
55273 -       /* CHECK: Can't have offset=1: used to override TCP syn-checks. */
55274 -       /* In fact, this is caught below (offset < 516). */
55275 -
55276 -       /* Can't do anything if it's a fragment. */
55277 -       if (fragoff)
55278 -               return 1;
55279 -
55280 -       /* CHECK: Smaller than minimal TCP hdr. */
55281 -       if (skb_copy_bits(skb, offset, &tcph, sizeof(tcph)) < 0) {
55282 -               u16 ports[2];
55283 -
55284 -               if (!embedded) {
55285 -                       limpk("Packet length %u < TCP header.\n",
55286 -                             skb->len - offset);
55287 -                       return 0;
55288 -               }
55289 -
55290 -               /* Must have ports available (datalen >= 8), from
55291 -                   check_icmp which set embedded = 1 */
55292 -               /* CHECK: TCP ports inside ICMP error */
55293 -               skb_copy_bits(skb, offset, ports, sizeof(ports));
55294 -               if (!ports[0] || !ports[1]) {
55295 -                       limpk("Zero TCP ports %u/%u.\n",
55296 -                             htons(ports[0]), htons(ports[1]));
55297 -                       return 0;
55298 -               }
55299 -               return 1;
55300 -       }
55301 -
55302 -       /* CHECK: TCP header claims tiny size. */
55303 -       if (tcph.doff * 4 < sizeof(tcph)) {
55304 -               limpk("TCP header claims tiny size %u\n", tcph.doff * 4);
55305 -               return 0;
55306 -       }
55307 -
55308 -       /* CHECK: Packet smaller than actual TCP hdr. */
55309 -       optlen = tcph.doff*4 - sizeof(tcph);
55310 -       if (skb_copy_bits(skb, offset + sizeof(tcph), opt, optlen) < 0) {
55311 -               if (!embedded) {
55312 -                       limpk("Packet length %u < actual TCP header.\n",
55313 -                             skb->len - offset);
55314 -                       return 0;
55315 -               } else
55316 -                       return 1;
55317 -       }
55318 -
55319 -       /* CHECK: TCP ports non-zero */
55320 -       if (!tcph.source || !tcph.dest) {
55321 -               limpk("Zero TCP ports %u/%u.\n",
55322 -                     htons(tcph.source), htons(tcph.dest));
55323 -               return 0;
55324 -       }
55325 -
55326 -       tcpflags = tcp_flag_word(&tcph);
55327 -
55328 -       /* CHECK: TCP reserved bits zero. */
55329 -       if (tcpflags & TCP_RESERVED_BITS) {
55330 -               limpk("TCP reserved bits not zero\n");
55331 -               return 0;
55332 -       }
55333 -
55334 -       tcpflags &= ~(TCP_DATA_OFFSET | TCP_FLAG_CWR | TCP_FLAG_ECE
55335 -                     | __constant_htonl(0x0000FFFF));
55336 -
55337 -       /* CHECK: TCP flags. */
55338 -       if (tcpflags != TCP_FLAG_SYN
55339 -           && tcpflags != (TCP_FLAG_SYN|TCP_FLAG_ACK)
55340 -           && tcpflags != TCP_FLAG_RST
55341 -           && tcpflags != (TCP_FLAG_RST|TCP_FLAG_ACK)
55342 -           && tcpflags != (TCP_FLAG_RST|TCP_FLAG_ACK|TCP_FLAG_PSH)
55343 -           && tcpflags != (TCP_FLAG_FIN|TCP_FLAG_ACK)
55344 -           && tcpflags != TCP_FLAG_ACK
55345 -           && tcpflags != (TCP_FLAG_ACK|TCP_FLAG_PSH)
55346 -           && tcpflags != (TCP_FLAG_ACK|TCP_FLAG_URG)
55347 -           && tcpflags != (TCP_FLAG_ACK|TCP_FLAG_URG|TCP_FLAG_PSH)
55348 -           && tcpflags != (TCP_FLAG_FIN|TCP_FLAG_ACK|TCP_FLAG_PSH)
55349 -           && tcpflags != (TCP_FLAG_FIN|TCP_FLAG_ACK|TCP_FLAG_URG)
55350 -           && tcpflags != (TCP_FLAG_FIN|TCP_FLAG_ACK|TCP_FLAG_URG
55351 -                           |TCP_FLAG_PSH)) {
55352 -               limpk("TCP flags bad: 0x%04X\n", ntohl(tcpflags) >> 16);
55353 -               return 0;
55354 -       }
55355 -
55356 -       for (i = 0; i < optlen; ) {
55357 -               switch (opt[i]) {
55358 -               case 0:
55359 -                       end_of_options = 1;
55360 -                       i++;
55361 -                       break;
55362 -               case 1:
55363 -                       i++;
55364 -                       break;
55365 -               default:
55366 -                       /* CHECK: options after EOO. */
55367 -                       if (end_of_options) {
55368 -                               limpk("TCP option %u after end\n",
55369 -                                     opt[i]);
55370 -                               return 0;
55371 -                       }
55372 -                       /* CHECK: options at tail. */
55373 -                       else if (i+1 >= optlen) {
55374 -                               limpk("TCP option %u at tail\n",
55375 -                                     opt[i]);
55376 -                               return 0;
55377 -                       }
55378 -                       /* CHECK: zero-length options. */
55379 -                       else if (opt[i+1] == 0) {
55380 -                               limpk("TCP option %u 0 len\n",
55381 -                                     opt[i]);
55382 -                               return 0;
55383 -                       }
55384 -                       /* CHECK: oversize options. */
55385 -                       else if (i + opt[i+1] > optlen) {
55386 -                               limpk("TCP option %u at %u too long\n",
55387 -                                     (unsigned int) opt[i], i);
55388 -                               return 0;
55389 -                       }
55390 -                       /* Move to next option */
55391 -                       i += opt[i+1];
55392 -               }
55393 -       }
55394 -
55395 -       return 1;
55396 -}
55397 -
55398 -/* Returns 1 if ok */
55399 -/* Standard IP checks. */
55400 -static int
55401 -check_ip(const struct sk_buff *skb, unsigned int offset)
55402 -{
55403 -       int end_of_options = 0;
55404 -       unsigned int datalen, optlen;
55405 -       unsigned int i;
55406 -       unsigned int fragoff;
55407 -       struct iphdr iph;
55408 -       unsigned char opt[15 * 4 - sizeof(struct iphdr)];
55409 -       int embedded = offset;
55410 -
55411 -       /* Should only happen for local outgoing raw-socket packets. */
55412 -       /* CHECK: length >= ip header. */
55413 -       if (skb_copy_bits(skb, offset, &iph, sizeof(iph)) < 0) {
55414 -               limpk("Packet length %u < IP header.\n", skb->len - offset);
55415 -               return 0;
55416 -       }
55417 -       if (iph.ihl * 4 < sizeof(iph)) {
55418 -               limpk("IP len %u < minimum IP header.\n", iph.ihl*4);
55419 -               return 0;
55420 -       }
55421 -
55422 -       optlen = iph.ihl * 4 - sizeof(iph);
55423 -       if (skb_copy_bits(skb, offset+sizeof(struct iphdr), opt, optlen)<0) {
55424 -               limpk("Packet length %u < IP header %u.\n",
55425 -                     skb->len - offset, iph.ihl * 4);
55426 -               return 0;
55427 -       }
55428 -
55429 -       fragoff = (ntohs(iph.frag_off) & IP_OFFSET);
55430 -       datalen = skb->len - (offset + sizeof(struct iphdr) + optlen);
55431 -
55432 -       /* CHECK: Embedded fragment. */
55433 -       if (offset && fragoff) {
55434 -               limpk("Embedded fragment.\n");
55435 -               return 0;
55436 -       }
55437 -
55438 -       for (i = 0; i < optlen; ) {
55439 -               switch (opt[i]) {
55440 -               case 0:
55441 -                       end_of_options = 1;
55442 -                       i++;
55443 -                       break;
55444 -               case 1:
55445 -                       i++;
55446 -                       break;
55447 -               default:
55448 -                       /* CHECK: options after EOO. */
55449 -                       if (end_of_options) {
55450 -                               limpk("IP option %u after end\n",
55451 -                                     opt[i]);
55452 -                               return 0;
55453 -                       }
55454 -                       /* CHECK: options at tail. */
55455 -                       else if (i+1 >= optlen) {
55456 -                               limpk("IP option %u at tail\n",
55457 -                                     opt[i]);
55458 -                               return 0;
55459 -                       }
55460 -                       /* CHECK: zero-length or one-length options. */
55461 -                       else if (opt[i+1] < 2) {
55462 -                               limpk("IP option %u %u len\n",
55463 -                                     opt[i], opt[i+1]);
55464 -                               return 0;
55465 -                       }
55466 -                       /* CHECK: oversize options. */
55467 -                       else if (i + opt[i+1] > optlen) {
55468 -                               limpk("IP option %u at %u too long\n",
55469 -                                     opt[i], i);
55470 -                               return 0;
55471 -                       }
55472 -                       /* Move to next option */
55473 -                       i += opt[i+1];
55474 -               }
55475 -       }
55476 -
55477 -       /* Fragment checks. */
55478 -
55479 -       /* CHECK: More fragments, but doesn't fill 8-byte boundary. */
55480 -       if ((ntohs(iph.frag_off) & IP_MF)
55481 -           && (ntohs(iph.tot_len) % 8) != 0) {
55482 -               limpk("Truncated fragment %u long.\n", ntohs(iph.tot_len));
55483 -               return 0;
55484 -       }
55485 -
55486 -       /* CHECK: Oversize fragment a-la Ping of Death. */
55487 -       if (fragoff * 8 + datalen > 65535) {
55488 -               limpk("Oversize fragment to %u.\n", fragoff * 8);
55489 -               return 0;
55490 -       }
55491 -
55492 -       /* CHECK: DF set and fragoff or MF set. */
55493 -       if ((ntohs(iph.frag_off) & IP_DF)
55494 -           && (fragoff || (ntohs(iph.frag_off) & IP_MF))) {
55495 -               limpk("DF set and offset=%u, MF=%u.\n",
55496 -                     fragoff, ntohs(iph.frag_off) & IP_MF);
55497 -               return 0;
55498 -       }
55499 -
55500 -       /* CHECK: Zero-sized fragments. */
55501 -       if ((fragoff || (ntohs(iph.frag_off) & IP_MF))
55502 -           && datalen == 0) {
55503 -               limpk("Zero size fragment offset=%u\n", fragoff);
55504 -               return 0;
55505 -       }
55506 -
55507 -       /* Note: we can have even middle fragments smaller than this:
55508 -          consider a large packet passing through a 600MTU then
55509 -          576MTU link: this gives a fragment of 24 data bytes.  But
55510 -          everyone packs fragments largest first, hence a fragment
55511 -          can't START before 576 - MAX_IP_HEADER_LEN. */
55512 -
55513 -       /* Used to be min-size 576: I recall Alan Cox saying ax25 goes
55514 -          down to 128 (576 taken from RFC 791: All hosts must be
55515 -          prepared to accept datagrams of up to 576 octets).  Use 128
55516 -          here. */
55517 -#define MIN_LIKELY_MTU 128
55518 -       /* CHECK: Min size of first frag = 128. */
55519 -       if ((ntohs(iph.frag_off) & IP_MF)
55520 -           && fragoff == 0
55521 -           && ntohs(iph.tot_len) < MIN_LIKELY_MTU) {
55522 -               limpk("First fragment size %u < %u\n", ntohs(iph.tot_len),
55523 -                     MIN_LIKELY_MTU);
55524 -               return 0;
55525 -       }
55526 -
55527 -       /* CHECK: Min offset of frag = 128 - IP hdr len. */
55528 -       if (fragoff && fragoff * 8 < MIN_LIKELY_MTU - iph.ihl * 4) {
55529 -               limpk("Fragment starts at %u < %u\n", fragoff * 8,
55530 -                     MIN_LIKELY_MTU - iph.ihl * 4);
55531 -               return 0;
55532 -       }
55533 -
55534 -       /* CHECK: Protocol specification non-zero. */
55535 -       if (iph.protocol == 0) {
55536 -               limpk("Zero protocol\n");
55537 -               return 0;
55538 -       }
55539 -
55540 -       /* FIXME: This is already checked for in "Oversize fragment"
55541 -           above --RR */
55542 -       /* CHECK: Do not use what is unused.
55543 -        * First bit of fragmentation flags should be unused.
55544 -        * May be used by OS fingerprinting tools.
55545 -        * 04 Jun 2002, Maciej Soltysiak, solt@dns.toxicfilms.tv
55546 -        */
55547 -       if (ntohs(iph.frag_off)>>15) {
55548 -               limpk("IP unused bit set\n");
55549 -               return 0;
55550 -       }
55551 -
55552 -       /* Per-protocol checks. */
55553 -       switch (iph.protocol) {
55554 -       case IPPROTO_ICMP:
55555 -               return check_icmp(skb, offset + iph.ihl*4, fragoff,
55556 -                                 (ntohs(iph.frag_off) & IP_MF),
55557 -                                 embedded);
55558 -
55559 -       case IPPROTO_UDP:
55560 -               return check_udp(skb, offset + iph.ihl*4, fragoff,
55561 -                                (ntohs(iph.frag_off) & IP_MF),
55562 -                                embedded);
55563 -
55564 -       case IPPROTO_TCP:
55565 -               return check_tcp(skb, offset + iph.ihl*4, fragoff,
55566 -                                (ntohs(iph.frag_off) & IP_MF),
55567 -                                embedded);
55568 -       default:
55569 -               /* Ignorance is bliss. */
55570 -               return 1;
55571 -       }
55572 -}
55573 -
55574 -static int
55575 -match(const struct sk_buff *skb,
55576 -      const struct net_device *in,
55577 -      const struct net_device *out,
55578 -      const void *matchinfo,
55579 -      int offset,
55580 -      int *hotdrop)
55581 -{
55582 -       return !check_ip(skb, 0);
55583 -}
55584 -
55585 -/* Called when user tries to insert an entry of this type. */
55586 -static int
55587 -checkentry(const char *tablename,
55588 -          const struct ipt_ip *ip,
55589 -          void *matchinfo,
55590 -          unsigned int matchsize,
55591 -          unsigned int hook_mask)
55592 -{
55593 -       if (matchsize != IPT_ALIGN(0))
55594 -               return 0;
55595 -
55596 -       return 1;
55597 -}
55598 -
55599 -static struct ipt_match unclean_match = {
55600 -       .name           = "unclean",
55601 -       .match          = &match,
55602 -       .checkentry     = &checkentry,
55603 -       .me             = THIS_MODULE,
55604 -};
55605 -
55606 -static int __init init(void)
55607 -{
55608 -       return ipt_register_match(&unclean_match);
55609 -}
55610 -
55611 -static void __exit fini(void)
55612 -{
55613 -       ipt_unregister_match(&unclean_match);
55614 -}
55615 -
55616 -module_init(init);
55617 -module_exit(fini);
55618 -MODULE_LICENSE("GPL");
55619 diff -Nru a/net/ipv4/netfilter/iptable_filter.c b/net/ipv4/netfilter/iptable_filter.c
55620 --- a/net/ipv4/netfilter/iptable_filter.c       Wed Jun 11 23:34:58 2003
55621 +++ b/net/ipv4/netfilter/iptable_filter.c       Sun Aug 24 05:00:28 2003
55622 @@ -6,6 +6,10 @@
55623  #include <linux/module.h>
55624  #include <linux/netfilter_ipv4/ip_tables.h>
55625  
55626 +MODULE_LICENSE("GPL");
55627 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
55628 +MODULE_DESCRIPTION("iptables filter table");
55629 +
55630  #define FILTER_VALID_HOOKS ((1 << NF_IP_LOCAL_IN) | (1 << NF_IP_FORWARD) | (1 << NF_IP_LOCAL_OUT))
55631  
55632  /* Standard entry. */
55633 @@ -200,4 +204,3 @@
55634  
55635  module_init(init);
55636  module_exit(fini);
55637 -MODULE_LICENSE("GPL");
55638 diff -Nru a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c
55639 --- a/net/ipv4/netfilter/iptable_mangle.c       Wed Jun 11 23:34:58 2003
55640 +++ b/net/ipv4/netfilter/iptable_mangle.c       Sun Aug 24 05:00:28 2003
55641 @@ -14,6 +14,10 @@
55642  #include <net/route.h>
55643  #include <linux/ip.h>
55644  
55645 +MODULE_LICENSE("GPL");
55646 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
55647 +MODULE_DESCRIPTION("iptables mangle table");
55648 +
55649  #define MANGLE_VALID_HOOKS ((1 << NF_IP_PRE_ROUTING) | \
55650                             (1 << NF_IP_LOCAL_IN) | \
55651                             (1 << NF_IP_FORWARD) | \
55652 @@ -267,4 +271,3 @@
55653  
55654  module_init(init);
55655  module_exit(fini);
55656 -MODULE_LICENSE("GPL");
55657 diff -Nru a/net/ipv4/route.c b/net/ipv4/route.c
55658 --- a/net/ipv4/route.c  Sat Aug 16 12:08:34 2003
55659 +++ b/net/ipv4/route.c  Thu Aug 28 00:02:15 2003
55660 @@ -312,49 +312,6 @@
55661         return 0;
55662  }
55663  
55664 -static int rt_cache_stat_get_info(char *buffer, char **start, off_t offset, int length)
55665 -{
55666 -       unsigned int dst_entries = atomic_read(&ipv4_dst_ops.entries);
55667 -       int i;
55668 -       int len = 0;
55669 -
55670 -       for (i = 0; i < NR_CPUS; i++) {
55671 -               if (!cpu_possible(i))
55672 -                       continue;
55673 -               len += sprintf(buffer+len, "%08x  %08x %08x %08x %08x %08x %08x %08x  %08x %08x %08x %08x %08x %08x %08x %08x %08x \n",
55674 -                              dst_entries,                    
55675 -                              per_cpu_ptr(rt_cache_stat, i)->in_hit,
55676 -                              per_cpu_ptr(rt_cache_stat, i)->in_slow_tot,
55677 -                              per_cpu_ptr(rt_cache_stat, i)->in_slow_mc,
55678 -                              per_cpu_ptr(rt_cache_stat, i)->in_no_route,
55679 -                              per_cpu_ptr(rt_cache_stat, i)->in_brd,
55680 -                              per_cpu_ptr(rt_cache_stat, i)->in_martian_dst,
55681 -                              per_cpu_ptr(rt_cache_stat, i)->in_martian_src,
55682 -
55683 -                              per_cpu_ptr(rt_cache_stat, i)->out_hit,
55684 -                              per_cpu_ptr(rt_cache_stat, i)->out_slow_tot,
55685 -                              per_cpu_ptr(rt_cache_stat, i)->out_slow_mc, 
55686 -
55687 -                              per_cpu_ptr(rt_cache_stat, i)->gc_total,
55688 -                              per_cpu_ptr(rt_cache_stat, i)->gc_ignored,
55689 -                              per_cpu_ptr(rt_cache_stat, i)->gc_goal_miss,
55690 -                              per_cpu_ptr(rt_cache_stat, i)->gc_dst_overflow,
55691 -                              per_cpu_ptr(rt_cache_stat, i)->in_hlist_search,
55692 -                              per_cpu_ptr(rt_cache_stat, i)->out_hlist_search
55693 -
55694 -                       );
55695 -       }
55696 -       len -= offset;
55697 -
55698 -       if (len > length)
55699 -               len = length;
55700 -       if (len < 0)
55701 -               len = 0;
55702 -
55703 -       *start = buffer + offset;
55704 -       return len;
55705 -}
55706 -
55707  static struct seq_operations rt_cache_seq_ops = {
55708         .start  = rt_cache_seq_start,
55709         .next   = rt_cache_seq_next,
55710 @@ -391,22 +348,89 @@
55711         .release = seq_release_private,
55712  };
55713  
55714 -int __init rt_cache_proc_init(void)
55715 +
55716 +static void *rt_cpu_seq_start(struct seq_file *seq, loff_t *pos)
55717  {
55718 -       int rc = 0;
55719 -       struct proc_dir_entry *p = create_proc_entry("rt_cache", S_IRUGO,
55720 -                                                    proc_net);
55721 -       if (p)
55722 -               p->proc_fops = &rt_cache_seq_fops;
55723 -       else
55724 -               rc = -ENOMEM;
55725 -       return rc;
55726 +       int cpu;
55727 +
55728 +       for (cpu = *pos; cpu < NR_CPUS; ++cpu) {
55729 +               if (!cpu_possible(cpu))
55730 +                       continue;
55731 +               *pos = cpu;
55732 +               return per_cpu_ptr(rt_cache_stat, cpu);
55733 +       }
55734 +       return NULL;
55735 +}
55736 +
55737 +static void *rt_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos)
55738 +{
55739 +       int cpu;
55740 +
55741 +       for (cpu = *pos + 1; cpu < NR_CPUS; ++cpu) {
55742 +               if (!cpu_possible(cpu))
55743 +                       continue;
55744 +               *pos = cpu;
55745 +               return per_cpu_ptr(rt_cache_stat, cpu);
55746 +       }
55747 +       return NULL;
55748 +       
55749  }
55750  
55751 -void __init rt_cache_proc_exit(void)
55752 +static void rt_cpu_seq_stop(struct seq_file *seq, void *v)
55753  {
55754 -       remove_proc_entry("rt_cache", proc_net);
55755 +
55756  }
55757 +
55758 +static int rt_cpu_seq_show(struct seq_file *seq, void *v)
55759 +{
55760 +       struct rt_cache_stat *st = v;
55761 +       
55762 +       seq_printf(seq,"%08x  %08x %08x %08x %08x %08x %08x %08x "
55763 +                  " %08x %08x %08x %08x %08x %08x %08x %08x %08x \n",
55764 +                  atomic_read(&ipv4_dst_ops.entries),
55765 +                  st->in_hit,
55766 +                  st->in_slow_tot,
55767 +                  st->in_slow_mc,
55768 +                  st->in_no_route,
55769 +                  st->in_brd,
55770 +                  st->in_martian_dst,
55771 +                  st->in_martian_src,
55772 +
55773 +                  st->out_hit,
55774 +                  st->out_slow_tot,
55775 +                  st->out_slow_mc, 
55776 +
55777 +                  st->gc_total,
55778 +                  st->gc_ignored,
55779 +                  st->gc_goal_miss,
55780 +                  st->gc_dst_overflow,
55781 +                  st->in_hlist_search,
55782 +                  st->out_hlist_search
55783 +               );
55784 +       return 0;
55785 +}
55786 +
55787 +static struct seq_operations rt_cpu_seq_ops = {
55788 +       .start  = rt_cpu_seq_start,
55789 +       .next   = rt_cpu_seq_next,
55790 +       .stop   = rt_cpu_seq_stop,
55791 +       .show   = rt_cpu_seq_show,
55792 +};
55793 +
55794 +
55795 +static int rt_cpu_seq_open(struct inode *inode, struct file *file)
55796 +{
55797 +       return seq_open(file, &rt_cpu_seq_ops);
55798 +}
55799 +
55800 +static struct file_operations rt_cpu_seq_fops = {
55801 +       .owner   = THIS_MODULE,
55802 +       .open    = rt_cpu_seq_open,
55803 +       .read    = seq_read,
55804 +       .llseek  = seq_lseek,
55805 +       .release = seq_release_private,
55806 +};
55807 +
55808  #endif /* CONFIG_PROC_FS */
55809    
55810  static __inline__ void rt_free(struct rtable *rt)
55811 @@ -2779,11 +2803,12 @@
55812         add_timer(&rt_secret_timer);
55813  
55814  #ifdef CONFIG_PROC_FS
55815 -       if (rt_cache_proc_init())
55816 +       if (!proc_net_fops_create("rt_cache", S_IRUGO, &rt_cache_seq_fops) ||
55817 +           !proc_net_fops_create("rt_cache_stat", S_IRUGO, &rt_cpu_seq_fops))
55818                 goto out_enomem;
55819 -       proc_net_create ("rt_cache_stat", 0, rt_cache_stat_get_info);
55820 +
55821  #ifdef CONFIG_NET_CLS_ROUTE
55822 -       create_proc_read_entry("net/rt_acct", 0, 0, ip_rt_acct_read, NULL);
55823 +       create_proc_read_entry("rt_acct", 0, proc_net, ip_rt_acct_read, NULL);
55824  #endif
55825  #endif
55826  #ifdef CONFIG_XFRM
55827 diff -Nru a/net/ipv6/icmp.c b/net/ipv6/icmp.c
55828 --- a/net/ipv6/icmp.c   Mon Aug 18 03:38:34 2003
55829 +++ b/net/ipv6/icmp.c   Mon Sep  1 01:38:00 2003
55830 @@ -70,12 +70,14 @@
55831  DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics);
55832  
55833  /*
55834 - *     ICMP socket(s) for flow control.
55835 + *     The ICMP socket(s). This is the most convenient way to flow control
55836 + *     our ICMP output as well as maintain a clean interface throughout
55837 + *     all layers. All Socketless IP sends will soon be gone.
55838 + *
55839 + *     On SMP we have one ICMP socket per-cpu.
55840   */
55841 -
55842 -/* XXX We can't use per_cpu because this can be modular... */
55843 -static struct socket *__icmpv6_socket[NR_CPUS];
55844 -#define icmpv6_socket  __icmpv6_socket[smp_processor_id()]
55845 +static DEFINE_PER_CPU(struct socket *, __icmpv6_socket) = NULL;
55846 +#define icmpv6_socket  __get_cpu_var(__icmpv6_socket)
55847  
55848  static int icmpv6_rcv(struct sk_buff **pskb, unsigned int *nhoffp);
55849  
55850 @@ -93,11 +95,19 @@
55851         __u32                   csum;
55852  };
55853  
55854 -static __inline__ void icmpv6_xmit_lock(void)
55855 +static __inline__ int icmpv6_xmit_lock(void)
55856  {
55857         local_bh_disable();
55858 -       if (unlikely(!spin_trylock(&icmpv6_socket->sk->sk_lock.slock)))
55859 -               BUG();
55860 +
55861 +       if (unlikely(!spin_trylock(&icmpv6_socket->sk->sk_lock.slock))) {
55862 +               /* This can happen if the output path (f.e. SIT or
55863 +                * ip6ip6 tunnel) signals dst_link_failure() for an
55864 +                * outgoing ICMP6 packet.
55865 +                */
55866 +               local_bh_enable();
55867 +               return 1;
55868 +       }
55869 +       return 0;
55870  }
55871  
55872  static __inline__ void icmpv6_xmit_unlock(void)
55873 @@ -342,7 +352,8 @@
55874         fl.fl_icmp_type = type;
55875         fl.fl_icmp_code = code;
55876  
55877 -       icmpv6_xmit_lock();
55878 +       if (icmpv6_xmit_lock())
55879 +               return;
55880  
55881         if (!icmpv6_xrlim_allow(sk, type, &fl))
55882                 goto out;
55883 @@ -432,7 +443,8 @@
55884         fl.oif = skb->dev->ifindex;
55885         fl.fl_icmp_type = ICMPV6_ECHO_REPLY;
55886  
55887 -       icmpv6_xmit_lock();
55888 +       if (icmpv6_xmit_lock())
55889 +               return;
55890  
55891         if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst))
55892                 fl.oif = np->mcast_oif;
55893 @@ -657,33 +669,23 @@
55894  int __init icmpv6_init(struct net_proto_family *ops)
55895  {
55896         struct sock *sk;
55897 -       int i;
55898 +       int err, i, j;
55899  
55900         for (i = 0; i < NR_CPUS; i++) {
55901 -               int err;
55902 -
55903                 if (!cpu_possible(i))
55904                         continue;
55905  
55906                 err = sock_create(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6,
55907 -                                 &__icmpv6_socket[i]);
55908 +                                 &per_cpu(__icmpv6_socket, i));
55909                 if (err < 0) {
55910 -                       int j;
55911 -
55912                         printk(KERN_ERR
55913                                "Failed to initialize the ICMP6 control socket "
55914                                "(err %d).\n",
55915                                err);
55916 -                       for (j = 0; j < i; j++) {
55917 -                               if (!cpu_possible(j))
55918 -                                       continue;
55919 -                               sock_release(__icmpv6_socket[j]);
55920 -                               __icmpv6_socket[j] = NULL; /* for safety */
55921 -                       }
55922 -                       return err;
55923 +                       goto fail;
55924                 }
55925  
55926 -               sk = __icmpv6_socket[i]->sk;
55927 +               sk = per_cpu(__icmpv6_socket, i)->sk;
55928                 sk->sk_allocation = GFP_ATOMIC;
55929                 sk->sk_sndbuf = SK_WMEM_MAX * 2;
55930                 sk->sk_prot->unhash(sk);
55931 @@ -692,16 +694,20 @@
55932  
55933         if (inet6_add_protocol(&icmpv6_protocol, IPPROTO_ICMPV6) < 0) {
55934                 printk(KERN_ERR "Failed to register ICMP6 protocol\n");
55935 -               for (i = 0; i < NR_CPUS; i++) {
55936 -                       if (!cpu_possible(i))
55937 -                               continue;
55938 -                       sock_release(__icmpv6_socket[i]);
55939 -                       __icmpv6_socket[i] = NULL;
55940 -               }
55941 -               return -EAGAIN;
55942 +               err = -EAGAIN;
55943 +               goto fail;
55944         }
55945  
55946         return 0;
55947 +
55948 + fail:
55949 +       for (j = 0; j < i; j++) {
55950 +               if (!cpu_possible(j))
55951 +                       continue;
55952 +               sock_release(per_cpu(__icmpv6_socket, j));
55953 +       }
55954 +
55955 +       return err;
55956  }
55957  
55958  void icmpv6_cleanup(void)
55959 @@ -711,8 +717,7 @@
55960         for (i = 0; i < NR_CPUS; i++) {
55961                 if (!cpu_possible(i))
55962                         continue;
55963 -               sock_release(__icmpv6_socket[i]);
55964 -               __icmpv6_socket[i] = NULL; /* For safety. */
55965 +               sock_release(per_cpu(__icmpv6_socket, i));
55966         }
55967         inet6_del_protocol(&icmpv6_protocol, IPPROTO_ICMPV6);
55968  }
55969 diff -Nru a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
55970 --- a/net/ipv6/ip6_output.c     Mon Aug 18 03:38:34 2003
55971 +++ b/net/ipv6/ip6_output.c     Mon Sep  1 01:44:26 2003
55972 @@ -876,7 +876,7 @@
55973         /* Connection association is same as pre-frag packet */
55974         to->nfct = from->nfct;
55975         nf_conntrack_get(to->nfct);
55976 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
55977 +#ifdef CONFIG_BRIDGE_NETFILTER
55978         to->nf_bridge = from->nf_bridge;
55979         nf_bridge_get(to->nf_bridge);
55980  #endif
55981 diff -Nru a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
55982 --- a/net/ipv6/ip6_tunnel.c     Mon Aug 18 04:52:14 2003
55983 +++ b/net/ipv6/ip6_tunnel.c     Mon Sep  1 01:55:01 2003
55984 @@ -23,7 +23,6 @@
55985  #include <linux/module.h>
55986  #include <linux/errno.h>
55987  #include <linux/types.h>
55988 -#include <linux/socket.h>
55989  #include <linux/sockios.h>
55990  #include <linux/if.h>
55991  #include <linux/in.h>
55992 @@ -37,12 +36,12 @@
55993  #include <linux/init.h>
55994  #include <linux/route.h>
55995  #include <linux/rtnetlink.h>
55996 +#include <linux/netfilter_ipv6.h>
55997  
55998  #include <asm/uaccess.h>
55999  #include <asm/atomic.h>
56000  
56001  #include <net/ip.h>
56002 -#include <net/sock.h>
56003  #include <net/ipv6.h>
56004  #include <net/protocol.h>
56005  #include <net/ip6_route.h>
56006 @@ -63,22 +62,6 @@
56007  
56008  #define IPV6_TCLASS_MASK (IPV6_FLOWINFO_MASK & ~IPV6_FLOWLABEL_MASK)
56009  
56010 -/* socket(s) used by ip6ip6_tnl_xmit() for resending packets */
56011 -static struct socket *__ip6_socket[NR_CPUS];
56012 -#define ip6_socket __ip6_socket[smp_processor_id()]
56013 -
56014 -static void ip6_xmit_lock(void)
56015 -{
56016 -       local_bh_disable();
56017 -       if (unlikely(!spin_trylock(&ip6_socket->sk->sk_lock.slock)))
56018 -               BUG();
56019 -}
56020 -
56021 -static void ip6_xmit_unlock(void)
56022 -{
56023 -       spin_unlock_bh(&ip6_socket->sk->sk_lock.slock);
56024 -}
56025 -
56026  #define HASH_SIZE  32
56027  
56028  #define HASH(addr) (((addr)->s6_addr32[0] ^ (addr)->s6_addr32[1] ^ \
56029 @@ -101,6 +84,33 @@
56030  /* lock for the tunnel lists */
56031  static rwlock_t ip6ip6_lock = RW_LOCK_UNLOCKED;
56032  
56033 +static inline struct dst_entry *ip6_tnl_dst_check(struct ip6_tnl *t)
56034 +{
56035 +       struct dst_entry *dst = t->dst_cache;
56036 +
56037 +       if (dst && dst->obsolete && 
56038 +           dst->ops->check(dst, t->dst_cookie) == NULL) {
56039 +               t->dst_cache = NULL;
56040 +               return NULL;
56041 +       }
56042 +
56043 +       return dst;
56044 +}
56045 +
56046 +static inline void ip6_tnl_dst_reset(struct ip6_tnl *t)
56047 +{
56048 +       dst_release(t->dst_cache);
56049 +       t->dst_cache = NULL;
56050 +}
56051 +
56052 +static inline void ip6_tnl_dst_store(struct ip6_tnl *t, struct dst_entry *dst)
56053 +{
56054 +       struct rt6_info *rt = (struct rt6_info *) dst;
56055 +       t->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
56056 +       dst_release(t->dst_cache);
56057 +       t->dst_cache = dst;
56058 +}
56059 +
56060  /**
56061   * ip6ip6_tnl_lookup - fetch tunnel matching the end-point addresses
56062   *   @remote: the address of the tunnel exit-point 
56063 @@ -294,13 +304,16 @@
56064  static void
56065  ip6ip6_tnl_dev_uninit(struct net_device *dev)
56066  {
56067 +       struct ip6_tnl *t = dev->priv;
56068 +
56069         if (dev == ip6ip6_fb_tnl_dev) {
56070                 write_lock_bh(&ip6ip6_lock);
56071                 tnls_wc[0] = NULL;
56072                 write_unlock_bh(&ip6ip6_lock);
56073         } else {
56074 -               ip6ip6_tnl_unlink((struct ip6_tnl *) dev->priv);
56075 +               ip6ip6_tnl_unlink(t);
56076         }
56077 +       ip6_tnl_dst_reset(t);
56078         dev_put(dev);
56079  }
56080  
56081 @@ -421,7 +434,7 @@
56082                 }
56083                 teli = parse_tlv_tnl_enc_lim(skb, skb->data);
56084  
56085 -               if (teli && teli == info - 2) {
56086 +               if (teli && teli == ntohl(info) - 2) {
56087                         tel = (struct ipv6_tlv_tnl_enc_lim *) &skb->data[teli];
56088                         if (tel->encap_limit == 0) {
56089                                 if (net_ratelimit())
56090 @@ -434,10 +447,9 @@
56091                 }
56092                 break;
56093         case ICMPV6_PKT_TOOBIG:
56094 -               mtu = info - offset;
56095 -               if (mtu <= IPV6_MIN_MTU) {
56096 +               mtu = ntohl(info) - offset;
56097 +               if (mtu < IPV6_MIN_MTU)
56098                         mtu = IPV6_MIN_MTU;
56099 -               }
56100                 t->dev->mtu = mtu;
56101  
56102                 if ((len = sizeof (*ipv6h) + ipv6h->payload_len) > mtu) {
56103 @@ -523,112 +535,34 @@
56104         return 0;
56105  }
56106  
56107 -/**
56108 - * txopt_len - get necessary size for new &struct ipv6_txoptions
56109 - *   @orig_opt: old options
56110 - *
56111 - * Return:
56112 - *   Size of old one plus size of tunnel encapsulation limit option
56113 - **/
56114 -
56115 -static inline int
56116 -txopt_len(struct ipv6_txoptions *orig_opt)
56117 -{
56118 -       int len = sizeof (*orig_opt) + 8;
56119 -
56120 -       if (orig_opt && orig_opt->dst0opt)
56121 -               len += ipv6_optlen(orig_opt->dst0opt);
56122 -       return len;
56123 -}
56124 -
56125 -/**
56126 - * merge_options - add encapsulation limit to original options
56127 - *   @encap_limit: number of allowed encapsulation limits
56128 - *   @orig_opt: original options
56129 - * 
56130 - * Return:
56131 - *   Pointer to new &struct ipv6_txoptions containing the tunnel
56132 - *   encapsulation limit
56133 - **/
56134 -
56135 -static struct ipv6_txoptions *
56136 -merge_options(struct sock *sk, __u8 encap_limit,
56137 -             struct ipv6_txoptions *orig_opt)
56138 +static inline struct ipv6_txoptions *create_tel(__u8 encap_limit)
56139  {
56140         struct ipv6_tlv_tnl_enc_lim *tel;
56141         struct ipv6_txoptions *opt;
56142         __u8 *raw;
56143 -       __u8 pad_to = 8;
56144 -       int opt_len = txopt_len(orig_opt);
56145  
56146 -       if (!(opt = sock_kmalloc(sk, opt_len, GFP_ATOMIC))) {
56147 +       int opt_len = sizeof(*opt) + 8;
56148 +
56149 +       if (!(opt = kmalloc(opt_len, GFP_ATOMIC))) {
56150                 return NULL;
56151         }
56152 -
56153         memset(opt, 0, opt_len);
56154         opt->tot_len = opt_len;
56155         opt->dst0opt = (struct ipv6_opt_hdr *) (opt + 1);
56156         opt->opt_nflen = 8;
56157  
56158 -       raw = (__u8 *) opt->dst0opt;
56159 -
56160         tel = (struct ipv6_tlv_tnl_enc_lim *) (opt->dst0opt + 1);
56161         tel->type = IPV6_TLV_TNL_ENCAP_LIMIT;
56162         tel->length = 1;
56163         tel->encap_limit = encap_limit;
56164  
56165 -       if (orig_opt) {
56166 -               __u8 *orig_raw;
56167 -
56168 -               opt->hopopt = orig_opt->hopopt;
56169 -
56170 -               /* Keep the original destination options properly
56171 -                  aligned and merge possible old paddings to the
56172 -                  new padding option */
56173 -               if ((orig_raw = (__u8 *) orig_opt->dst0opt) != NULL) {
56174 -                       __u8 type;
56175 -                       int i = sizeof (struct ipv6_opt_hdr);
56176 -                       pad_to += sizeof (struct ipv6_opt_hdr);
56177 -                       while (i < ipv6_optlen(orig_opt->dst0opt)) {
56178 -                               type = orig_raw[i++];
56179 -                               if (type == IPV6_TLV_PAD0)
56180 -                                       pad_to++;
56181 -                               else if (type == IPV6_TLV_PADN) {
56182 -                                       int len = orig_raw[i++];
56183 -                                       i += len;
56184 -                                       pad_to += len + 2;
56185 -                               } else {
56186 -                                       break;
56187 -                               }
56188 -                       }
56189 -                       opt->dst0opt->hdrlen = orig_opt->dst0opt->hdrlen + 1;
56190 -                       memcpy(raw + pad_to, orig_raw + pad_to - 8,
56191 -                              opt_len - sizeof (*opt) - pad_to);
56192 -               }
56193 -               opt->srcrt = orig_opt->srcrt;
56194 -               opt->opt_nflen += orig_opt->opt_nflen;
56195 -
56196 -               opt->dst1opt = orig_opt->dst1opt;
56197 -               opt->auth = orig_opt->auth;
56198 -               opt->opt_flen = orig_opt->opt_flen;
56199 -       }
56200 +       raw = (__u8 *) opt->dst0opt;
56201         raw[5] = IPV6_TLV_PADN;
56202 -
56203 -       /* subtract lengths of destination suboption header,
56204 -          tunnel encapsulation limit and pad N header */
56205 -       raw[6] = pad_to - 7;
56206 +       raw[6] = 1;
56207  
56208         return opt;
56209  }
56210  
56211 -static int 
56212 -ip6ip6_getfrag(void *from, char *to, int offset, int len, int odd, 
56213 -               struct sk_buff *skb)
56214 -{
56215 -       memcpy(to, (char *) from + offset, len);
56216 -       return 0;
56217 -}
56218 -
56219  /**
56220   * ip6ip6_tnl_addr_conflict - compare packet addresses to tunnel's own
56221   *   @t: the outgoing tunnel device
56222 @@ -656,7 +590,7 @@
56223   *
56224   * Description:
56225   *   Build new header and do some sanity checks on the packet before sending
56226 - *   it to ip6_build_xmit().
56227 + *   it.
56228   *
56229   * Return: 
56230   *   0
56231 @@ -667,18 +601,17 @@
56232         struct ip6_tnl *t = (struct ip6_tnl *) dev->priv;
56233         struct net_device_stats *stats = &t->stat;
56234         struct ipv6hdr *ipv6h = skb->nh.ipv6h;
56235 -       struct ipv6_txoptions *orig_opt = NULL;
56236         struct ipv6_txoptions *opt = NULL;
56237         int encap_limit = -1;
56238         __u16 offset;
56239         struct flowi fl;
56240 -       struct ip6_flowlabel *fl_lbl = NULL;
56241 -       int err = 0;
56242         struct dst_entry *dst;
56243 -       int link_failure = 0;
56244 -       struct sock *sk = ip6_socket->sk;
56245 -       struct ipv6_pinfo *np = inet6_sk(sk);
56246 +       struct net_device *tdev;
56247         int mtu;
56248 +       int max_headroom = sizeof(struct ipv6hdr);
56249 +       u8 proto;
56250 +       int err;
56251 +       int pkt_len;
56252  
56253         if (t->recursion++) {
56254                 stats->collisions++;
56255 @@ -701,58 +634,39 @@
56256         } else if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT)) {
56257                 encap_limit = t->parms.encap_limit;
56258         }
56259 -       ip6_xmit_lock();
56260 -
56261         memcpy(&fl, &t->fl, sizeof (fl));
56262 +       proto = fl.proto;
56263  
56264         if ((t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS))
56265                 fl.fl6_flowlabel |= (*(__u32 *) ipv6h & IPV6_TCLASS_MASK);
56266         if ((t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL))
56267                 fl.fl6_flowlabel |= (*(__u32 *) ipv6h & IPV6_FLOWLABEL_MASK);
56268  
56269 -       if (fl.fl6_flowlabel) {
56270 -               fl_lbl = fl6_sock_lookup(sk, fl.fl6_flowlabel);
56271 -               if (fl_lbl)
56272 -                       orig_opt = fl_lbl->opt;
56273 -       }
56274 -       if (encap_limit >= 0) {
56275 -               if (!(opt = merge_options(sk, encap_limit, orig_opt))) {
56276 -                       goto tx_err_free_fl_lbl;
56277 -               }
56278 -       } else {
56279 -               opt = orig_opt;
56280 -       }
56281 -       dst = __sk_dst_check(sk, np->dst_cookie);
56282 +       if (encap_limit >= 0 && (opt = create_tel(encap_limit)) == NULL)
56283 +               goto tx_err;
56284  
56285 -       if (dst) {
56286 -               if (np->daddr_cache == NULL ||
56287 -                   ipv6_addr_cmp(&fl.fl6_dst, np->daddr_cache) ||
56288 -                   (fl.oif && fl.oif != dst->dev->ifindex)) {
56289 -                       dst = NULL;
56290 -               }
56291 -       }
56292 -       if (dst == NULL) {
56293 -               dst = ip6_route_output(sk, &fl);
56294 -               if (dst->error) {
56295 -                       stats->tx_carrier_errors++;
56296 -                       link_failure = 1;
56297 -                       goto tx_err_dst_release;
56298 -               }
56299 -               /* local routing loop */
56300 -               if (dst->dev == dev) {
56301 -                       stats->collisions++;
56302 -                       if (net_ratelimit())
56303 -                               printk(KERN_WARNING 
56304 -                                      "%s: Local routing loop detected!\n",
56305 -                                      t->parms.name);
56306 -                       goto tx_err_dst_release;
56307 -               }
56308 -               ipv6_addr_copy(&np->daddr, &fl.fl6_dst);
56309 -               ipv6_addr_copy(&np->saddr, &fl.fl6_src);
56310 +       if ((dst = ip6_tnl_dst_check(t)) != NULL)
56311 +               dst_hold(dst);
56312 +       else
56313 +               dst = ip6_route_output(NULL, &fl);
56314 +
56315 +       if (dst->error || xfrm_lookup(&dst, &fl, NULL, 0) < 0)
56316 +               goto tx_err_link_failure;
56317 +
56318 +       tdev = dst->dev;
56319 +
56320 +       if (tdev == dev) {
56321 +               stats->collisions++;
56322 +               if (net_ratelimit())
56323 +                       printk(KERN_WARNING 
56324 +                              "%s: Local routing loop detected!\n",
56325 +                              t->parms.name);
56326 +               goto tx_err_dst_release;
56327         }
56328         mtu = dst_pmtu(dst) - sizeof (*ipv6h);
56329         if (opt) {
56330 -               mtu -= (opt->opt_nflen + opt->opt_flen);
56331 +               max_headroom += 8;
56332 +               mtu -= 8;
56333         }
56334         if (mtu < IPV6_MIN_MTU)
56335                 mtu = IPV6_MIN_MTU;
56336 @@ -765,41 +679,71 @@
56337                 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, dev);
56338                 goto tx_err_dst_release;
56339         }
56340 -       err = ip6_append_data(sk, ip6ip6_getfrag, skb->nh.raw, skb->len, 0,
56341 -                             t->parms.hop_limit, opt, &fl, 
56342 -                             (struct rt6_info *)dst, MSG_DONTWAIT);
56343 +       skb->h.raw = skb->nh.raw;
56344  
56345 -       if (err) {
56346 -               ip6_flush_pending_frames(sk);
56347 -       } else {
56348 -               err = ip6_push_pending_frames(sk);
56349 -               err = (err < 0 ? err : 0);
56350 +       /*
56351 +        * Okay, now see if we can stuff it in the buffer as-is.
56352 +        */
56353 +       max_headroom += LL_RESERVED_SPACE(tdev);
56354 +       
56355 +       if (skb_headroom(skb) < max_headroom || 
56356 +           skb_cloned(skb) || skb_shared(skb)) {
56357 +               struct sk_buff *new_skb;
56358 +               
56359 +               if (!(new_skb = skb_realloc_headroom(skb, max_headroom)))
56360 +                       goto tx_err_dst_release;
56361 +
56362 +               if (skb->sk)
56363 +                       skb_set_owner_w(new_skb, skb->sk);
56364 +               kfree_skb(skb);
56365 +               skb = new_skb;
56366         }
56367 -       if (!err) {
56368 -               stats->tx_bytes += skb->len;
56369 +       dst_release(skb->dst);
56370 +       skb->dst = dst_clone(dst);
56371 +
56372 +       if (opt)
56373 +               ipv6_push_nfrag_opts(skb, opt, &proto, NULL);
56374 +
56375 +       skb->nh.raw = skb_push(skb, sizeof(struct ipv6hdr));
56376 +       ipv6h = skb->nh.ipv6h;
56377 +       *(u32*)ipv6h = fl.fl6_flowlabel | htonl(0x60000000);
56378 +       ipv6h->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
56379 +       ipv6h->hop_limit = t->parms.hop_limit;
56380 +       ipv6h->nexthdr = proto;
56381 +       ipv6_addr_copy(&ipv6h->saddr, &fl.fl6_src);
56382 +       ipv6_addr_copy(&ipv6h->daddr, &fl.fl6_dst);
56383 +#ifdef CONFIG_NETFILTER
56384 +       nf_conntrack_put(skb->nfct);
56385 +       skb->nfct = NULL;
56386 +#ifdef CONFIG_NETFILTER_DEBUG
56387 +       skb->nf_debug = 0;
56388 +#endif
56389 +#endif
56390 +       pkt_len = skb->len;
56391 +       err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, 
56392 +                     skb->dst->dev, dst_output);
56393 +
56394 +       if (err == NET_XMIT_SUCCESS || err == NET_XMIT_CN) {
56395 +               stats->tx_bytes += pkt_len;
56396                 stats->tx_packets++;
56397         } else {
56398                 stats->tx_errors++;
56399                 stats->tx_aborted_errors++;
56400         }
56401 -       if (opt && opt != orig_opt)
56402 -               sock_kfree_s(sk, opt, opt->tot_len);
56403 +       ip6_tnl_dst_store(t, dst);
56404 +
56405 +       if (opt)
56406 +               kfree(opt);
56407  
56408 -       fl6_sock_release(fl_lbl);
56409 -       ip6_dst_store(sk, dst, &np->daddr);
56410 -       ip6_xmit_unlock();
56411 -       kfree_skb(skb);
56412         t->recursion--;
56413         return 0;
56414 +tx_err_link_failure:
56415 +       stats->tx_carrier_errors++;
56416 +       dst_link_failure(skb);
56417  tx_err_dst_release:
56418         dst_release(dst);
56419 -       if (opt && opt != orig_opt)
56420 -               sock_kfree_s(sk, opt, opt->tot_len);
56421 -tx_err_free_fl_lbl:
56422 -       fl6_sock_release(fl_lbl);
56423 -       ip6_xmit_unlock();
56424 -       if (link_failure)
56425 -               dst_link_failure(skb);
56426 +       if (opt)
56427 +               kfree(opt);
56428  tx_err:
56429         stats->tx_errors++;
56430         stats->tx_dropped++;
56431 @@ -851,9 +795,12 @@
56432  {
56433         struct net_device *dev = t->dev;
56434         struct ip6_tnl_parm *p = &t->parms;
56435 -       struct flowi *fl;
56436 +       struct flowi *fl = &t->fl;
56437 +
56438 +       memcpy(&dev->dev_addr, &p->laddr, sizeof(struct in6_addr));
56439 +       memcpy(&dev->broadcast, &p->raddr, sizeof(struct in6_addr));
56440 +
56441         /* Set up flowi template */
56442 -       fl = &t->fl;
56443         ipv6_addr_copy(&fl->fl6_src, &p->laddr);
56444         ipv6_addr_copy(&fl->fl6_dst, &p->raddr);
56445         fl->oif = p->link;
56446 @@ -878,10 +825,7 @@
56447                 if (rt == NULL)
56448                         return;
56449  
56450 -               /* as long as tunnels use the same socket for transmission,
56451 -                  locally nested tunnels won't work */
56452 -               
56453 -               if (rt->rt6i_dev && rt->rt6i_dev->type != ARPHRD_TUNNEL6) {
56454 +               if (rt->rt6i_dev) {
56455                         dev->iflink = rt->rt6i_dev->ifindex;
56456  
56457                         dev->hard_header_len = rt->rt6i_dev->hard_header_len +
56458 @@ -1083,7 +1027,7 @@
56459  {
56460         SET_MODULE_OWNER(dev);
56461         dev->uninit = ip6ip6_tnl_dev_uninit;
56462 -       dev->destructor = (void (*)(struct net_device *))kfree;
56463 +       dev->destructor = free_netdev;
56464         dev->hard_start_xmit = ip6ip6_tnl_xmit;
56465         dev->get_stats = ip6ip6_tnl_get_stats;
56466         dev->do_ioctl = ip6ip6_tnl_ioctl;
56467 @@ -1094,10 +1038,7 @@
56468         dev->mtu = ETH_DATA_LEN - sizeof (struct ipv6hdr);
56469         dev->flags |= IFF_NOARP;
56470         dev->iflink = 0;
56471 -       /* Hmm... MAX_ADDR_LEN is 8, so the ipv6 addresses can't be
56472 -          copied to dev->dev_addr and dev->broadcast, like the ipv4
56473 -          addresses were in ipip.c, ip_gre.c and sit.c. */
56474 -       dev->addr_len = 0;
56475 +       dev->addr_len = sizeof(struct in6_addr);
56476  }
56477  
56478  
56479 @@ -1139,7 +1080,7 @@
56480  int ip6ip6_fb_tnl_dev_init(struct net_device *dev)
56481  {
56482         struct ip6_tnl *t = dev->priv;
56483 -       ip6ip6_tnl_dev_init_gen(dev); 
56484 +       ip6ip6_tnl_dev_init_gen(dev);
56485         dev_hold(dev);
56486         tnls_wc[0] = t;
56487         return 0;
56488 @@ -1159,61 +1100,28 @@
56489  
56490  int __init ip6_tunnel_init(void)
56491  {
56492 -       int i, j, err;
56493 -       struct sock *sk;
56494 -       struct ipv6_pinfo *np;
56495 -
56496 -       for (i = 0; i < NR_CPUS; i++) {
56497 -               if (!cpu_possible(i))
56498 -                       continue;
56499 -
56500 -               err = sock_create(PF_INET6, SOCK_RAW, IPPROTO_IPV6, 
56501 -                                 &__ip6_socket[i]);
56502 -               if (err < 0) {
56503 -                       printk(KERN_ERR 
56504 -                              "Failed to create the IPv6 tunnel socket "
56505 -                              "(err %d).\n", 
56506 -                              err);
56507 -                       goto fail;
56508 -               }
56509 -               sk = __ip6_socket[i]->sk;
56510 -               sk->sk_allocation = GFP_ATOMIC;
56511 -
56512 -               np = inet6_sk(sk);
56513 -               np->hop_limit = 255;
56514 -               np->mc_loop = 0;
56515 +       int  err;
56516  
56517 -               sk->sk_prot->unhash(sk);
56518 -       }
56519         if ((err = inet6_add_protocol(&ip6ip6_protocol, IPPROTO_IPV6)) < 0) {
56520                 printk(KERN_ERR "Failed to register IPv6 protocol\n");
56521 -               goto fail;
56522 +               return err;
56523         }
56524 -
56525 -       
56526         ip6ip6_fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6tnl0",
56527                                          ip6ip6_tnl_dev_setup);
56528  
56529         if (!ip6ip6_fb_tnl_dev) {
56530                 err = -ENOMEM;
56531 -               goto tnl_fail;
56532 +               goto fail;
56533         }
56534         ip6ip6_fb_tnl_dev->init = ip6ip6_fb_tnl_dev_init;
56535  
56536         if ((err = register_netdev(ip6ip6_fb_tnl_dev))) {
56537                 kfree(ip6ip6_fb_tnl_dev);
56538 -               goto tnl_fail;
56539 +               goto fail;
56540         }
56541         return 0;
56542 -tnl_fail:
56543 -       inet6_del_protocol(&ip6ip6_protocol, IPPROTO_IPV6);
56544  fail:
56545 -       for (j = 0; j < i; j++) {
56546 -               if (!cpu_possible(j))
56547 -                       continue;
56548 -               sock_release(__ip6_socket[j]);
56549 -               __ip6_socket[j] = NULL;
56550 -       }
56551 +       inet6_del_protocol(&ip6ip6_protocol, IPPROTO_IPV6);
56552         return err;
56553  }
56554  
56555 @@ -1223,18 +1131,8 @@
56556  
56557  void ip6_tunnel_cleanup(void)
56558  {
56559 -       int i;
56560 -
56561         unregister_netdev(ip6ip6_fb_tnl_dev);
56562 -
56563         inet6_del_protocol(&ip6ip6_protocol, IPPROTO_IPV6);
56564 -
56565 -       for (i = 0; i < NR_CPUS; i++) {
56566 -               if (!cpu_possible(i))
56567 -                       continue;
56568 -               sock_release(__ip6_socket[i]);
56569 -               __ip6_socket[i] = NULL;
56570 -       }
56571  }
56572  
56573  #ifdef MODULE
56574 diff -Nru a/net/ipv6/ipv6_syms.c b/net/ipv6/ipv6_syms.c
56575 --- a/net/ipv6/ipv6_syms.c      Sat Aug  9 02:14:55 2003
56576 +++ b/net/ipv6/ipv6_syms.c      Mon Sep  1 01:55:02 2003
56577 @@ -45,3 +45,4 @@
56578  EXPORT_SYMBOL(ip6_append_data);
56579  EXPORT_SYMBOL(ip6_flush_pending_frames);
56580  EXPORT_SYMBOL(ip6_push_pending_frames);
56581 +EXPORT_SYMBOL(ipv6_push_nfrag_opts);
56582 diff -Nru a/net/ipv6/mcast.c b/net/ipv6/mcast.c
56583 --- a/net/ipv6/mcast.c  Thu Aug 21 14:48:55 2003
56584 +++ b/net/ipv6/mcast.c  Wed Aug 27 23:45:13 2003
56585 @@ -2078,6 +2078,7 @@
56586                         break;
56587                 }
56588                 read_unlock_bh(&idev->lock);
56589 +               in6_dev_put(idev);
56590         }
56591         return im;
56592  }
56593 @@ -2135,7 +2136,9 @@
56594         if (likely(state->idev != NULL)) {
56595                 read_unlock_bh(&state->idev->lock);
56596                 in6_dev_put(state->idev);
56597 +               state->idev = NULL;
56598         }
56599 +       state->dev = NULL;
56600         read_unlock(&dev_base_lock);
56601  }
56602  
56603 @@ -2225,6 +2228,7 @@
56604                         spin_unlock_bh(&im->mca_lock);
56605                 }
56606                 read_unlock_bh(&idev->lock);
56607 +               in6_dev_put(idev);
56608         }
56609         return psf;
56610  }
56611 @@ -2291,12 +2295,16 @@
56612  static void igmp6_mcf_seq_stop(struct seq_file *seq, void *v)
56613  {
56614         struct igmp6_mcf_iter_state *state = igmp6_mcf_seq_private(seq);
56615 -       if (likely(state->im != NULL))
56616 +       if (likely(state->im != NULL)) {
56617                 spin_unlock_bh(&state->im->mca_lock);
56618 +               state->im = NULL;
56619 +       }
56620         if (likely(state->idev != NULL)) {
56621                 read_unlock_bh(&state->idev->lock);
56622                 in6_dev_put(state->idev);
56623 +               state->idev = NULL;
56624         }
56625 +       state->dev = NULL;
56626         read_unlock(&dev_base_lock);
56627  }
56628  
56629 diff -Nru a/net/ipv6/netfilter/Kconfig b/net/ipv6/netfilter/Kconfig
56630 --- a/net/ipv6/netfilter/Kconfig        Mon Mar  3 01:40:45 2003
56631 +++ b/net/ipv6/netfilter/Kconfig        Sun Aug 24 04:58:54 2003
56632 @@ -3,14 +3,14 @@
56633  #
56634  
56635  menu "IPv6: Netfilter Configuration"
56636 -       depends on INET && EXPERIMENTAL && IPV6!=n && NETFILTER
56637 +       depends on INET && IPV6!=n && NETFILTER
56638  
56639  #tristate 'Connection tracking (required for masq/NAT)' CONFIG_IP6_NF_CONNTRACK
56640  #if [ "$CONFIG_IP6_NF_CONNTRACK" != "n" ]; then
56641  #  dep_tristate '  FTP protocol support' CONFIG_IP6_NF_FTP $CONFIG_IP6_NF_CONNTRACK
56642  #fi
56643  config IP6_NF_QUEUE
56644 -       tristate "Userspace queueing via NETLINK (EXPERIMENTAL)"
56645 +       tristate "Userspace queueing via NETLINK"
56646         ---help---
56647  
56648           This option adds a queue handler to the kernel for IPv6
56649 @@ -62,7 +62,7 @@
56650  
56651  config IP6_NF_MATCH_RT
56652         tristate "Routing header match support"
56653 -       depends on IP6_NF_IPTABLES && EXPERIMENTAL
56654 +       depends on IP6_NF_IPTABLES
56655         help
56656           rt matching allows you to match packets based on the routing
56657           header of the packet.
56658 @@ -72,7 +72,7 @@
56659  
56660  config IP6_NF_MATCH_OPTS
56661         tristate "Hop-by-hop and Dst opts header match support"
56662 -       depends on IP6_NF_IPTABLES && EXPERIMENTAL
56663 +       depends on IP6_NF_IPTABLES
56664         help
56665           This allows one to match packets based on the hop-by-hop
56666           and destination options headers of a packet.
56667 @@ -82,7 +82,7 @@
56668  
56669  config IP6_NF_MATCH_FRAG
56670         tristate "Fragmentation header match support"
56671 -       depends on IP6_NF_IPTABLES && EXPERIMENTAL
56672 +       depends on IP6_NF_IPTABLES
56673         help
56674           frag matching allows you to match packets based on the fragmentation
56675           header of the packet.
56676 @@ -112,7 +112,7 @@
56677           <file:Documentation/modules.txt>.  If unsure, say `N'.
56678  
56679  config IP6_NF_MATCH_OWNER
56680 -       tristate "Owner match support (EXPERIMENTAL)"
56681 +       tristate "Owner match support"
56682         depends on IP6_NF_IPTABLES
56683         help
56684           Packet owner matching allows you to match locally-generated packets
56685 @@ -134,8 +134,8 @@
56686           <file:Documentation/modules.txt>.  If unsure, say `N'.
56687  
56688  config IP6_NF_MATCH_IPV6HEADER
56689 -       tristate "IPv6 Extension Headers Match (EXPERIMENTAL)"
56690 -       depends on IP6_NF_IPTABLES && EXPERIMENTAL
56691 +       tristate "IPv6 Extension Headers Match"
56692 +       depends on IP6_NF_IPTABLES
56693         help
56694           This module allows one to match packets based upon
56695           the ipv6 extension headers.
56696 @@ -144,8 +144,8 @@
56697           <file:Documentation/modules.txt>.  If unsure, say `N'.
56698  
56699  config IP6_NF_MATCH_AHESP
56700 -       tristate "AH/ESP match support (EXPERIMENTAL)"
56701 -       depends on IP6_NF_IPTABLES && EXPERIMENTAL
56702 +       tristate "AH/ESP match support"
56703 +       depends on IP6_NF_IPTABLES
56704         help
56705           This module allows one to match AH and ESP packets.
56706  
56707 @@ -163,7 +163,7 @@
56708           Documentation/modules.txt.  If unsure, say `N'.
56709  
56710  config IP6_NF_MATCH_EUI64
56711 -       tristate "EUI64 address check (EXPERIMENTAL)"
56712 +       tristate "EUI64 address check"
56713         depends on IP6_NF_IPTABLES
56714         help
56715           This module performs checking on the IPv6 source address
56716 diff -Nru a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
56717 --- a/net/ipv6/netfilter/ip6_tables.c   Sat Aug  2 18:29:29 2003
56718 +++ b/net/ipv6/netfilter/ip6_tables.c   Sun Aug 24 05:00:28 2003
56719 @@ -26,6 +26,10 @@
56720  
56721  #include <linux/netfilter_ipv6/ip6_tables.h>
56722  
56723 +MODULE_LICENSE("GPL");
56724 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
56725 +MODULE_DESCRIPTION("IPv6 packet filter");
56726 +
56727  #define IPV6_HDR_LEN   (sizeof(struct ipv6hdr))
56728  #define IPV6_OPTHDR_LEN        (sizeof(struct ipv6_opt_hdr))
56729  
56730 @@ -1923,4 +1927,3 @@
56731  
56732  module_init(init);
56733  module_exit(fini);
56734 -MODULE_LICENSE("GPL");
56735 diff -Nru a/net/ipv6/netfilter/ip6t_MARK.c b/net/ipv6/netfilter/ip6t_MARK.c
56736 --- a/net/ipv6/netfilter/ip6t_MARK.c    Tue Feb  5 07:24:40 2002
56737 +++ b/net/ipv6/netfilter/ip6t_MARK.c    Sun Aug 24 05:00:28 2003
56738 @@ -7,6 +7,9 @@
56739  #include <linux/netfilter_ipv6/ip6_tables.h>
56740  #include <linux/netfilter_ipv6/ip6t_MARK.h>
56741  
56742 +MODULE_LICENSE("GPL");
56743 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
56744 +
56745  static unsigned int
56746  target(struct sk_buff **pskb,
56747         unsigned int hooknum,
56748 @@ -65,4 +68,3 @@
56749  
56750  module_init(init);
56751  module_exit(fini);
56752 -MODULE_LICENSE("GPL");
56753 diff -Nru a/net/ipv6/netfilter/ip6t_eui64.c b/net/ipv6/netfilter/ip6t_eui64.c
56754 --- a/net/ipv6/netfilter/ip6t_eui64.c   Thu Mar 20 00:43:40 2003
56755 +++ b/net/ipv6/netfilter/ip6t_eui64.c   Sun Aug 24 05:00:28 2003
56756 @@ -6,6 +6,10 @@
56757  
56758  #include <linux/netfilter_ipv6/ip6_tables.h>
56759  
56760 +MODULE_DESCRIPTION("IPv6 EUI64 address checking match");
56761 +MODULE_LICENSE("GPL");
56762 +MODULE_AUTHOR("Andras Kis-Szabo <kisza@sch.bme.hu>");
56763 +
56764  static int
56765  match(const struct sk_buff *skb,
56766        const struct net_device *in,
56767 @@ -88,6 +92,3 @@
56768  
56769  module_init(init);
56770  module_exit(fini);
56771 -MODULE_DESCRIPTION("IPv6 EUI64 address checking match");
56772 -MODULE_LICENSE("GPL");
56773 -MODULE_AUTHOR("Andras Kis-Szabo <kisza@sch.bme.hu>");
56774 diff -Nru a/net/ipv6/netfilter/ip6t_length.c b/net/ipv6/netfilter/ip6t_length.c
56775 --- a/net/ipv6/netfilter/ip6t_length.c  Thu Mar 20 00:43:40 2003
56776 +++ b/net/ipv6/netfilter/ip6t_length.c  Sun Aug 24 05:00:28 2003
56777 @@ -5,6 +5,10 @@
56778  #include <linux/netfilter_ipv6/ip6t_length.h>
56779  #include <linux/netfilter_ipv6/ip6_tables.h>
56780  
56781 +MODULE_LICENSE("GPL");
56782 +MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");
56783 +MODULE_DESCRIPTION("IPv6 packet length match");
56784 +
56785  static int
56786  match(const struct sk_buff *skb,
56787        const struct net_device *in,
56788 diff -Nru a/net/ipv6/netfilter/ip6t_limit.c b/net/ipv6/netfilter/ip6t_limit.c
56789 --- a/net/ipv6/netfilter/ip6t_limit.c   Thu Mar 20 00:43:40 2003
56790 +++ b/net/ipv6/netfilter/ip6t_limit.c   Sun Aug 24 05:00:28 2003
56791 @@ -15,6 +15,10 @@
56792  #include <linux/netfilter_ipv6/ip6_tables.h>
56793  #include <linux/netfilter_ipv6/ip6t_limit.h>
56794  
56795 +MODULE_LICENSE("GPL");
56796 +MODULE_AUTHOR("Herve Eychenne <rv@wallfire.org>");
56797 +MODULE_DESCRIPTION("rate limiting within ip6tables");
56798 +
56799  /* The algorithm used is the Simple Token Bucket Filter (TBF)
56800   * see net/sched/sch_tbf.c in the linux source tree
56801   */
56802 @@ -136,4 +140,3 @@
56803  
56804  module_init(init);
56805  module_exit(fini);
56806 -MODULE_LICENSE("GPL");
56807 diff -Nru a/net/ipv6/netfilter/ip6t_mac.c b/net/ipv6/netfilter/ip6t_mac.c
56808 --- a/net/ipv6/netfilter/ip6t_mac.c     Thu Mar 20 00:43:40 2003
56809 +++ b/net/ipv6/netfilter/ip6t_mac.c     Sun Aug 24 05:00:28 2003
56810 @@ -6,6 +6,10 @@
56811  #include <linux/netfilter_ipv6/ip6t_mac.h>
56812  #include <linux/netfilter_ipv6/ip6_tables.h>
56813  
56814 +MODULE_LICENSE("GPL");
56815 +MODULE_DESCRIPTION("MAC address matching module for IPv6");
56816 +MODULE_AUTHOR("Netfilter Core Teaam <coreteam@netfilter.org>");
56817 +
56818  static int
56819  match(const struct sk_buff *skb,
56820        const struct net_device *in,
56821 @@ -66,5 +70,3 @@
56822  
56823  module_init(init);
56824  module_exit(fini);
56825 -MODULE_LICENSE("GPL");
56826 -MODULE_DESCRIPTION("MAC address matching module for IPv6");
56827 diff -Nru a/net/ipv6/netfilter/ip6t_mark.c b/net/ipv6/netfilter/ip6t_mark.c
56828 --- a/net/ipv6/netfilter/ip6t_mark.c    Thu Mar 20 00:43:40 2003
56829 +++ b/net/ipv6/netfilter/ip6t_mark.c    Sun Aug 24 05:00:28 2003
56830 @@ -5,6 +5,10 @@
56831  #include <linux/netfilter_ipv6/ip6t_mark.h>
56832  #include <linux/netfilter_ipv6/ip6_tables.h>
56833  
56834 +MODULE_LICENSE("GPL");
56835 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
56836 +MODULE_DESCRIPTION("ip6tables mark match");
56837 +
56838  static int
56839  match(const struct sk_buff *skb,
56840        const struct net_device *in,
56841 @@ -52,4 +56,3 @@
56842  
56843  module_init(init);
56844  module_exit(fini);
56845 -MODULE_LICENSE("GPL");
56846 diff -Nru a/net/ipv6/netfilter/ip6t_multiport.c b/net/ipv6/netfilter/ip6t_multiport.c
56847 --- a/net/ipv6/netfilter/ip6t_multiport.c       Thu Mar 20 00:43:40 2003
56848 +++ b/net/ipv6/netfilter/ip6t_multiport.c       Sun Aug 24 05:00:28 2003
56849 @@ -9,6 +9,10 @@
56850  #include <linux/netfilter_ipv6/ip6t_multiport.h>
56851  #include <linux/netfilter_ipv6/ip6_tables.h>
56852  
56853 +MODULE_LICENSE("GPL");
56854 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
56855 +MODULE_DESCRIPTION("ip6tables match for multiple ports");
56856 +
56857  #if 0
56858  #define duprintf(format, args...) printk(format , ## args)
56859  #else
56860 diff -Nru a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c
56861 --- a/net/ipv6/netfilter/ip6table_filter.c      Mon Apr 28 02:27:56 2003
56862 +++ b/net/ipv6/netfilter/ip6table_filter.c      Sun Aug 24 05:00:28 2003
56863 @@ -6,6 +6,10 @@
56864  #include <linux/module.h>
56865  #include <linux/netfilter_ipv6/ip6_tables.h>
56866  
56867 +MODULE_LICENSE("GPL");
56868 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
56869 +MODULE_DESCRIPTION("ip6tables filter table");
56870 +
56871  #define FILTER_VALID_HOOKS ((1 << NF_IP6_LOCAL_IN) | (1 << NF_IP6_FORWARD) | (1 << NF_IP6_LOCAL_OUT))
56872  
56873  /* Standard entry. */
56874 @@ -202,4 +206,3 @@
56875  
56876  module_init(init);
56877  module_exit(fini);
56878 -MODULE_LICENSE("GPL");
56879 diff -Nru a/net/ipv6/netfilter/ip6table_mangle.c b/net/ipv6/netfilter/ip6table_mangle.c
56880 --- a/net/ipv6/netfilter/ip6table_mangle.c      Mon Apr 28 02:27:56 2003
56881 +++ b/net/ipv6/netfilter/ip6table_mangle.c      Sun Aug 24 05:00:28 2003
56882 @@ -6,6 +6,10 @@
56883  #include <linux/module.h>
56884  #include <linux/netfilter_ipv6/ip6_tables.h>
56885  
56886 +MODULE_LICENSE("GPL");
56887 +MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
56888 +MODULE_DESCRIPTION("ip6tables mangle table");
56889 +
56890  #define MANGLE_VALID_HOOKS ((1 << NF_IP6_PRE_ROUTING) | \
56891                             (1 << NF_IP6_LOCAL_IN) | \
56892                             (1 << NF_IP6_FORWARD) | \
56893 @@ -279,4 +283,3 @@
56894  
56895  module_init(init);
56896  module_exit(fini);
56897 -MODULE_LICENSE("GPL");
56898 diff -Nru a/net/ipv6/route.c b/net/ipv6/route.c
56899 --- a/net/ipv6/route.c  Mon Aug 18 03:49:00 2003
56900 +++ b/net/ipv6/route.c  Sat Aug 30 21:26:12 2003
56901 @@ -577,7 +577,7 @@
56902         rt->rt6i_dev      = dev;
56903         rt->rt6i_nexthop  = neigh;
56904         rt->rt6i_expires  = 0;
56905 -       rt->rt6i_flags    = RTF_LOCAL;
56906 +       rt->rt6i_flags    = RTF_LOCAL | RTF_NDISC;
56907         rt->rt6i_metric   = 0;
56908         atomic_set(&rt->u.dst.__refcnt, 1);
56909         rt->u.dst.metrics[RTAX_HOPLIMIT-1] = 255;
56910 @@ -831,7 +831,7 @@
56911                 }
56912         }
56913  
56914 -       rt->rt6i_flags = rtmsg->rtmsg_flags;
56915 +       rt->rt6i_flags = rtmsg->rtmsg_flags & ~RTF_NDISC;
56916  
56917  install_route:
56918         if (rta && rta[RTA_METRICS-1]) {
56919 @@ -1123,6 +1123,8 @@
56920  static struct rt6_info * ip6_rt_copy(struct rt6_info *ort)
56921  {
56922         struct rt6_info *rt = ip6_dst_alloc();
56923 +
56924 +       BUG_ON(ort->rt6i_flags & RTF_NDISC);
56925  
56926         if (rt) {
56927                 rt->u.dst.input = ort->u.dst.input;
56928 diff -Nru a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
56929 --- a/net/ipv6/xfrm6_policy.c   Sun Jul 27 19:22:27 2003
56930 +++ b/net/ipv6/xfrm6_policy.c   Sat Aug 30 21:26:12 2003
56931 @@ -55,12 +55,22 @@
56932  __xfrm6_find_bundle(struct flowi *fl, struct rtable *rt, struct xfrm_policy *policy)
56933  {
56934         struct dst_entry *dst;
56935 +       u32 ndisc_bit = 0;
56936 +
56937 +       if (fl->proto == IPPROTO_ICMPV6 &&
56938 +           (fl->fl_icmp_type == NDISC_NEIGHBOUR_ADVERTISEMENT ||
56939 +            fl->fl_icmp_type == NDISC_NEIGHBOUR_SOLICITATION  ||
56940 +            fl->fl_icmp_type == NDISC_ROUTER_SOLICITATION))
56941 +               ndisc_bit = RTF_NDISC;
56942  
56943         /* Still not clear if we should set fl->fl6_{src,dst}... */
56944         read_lock_bh(&policy->lock);
56945         for (dst = policy->bundles; dst; dst = dst->next) {
56946                 struct xfrm_dst *xdst = (struct xfrm_dst*)dst;
56947                 struct in6_addr fl_dst_prefix, fl_src_prefix;
56948 +
56949 +               if ((xdst->u.rt6.rt6i_flags & RTF_NDISC) != ndisc_bit)
56950 +                       continue;
56951  
56952                 ipv6_addr_prefix(&fl_dst_prefix,
56953                                  &fl->fl6_dst,
56954 diff -Nru a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c
56955 --- a/net/ipx/af_ipx.c  Wed Jun 18 13:59:01 2003
56956 +++ b/net/ipx/af_ipx.c  Sat Aug 30 19:12:56 2003
56957 @@ -1365,6 +1365,7 @@
56958                         atomic_read(&ipx_sock_nr));
56959  #endif
56960         sock_init_data(sock, sk);
56961 +       sk_set_owner(sk, THIS_MODULE);
56962         sk->sk_no_check = 1;            /* Checksum off by default */
56963         rc = 0;
56964  out:
56965 diff -Nru a/net/irda/af_irda.c b/net/irda/af_irda.c
56966 --- a/net/irda/af_irda.c        Wed Jun  4 17:57:09 2003
56967 +++ b/net/irda/af_irda.c        Sat Aug 30 19:15:30 2003
56968 @@ -1098,6 +1098,7 @@
56969  
56970         /* Initialise networking socket struct */
56971         sock_init_data(sock, sk);       /* Note : set sk->sk_refcnt to 1 */
56972 +       sk_set_owner(sk, THIS_MODULE);
56973         sk->sk_family = PF_IRDA;
56974         sk->sk_protocol = protocol;
56975         /* Link networking socket and IrDA socket structs together */
56976 diff -Nru a/net/llc/llc_mac.c b/net/llc/llc_mac.c
56977 --- a/net/llc/llc_mac.c Wed Jun  4 17:57:09 2003
56978 +++ b/net/llc/llc_mac.c Sat Aug 30 19:09:25 2003
56979 @@ -35,7 +35,7 @@
56980  
56981  u8 llc_mac_null_var[IFHWADDRLEN];
56982  
56983 -static void fix_up_incoming_skb(struct sk_buff *skb);
56984 +static int fix_up_incoming_skb(struct sk_buff *skb);
56985  static void llc_station_rcv(struct sk_buff *skb);
56986  static void llc_sap_rcv(struct llc_sap *sap, struct sk_buff *skb);
56987  
56988 @@ -69,7 +69,8 @@
56989         skb = skb_share_check(skb, GFP_ATOMIC);
56990         if (!skb)
56991                 goto out;
56992 -       fix_up_incoming_skb(skb);
56993 +       if (!fix_up_incoming_skb(skb))
56994 +               goto drop;
56995         pdu = llc_pdu_sn_hdr(skb);
56996         if (!pdu->dsap) { /* NULL DSAP, refer to station */
56997                 dprintk("%s: calling llc_station_rcv!\n", __FUNCTION__);
56998 @@ -172,11 +173,15 @@
56999   *     by looking at the two lowest-order bits of the first control field
57000   *     byte; field is either 3 or 4 bytes long.
57001   */
57002 -static void fix_up_incoming_skb(struct sk_buff *skb)
57003 +static int fix_up_incoming_skb(struct sk_buff *skb)
57004  {
57005         u8 llc_len = 2;
57006 -       struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)skb->data;
57007 +       struct llc_pdu_sn *pdu;
57008 +
57009 +       if (!pskb_may_pull(skb, sizeof(*pdu)))
57010 +               return 0;
57011  
57012 +       pdu = (struct llc_pdu_sn *)skb->data;
57013         if ((pdu->ctrl_1 & LLC_PDU_TYPE_MASK) == LLC_PDU_TYPE_U)
57014                 llc_len = 1;
57015         llc_len += 2;
57016 @@ -188,6 +193,7 @@
57017  
57018                 skb_trim(skb, data_size);
57019         }
57020 +       return 1;
57021  }
57022  
57023  /*
57024 diff -Nru a/net/llc/llc_main.c b/net/llc/llc_main.c
57025 --- a/net/llc/llc_main.c        Mon Jun 16 08:11:36 2003
57026 +++ b/net/llc/llc_main.c        Sat Aug 30 19:10:22 2003
57027 @@ -229,6 +229,7 @@
57028         if (llc_sk_init(sk))
57029                 goto outsk;
57030         sock_init_data(NULL, sk);
57031 +       sk_set_owner(sk, THIS_MODULE);
57032  #ifdef LLC_REFCNT_DEBUG
57033         atomic_inc(&llc_sock_nr);
57034         printk(KERN_DEBUG "LLC socket %p created in %s, now we have %d alive\n", sk,
57035 diff -Nru a/net/llc/llc_proc.c b/net/llc/llc_proc.c
57036 --- a/net/llc/llc_proc.c        Mon Jun 16 08:11:36 2003
57037 +++ b/net/llc/llc_proc.c        Sat Aug 30 19:11:23 2003
57038 @@ -245,6 +245,7 @@
57039         llc_proc_dir = proc_mkdir("llc", proc_net);
57040         if (!llc_proc_dir)
57041                 goto out;
57042 +       llc_proc_dir->owner = THIS_MODULE;
57043  
57044         p = create_proc_entry("socket", S_IRUGO, llc_proc_dir);
57045         if (!p)
57046 diff -Nru a/net/netlink/netlink_dev.c b/net/netlink/netlink_dev.c
57047 --- a/net/netlink/netlink_dev.c Sun May 25 19:34:11 2003
57048 +++ b/net/netlink/netlink_dev.c Tue Aug 26 09:25:41 2003
57049 @@ -41,7 +41,7 @@
57050   
57051  static unsigned int netlink_poll(struct file *file, poll_table * wait)
57052  {
57053 -       struct socket *sock = netlink_user[minor(file->f_dentry->d_inode->i_rdev)];
57054 +       struct socket *sock = netlink_user[iminor(file->f_dentry->d_inode)];
57055  
57056         if (sock->ops->poll==NULL)
57057                 return 0;
57058 @@ -56,7 +56,7 @@
57059                              size_t count, loff_t *pos)
57060  {
57061         struct inode *inode = file->f_dentry->d_inode;
57062 -       struct socket *sock = netlink_user[minor(inode->i_rdev)];
57063 +       struct socket *sock = netlink_user[iminor(inode)];
57064         struct msghdr msg;
57065         struct iovec iov;
57066  
57067 @@ -80,7 +80,7 @@
57068                             size_t count, loff_t *pos)
57069  {
57070         struct inode *inode = file->f_dentry->d_inode;
57071 -       struct socket *sock = netlink_user[minor(inode->i_rdev)];
57072 +       struct socket *sock = netlink_user[iminor(inode)];
57073         struct msghdr msg;
57074         struct iovec iov;
57075  
57076 @@ -100,7 +100,7 @@
57077  
57078  static int netlink_open(struct inode * inode, struct file * file)
57079  {
57080 -       unsigned int minor = minor(inode->i_rdev);
57081 +       unsigned int minor = iminor(inode);
57082         struct socket *sock;
57083         struct sockaddr_nl nladdr;
57084         int err;
57085 @@ -132,7 +132,7 @@
57086  
57087  static int netlink_release(struct inode * inode, struct file * file)
57088  {
57089 -       unsigned int minor = minor(inode->i_rdev);
57090 +       unsigned int minor = iminor(inode);
57091         struct socket *sock;
57092  
57093         sock = netlink_user[minor];
57094 @@ -146,7 +146,7 @@
57095  static int netlink_ioctl(struct inode *inode, struct file *file,
57096                     unsigned int cmd, unsigned long arg)
57097  {
57098 -       unsigned int minor = minor(inode->i_rdev);
57099 +       unsigned int minor = iminor(inode);
57100         int retval = 0;
57101  
57102         if (minor >= MAX_LINKS)
57103 diff -Nru a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
57104 --- a/net/netrom/af_netrom.c    Thu Aug 14 21:16:39 2003
57105 +++ b/net/netrom/af_netrom.c    Sat Aug 30 19:14:38 2003
57106 @@ -433,6 +433,7 @@
57107         nr = nr_sk(sk);
57108  
57109         sock_init_data(sock, sk);
57110 +       sk_set_owner(sk, THIS_MODULE);
57111  
57112         sock->ops    = &nr_proto_ops;
57113         sk->sk_protocol = protocol;
57114 @@ -473,6 +474,7 @@
57115         nr = nr_sk(sk);
57116  
57117         sock_init_data(NULL, sk);
57118 +       sk_set_owner(sk, THIS_MODULE);
57119  
57120         sk->sk_type     = osk->sk_type;
57121         sk->sk_socket   = osk->sk_socket;
57122 diff -Nru a/net/netsyms.c b/net/netsyms.c
57123 --- a/net/netsyms.c     Tue Aug 19 22:13:11 2003
57124 +++ b/net/netsyms.c     Mon Sep  1 17:25:54 2003
57125 @@ -631,7 +631,10 @@
57126  /* ethtool.c */
57127  EXPORT_SYMBOL(ethtool_op_get_link);
57128  EXPORT_SYMBOL(ethtool_op_get_tx_csum);
57129 +EXPORT_SYMBOL(ethtool_op_set_tx_csum);
57130  EXPORT_SYMBOL(ethtool_op_get_sg);
57131  EXPORT_SYMBOL(ethtool_op_set_sg);
57132 +EXPORT_SYMBOL(ethtool_op_get_tso);
57133 +EXPORT_SYMBOL(ethtool_op_set_tso);
57134  
57135  #endif  /* CONFIG_NET */
57136 diff -Nru a/net/rose/af_rose.c b/net/rose/af_rose.c
57137 --- a/net/rose/af_rose.c        Tue Aug 19 20:57:58 2003
57138 +++ b/net/rose/af_rose.c        Sat Aug 30 19:14:39 2003
57139 @@ -518,6 +518,7 @@
57140         rose = rose_sk(sk);
57141  
57142         sock_init_data(sock, sk);
57143 +       sk_set_owner(sk, THIS_MODULE);
57144  
57145         skb_queue_head_init(&rose->ack_queue);
57146  #ifdef M_BIT
57147 @@ -556,6 +557,7 @@
57148         rose = rose_sk(sk);
57149  
57150         sock_init_data(NULL, sk);
57151 +       sk_set_owner(sk, THIS_MODULE);
57152  
57153         skb_queue_head_init(&rose->ack_queue);
57154  #ifdef M_BIT
57155 diff -Nru a/net/rxrpc/krxiod.c b/net/rxrpc/krxiod.c
57156 --- a/net/rxrpc/krxiod.c        Tue Feb 11 14:57:54 2003
57157 +++ b/net/rxrpc/krxiod.c        Sat Aug 30 20:36:03 2003
57158 @@ -9,7 +9,6 @@
57159   * 2 of the License, or (at your option) any later version.
57160   */
57161  
57162 -#include <linux/version.h>
57163  #include <linux/sched.h>
57164  #include <linux/completion.h>
57165  #include <linux/spinlock.h>
57166 diff -Nru a/net/rxrpc/krxsecd.c b/net/rxrpc/krxsecd.c
57167 --- a/net/rxrpc/krxsecd.c       Tue Feb 11 14:57:54 2003
57168 +++ b/net/rxrpc/krxsecd.c       Sat Aug 30 20:36:03 2003
57169 @@ -14,7 +14,6 @@
57170   * - responding to security challenges on outbound connections
57171   */
57172  
57173 -#include <linux/version.h>
57174  #include <linux/module.h>
57175  #include <linux/sched.h>
57176  #include <linux/completion.h>
57177 diff -Nru a/net/rxrpc/krxtimod.c b/net/rxrpc/krxtimod.c
57178 --- a/net/rxrpc/krxtimod.c      Sun Apr 20 07:45:44 2003
57179 +++ b/net/rxrpc/krxtimod.c      Sat Aug 30 20:36:03 2003
57180 @@ -9,7 +9,6 @@
57181   * 2 of the License, or (at your option) any later version.
57182   */
57183  
57184 -#include <linux/version.h>
57185  #include <linux/module.h>
57186  #include <linux/init.h>
57187  #include <linux/sched.h>
57188 diff -Nru a/net/sched/sch_generic.c b/net/sched/sch_generic.c
57189 --- a/net/sched/sch_generic.c   Sun Apr 20 00:57:16 2003
57190 +++ b/net/sched/sch_generic.c   Mon Sep  1 01:18:30 2003
57191 @@ -121,7 +121,7 @@
57192                                         printk(KERN_DEBUG "Dead loop on netdevice %s, fix it urgently!\n", dev->name);
57193                                 return -1;
57194                         }
57195 -                       netdev_rx_stat[smp_processor_id()].cpu_collision++;
57196 +                       __get_cpu_var(netdev_rx_stat).cpu_collision++;
57197                 }
57198  
57199                 /* Device kicked us out :(
57200 diff -Nru a/net/sctp/socket.c b/net/sctp/socket.c
57201 --- a/net/sctp/socket.c Mon Aug  4 10:35:40 2003
57202 +++ b/net/sctp/socket.c Thu Aug 28 01:21:04 2003
57203 @@ -852,7 +852,7 @@
57204                 associd = sinfo->sinfo_assoc_id;
57205         }
57206  
57207 -       SCTP_DEBUG_PRINTK("msg_len: %Zd, sinfo_flags: 0x%x\n",
57208 +       SCTP_DEBUG_PRINTK("msg_len: %d, sinfo_flags: 0x%x\n",
57209                           msg_len, sinfo_flags);
57210  
57211         /* MSG_EOF or MSG_ABORT cannot be set on a TCP-style socket. */
57212 diff -Nru a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
57213 --- a/net/sunrpc/rpc_pipe.c     Sat Jun 14 16:58:21 2003
57214 +++ b/net/sunrpc/rpc_pipe.c     Sat Aug 30 20:35:33 2003
57215 @@ -10,7 +10,6 @@
57216   */
57217  #include <linux/config.h>
57218  #include <linux/module.h>
57219 -#include <linux/version.h>
57220  #include <linux/slab.h>
57221  #include <linux/string.h>
57222  #include <linux/pagemap.h>
57223 diff -Nru a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
57224 --- a/net/sunrpc/svcsock.c      Mon Aug 18 15:49:47 2003
57225 +++ b/net/sunrpc/svcsock.c      Sat Aug 30 20:35:33 2003
57226 @@ -27,7 +27,6 @@
57227  #include <linux/inet.h>
57228  #include <linux/udp.h>
57229  #include <linux/tcp.h>
57230 -#include <linux/version.h>
57231  #include <linux/unistd.h>
57232  #include <linux/slab.h>
57233  #include <linux/netdevice.h>
57234 diff -Nru a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
57235 --- a/net/sunrpc/sysctl.c       Mon Aug 11 22:33:48 2003
57236 +++ b/net/sunrpc/sysctl.c       Sat Aug 30 20:35:33 2003
57237 @@ -8,7 +8,6 @@
57238   */
57239  
57240  #include <linux/config.h>
57241 -#include <linux/version.h>
57242  #include <linux/types.h>
57243  #include <linux/linkage.h>
57244  #include <linux/ctype.h>
57245 diff -Nru a/net/sunrpc/timer.c b/net/sunrpc/timer.c
57246 --- a/net/sunrpc/timer.c        Thu Aug 21 18:32:56 2003
57247 +++ b/net/sunrpc/timer.c        Sat Aug 30 20:35:33 2003
57248 @@ -15,7 +15,6 @@
57249  
57250  #include <asm/param.h>
57251  
57252 -#include <linux/version.h>
57253  #include <linux/types.h>
57254  #include <linux/unistd.h>
57255  
57256 diff -Nru a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
57257 --- a/net/sunrpc/xprt.c Thu Aug 21 18:41:58 2003
57258 +++ b/net/sunrpc/xprt.c Sat Aug 30 20:35:33 2003
57259 @@ -45,7 +45,6 @@
57260  
57261  #define __KERNEL_SYSCALLS__
57262  
57263 -#include <linux/version.h>
57264  #include <linux/types.h>
57265  #include <linux/slab.h>
57266  #include <linux/capability.h>
57267 diff -Nru a/net/x25/af_x25.c b/net/x25/af_x25.c
57268 --- a/net/x25/af_x25.c  Tue Aug  5 17:31:06 2003
57269 +++ b/net/x25/af_x25.c  Sat Aug 30 19:14:39 2003
57270 @@ -449,6 +449,7 @@
57271         x25->sk = sk;
57272  
57273         sock_init_data(NULL, sk);
57274 +       sk_set_owner(sk, THIS_MODULE);
57275  
57276         skb_queue_head_init(&x25->ack_queue);
57277         skb_queue_head_init(&x25->fragment_queue);
57278 @@ -478,6 +479,7 @@
57279         x25 = x25_sk(sk);
57280  
57281         sock_init_data(sock, sk);
57282 +       sk_set_owner(sk, THIS_MODULE);
57283  
57284         init_timer(&x25->timer);
57285  
57286 diff -Nru a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
57287 --- a/net/xfrm/xfrm_user.c      Thu Aug  7 21:04:46 2003
57288 +++ b/net/xfrm/xfrm_user.c      Mon Sep  1 01:12:32 2003
57289 @@ -1195,3 +1195,4 @@
57290  
57291  module_init(xfrm_user_init);
57292  module_exit(xfrm_user_exit);
57293 +MODULE_LICENSE("GPL");
57294 diff -Nru a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
57295 --- a/scripts/kconfig/Makefile  Tue Aug 19 09:27:03 2003
57296 +++ b/scripts/kconfig/Makefile  Sun Aug 31 16:13:49 2003
57297 @@ -2,40 +2,43 @@
57298  # Kernel configuration targets
57299  # These targets are used from top-level makefile
57300  
57301 -.PHONY: oldconfig xconfig gconfig menuconfig config
57302 +.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig
57303  
57304 -xconfig: scripts/kconfig/qconf
57305 -       ./scripts/kconfig/qconf arch/$(ARCH)/Kconfig
57306 +xconfig: $(obj)/qconf
57307 +       $< arch/$(ARCH)/Kconfig
57308  
57309 -gconfig: scripts/kconfig/gconf
57310 -       ./scripts/kconfig/gconf arch/$(ARCH)/Kconfig
57311 +gconfig: $(obj)/gconf
57312 +       ./$<  arch/$(ARCH)/Kconfig
57313  
57314 -menuconfig: scripts/kconfig/mconf
57315 +menuconfig: $(obj)/mconf
57316         $(Q)$(MAKE) $(build)=scripts/lxdialog
57317 -       ./scripts/kconfig/mconf arch/$(ARCH)/Kconfig
57318 +       $< arch/$(ARCH)/Kconfig
57319  
57320 -config: scripts/kconfig/conf
57321 -       ./scripts/kconfig/conf arch/$(ARCH)/Kconfig
57322 +config: $(obj)/conf
57323 +       $< arch/$(ARCH)/Kconfig
57324  
57325 -oldconfig: scripts/kconfig/conf
57326 -       ./scripts/kconfig/conf -o arch/$(ARCH)/Kconfig
57327 +oldconfig: $(obj)/conf
57328 +       $< -o arch/$(ARCH)/Kconfig
57329 +
57330 +silentoldconfig: $(obj)/conf
57331 +       $< -s arch/$(ARCH)/Kconfig
57332  
57333  .PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig
57334  
57335 -randconfig: scripts/kconfig/conf
57336 -       ./scripts/kconfig/conf -r arch/$(ARCH)/Kconfig
57337 +randconfig: $(obj)/conf
57338 +       $< -r arch/$(ARCH)/Kconfig
57339  
57340 -allyesconfig: scripts/kconfig/conf
57341 -       ./scripts/kconfig/conf -y arch/$(ARCH)/Kconfig
57342 +allyesconfig: $(obj)/conf
57343 +       $< -y arch/$(ARCH)/Kconfig
57344  
57345 -allnoconfig: scripts/kconfig/conf
57346 -       ./scripts/kconfig/conf -n arch/$(ARCH)/Kconfig
57347 +allnoconfig: $(obj)/conf
57348 +       $< -n arch/$(ARCH)/Kconfig
57349  
57350 -allmodconfig: scripts/kconfig/conf
57351 -       ./scripts/kconfig/conf -m arch/$(ARCH)/Kconfig
57352 +allmodconfig: $(obj)/conf
57353 +       $< -m arch/$(ARCH)/Kconfig
57354  
57355 -defconfig: scripts/kconfig/conf
57356 -       ./scripts/kconfig/conf -d arch/$(ARCH)/Kconfig
57357 +defconfig: $(obj)/conf
57358 +       $< -d arch/$(ARCH)/Kconfig
57359  
57360  # Help text used by make help
57361  help:
57362 diff -Nru a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
57363 --- a/scripts/kconfig/symbol.c  Fri Jun  6 01:28:22 2003
57364 +++ b/scripts/kconfig/symbol.c  Sun Aug 31 16:14:08 2003
57365 @@ -12,21 +12,21 @@
57366  #include "lkc.h"
57367  
57368  struct symbol symbol_yes = {
57369 -       name: "y",
57370 -       curr: { "y", yes },
57371 -       flags: SYMBOL_YES|SYMBOL_VALID,
57372 +       .name = "y",
57373 +       .curr = { "y", yes },
57374 +       .flags = SYMBOL_YES|SYMBOL_VALID,
57375  }, symbol_mod = {
57376 -       name: "m",
57377 -       curr: { "m", mod },
57378 -       flags: SYMBOL_MOD|SYMBOL_VALID,
57379 +       .name = "m",
57380 +       .curr = { "m", mod },
57381 +       .flags = SYMBOL_MOD|SYMBOL_VALID,
57382  }, symbol_no = {
57383 -       name: "n",
57384 -       curr: { "n", no },
57385 -       flags: SYMBOL_NO|SYMBOL_VALID,
57386 +       .name = "n",
57387 +       .curr = { "n", no },
57388 +       .flags = SYMBOL_NO|SYMBOL_VALID,
57389  }, symbol_empty = {
57390 -       name: "",
57391 -       curr: { "", no },
57392 -       flags: SYMBOL_VALID,
57393 +       .name = "",
57394 +       .curr = { "", no },
57395 +       .flags = SYMBOL_VALID,
57396  };
57397  
57398  int sym_change_count;
57399 diff -Nru a/security/capability.c b/security/capability.c
57400 --- a/security/capability.c     Wed Jul  2 21:22:38 2003
57401 +++ b/security/capability.c     Sun Aug 31 16:14:14 2003
57402 @@ -295,12 +295,7 @@
57403  
57404         vm_acct_memory(pages);
57405  
57406 -        /*
57407 -        * Sometimes we want to use more memory than we have
57408 -        */
57409 -       if (sysctl_overcommit_memory == 1)
57410 -               return 0;
57411 -
57412 +       /* We estimate memory ourselves (common case) */
57413         if (sysctl_overcommit_memory == 0) {
57414                 free = get_page_cache_size();
57415                 free += nr_free_pages();
57416 @@ -322,10 +317,16 @@
57417  
57418                 if (free > pages)
57419                         return 0;
57420 +
57421                 vm_unacct_memory(pages);
57422                 return -ENOMEM;
57423         }
57424  
57425 +       /* Kernel assumes allocation */
57426 +       if (sysctl_overcommit_memory == 1)
57427 +               return 0;
57428 +
57429 +       /* sysctl_overcommit_memory must be 2 which means strict_overcommit*/
57430         allowed = totalram_pages * sysctl_overcommit_ratio / 100;
57431         allowed += total_swap_pages;
57432  
57433 diff -Nru a/security/selinux/hooks.c b/security/selinux/hooks.c
57434 --- a/security/selinux/hooks.c  Mon Aug 18 22:27:19 2003
57435 +++ b/security/selinux/hooks.c  Sun Aug 31 16:14:20 2003
57436 @@ -1332,31 +1332,19 @@
57437  
57438  static int selinux_bprm_alloc_security(struct linux_binprm *bprm)
57439  {
57440 -       int rc;
57441 +       struct bprm_security_struct *bsec;
57442  
57443 -       /* Make sure that the secondary module doesn't use the
57444 -          bprm->security field, since we do not yet support chaining
57445 -          of multiple security structures on the field.  Neither
57446 -          the dummy nor the capability module use the field.  The owlsm
57447 -          module uses the field if CONFIG_OWLSM_FD is enabled. */
57448 -       rc = secondary_ops->bprm_alloc_security(bprm);
57449 -       if (rc)
57450 -               return rc;
57451 -       if (bprm->security) {
57452 -               printk(KERN_WARNING "%s: no support yet for chaining on the "
57453 -                      "security field by secondary modules.\n", __FUNCTION__);
57454 -               /* Release the secondary module's security object. */
57455 -               secondary_ops->bprm_free_security(bprm);
57456 -               /* Unregister the secondary module to prevent problems
57457 -                  with subsequent binprm hooks. This will revert to the
57458 -                  original (dummy) module for the secondary operations. */
57459 -               rc = security_ops->unregister_security("unknown", secondary_ops);
57460 -               if (rc)
57461 -                       return rc;
57462 -               printk(KERN_WARNING "%s: Unregistered the secondary security "
57463 -                      "module.\n", __FUNCTION__);
57464 -       }
57465 -       bprm->security = NULL;
57466 +       bsec = kmalloc(sizeof(struct bprm_security_struct), GFP_KERNEL);
57467 +       if (!bsec)
57468 +               return -ENOMEM;
57469 +
57470 +       memset(bsec, 0, sizeof *bsec);
57471 +       bsec->magic = SELINUX_MAGIC;
57472 +       bsec->bprm = bprm;
57473 +       bsec->sid = SECINITSID_UNLABELED;
57474 +       bsec->set = 0;
57475 +
57476 +       bprm->security = bsec;
57477         return 0;
57478  }
57479  
57480 @@ -1365,6 +1353,7 @@
57481         struct task_security_struct *tsec;
57482         struct inode *inode = bprm->file->f_dentry->d_inode;
57483         struct inode_security_struct *isec;
57484 +       struct bprm_security_struct *bsec;
57485         u32 newsid;
57486         struct avc_audit_data ad;
57487         int rc;
57488 @@ -1373,15 +1362,16 @@
57489         if (rc)
57490                 return rc;
57491  
57492 -       if (bprm->sh_bang || bprm->security)
57493 -               /* The security field should already be set properly. */
57494 +       bsec = bprm->security;
57495 +
57496 +       if (bsec->set)
57497                 return 0;
57498  
57499         tsec = current->security;
57500         isec = inode->i_security;
57501  
57502         /* Default to the current task SID. */
57503 -       bprm->security = (void *)tsec->sid;
57504 +       bsec->sid = tsec->sid;
57505  
57506         /* Reset create SID on execve. */
57507         tsec->create_sid = 0;
57508 @@ -1427,9 +1417,10 @@
57509                         return rc;
57510  
57511                 /* Set the security field to the new SID. */
57512 -               bprm->security = (void*) newsid;
57513 +               bsec->sid = newsid;
57514         }
57515  
57516 +       bsec->set = 1;
57517         return 0;
57518  }
57519  
57520 @@ -1463,8 +1454,9 @@
57521  
57522  static void selinux_bprm_free_security(struct linux_binprm *bprm)
57523  {
57524 -       /* Nothing to do - not dynamically allocated. */
57525 -       return;
57526 +       struct bprm_security_struct *bsec = bprm->security;
57527 +       bprm->security = NULL;
57528 +       kfree(bsec);
57529  }
57530  
57531  /* Derived from fs/exec.c:flush_old_files. */
57532 @@ -1509,6 +1501,7 @@
57533  static void selinux_bprm_compute_creds(struct linux_binprm *bprm)
57534  {
57535         struct task_security_struct *tsec, *psec;
57536 +       struct bprm_security_struct *bsec;
57537         u32 sid;
57538         struct av_decision avd;
57539         int rc;
57540 @@ -1517,9 +1510,8 @@
57541  
57542         tsec = current->security;
57543  
57544 -       sid = (u32)bprm->security;
57545 -       if (!sid)
57546 -               sid = tsec->sid;
57547 +       bsec = bprm->security;
57548 +       sid = bsec->sid;
57549  
57550         tsec->osid = tsec->sid;
57551         if (tsec->sid != sid) {
57552 @@ -2057,9 +2049,11 @@
57553                 case F_GETLK:
57554                 case F_SETLK:
57555                 case F_SETLKW:
57556 +#if BITS_PER_LONG == 32
57557                 case F_GETLK64:
57558                 case F_SETLK64:
57559                 case F_SETLKW64:
57560 +#endif
57561                         if (!file->f_dentry || !file->f_dentry->d_inode) {
57562                                 err = -EINVAL;
57563                                 break;
57564 @@ -3112,9 +3106,8 @@
57565                                char *name, void *value, size_t size)
57566  {
57567         struct task_security_struct *tsec;
57568 -       u32 sid;
57569 +       u32 sid, len;
57570         char *context;
57571 -       size_t len;
57572         int error;
57573  
57574         if (current != p) {
57575 diff -Nru a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h
57576 --- a/security/selinux/include/objsec.h Thu Aug 14 18:17:44 2003
57577 +++ b/security/selinux/include/objsec.h Sun Aug 31 16:14:20 2003
57578 @@ -21,6 +21,7 @@
57579  #include <linux/list.h>
57580  #include <linux/sched.h>
57581  #include <linux/fs.h>
57582 +#include <linux/binfmts.h>
57583  #include <linux/in.h>
57584  #include "flask.h"
57585  #include "avc.h"
57586 @@ -83,6 +84,13 @@
57587         u16 sclass;     /* security class of this object */
57588         u32 sid;              /* SID of IPC resource */
57589          struct avc_entry_ref avcr;     /* reference to permissions */
57590 +};
57591 +
57592 +struct bprm_security_struct {
57593 +       unsigned long magic;           /* magic number for this module */
57594 +       struct linux_binprm *bprm;     /* back pointer to bprm object */
57595 +       u32 sid;                       /* SID for transformed process */
57596 +       unsigned char set;
57597  };
57598  
57599  extern int inode_security_set_sid(struct inode *inode, u32 sid);
57600 diff -Nru a/security/selinux/ss/avtab.c b/security/selinux/ss/avtab.c
57601 --- a/security/selinux/ss/avtab.c       Thu Jul 17 02:38:01 2003
57602 +++ b/security/selinux/ss/avtab.c       Sun Aug 31 16:14:19 2003
57603 @@ -106,7 +106,7 @@
57604                 }
57605                 h->htable[i] = NULL;
57606         }
57607 -       kfree(h->htable);
57608 +       vfree(h->htable);
57609  }
57610  
57611  
57612 @@ -138,7 +138,7 @@
57613  {
57614         int i;
57615  
57616 -       h->htable = kmalloc(sizeof(*(h->htable)) * AVTAB_SIZE, GFP_KERNEL);
57617 +       h->htable = vmalloc(sizeof(*(h->htable)) * AVTAB_SIZE);
57618         if (!h->htable)
57619                 return -ENOMEM;
57620         for (i = 0; i < AVTAB_SIZE; i++)
57621 diff -Nru a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c
57622 --- a/security/selinux/ss/ebitmap.c     Thu Jul 17 02:38:01 2003
57623 +++ b/security/selinux/ss/ebitmap.c     Sun Aug 31 16:14:19 2003
57624 @@ -250,8 +250,8 @@
57625         count = le32_to_cpu(buf[2]);
57626  
57627         if (mapsize != MAPSIZE) {
57628 -               printk(KERN_ERR "security: ebitmap: map size %d does not "
57629 -                      "match my size %d (high bit was %d)\n", mapsize,
57630 +               printk(KERN_ERR "security: ebitmap: map size %u does not "
57631 +                      "match my size %Zd (high bit was %d)\n", mapsize,
57632                        MAPSIZE, e->highbit);
57633                 goto out;
57634         }
57635 @@ -261,7 +261,7 @@
57636         }
57637         if (e->highbit & (MAPSIZE - 1)) {
57638                 printk(KERN_ERR "security: ebitmap: high bit (%d) is not a "
57639 -                      "multiple of the map size (%d)\n", e->highbit, MAPSIZE);
57640 +                      "multiple of the map size (%Zd)\n", e->highbit, MAPSIZE);
57641                 goto bad;
57642         }
57643         l = NULL;
57644 @@ -283,13 +283,13 @@
57645  
57646                 if (n->startbit & (MAPSIZE - 1)) {
57647                         printk(KERN_ERR "security: ebitmap start bit (%d) is "
57648 -                              "not a multiple of the map size (%d)\n",
57649 +                              "not a multiple of the map size (%Zd)\n",
57650                                n->startbit, MAPSIZE);
57651                         goto bad_free;
57652                 }
57653                 if (n->startbit > (e->highbit - MAPSIZE)) {
57654                         printk(KERN_ERR "security: ebitmap start bit (%d) is "
57655 -                              "beyond the end of the bitmap (%d)\n",
57656 +                              "beyond the end of the bitmap (%Zd)\n",
57657                                n->startbit, (e->highbit - MAPSIZE));
57658                         goto bad_free;
57659                 }
57660 diff -Nru a/security/selinux/ss/global.h b/security/selinux/ss/global.h
57661 --- a/security/selinux/ss/global.h      Sun Aug 10 04:22:59 2003
57662 +++ b/security/selinux/ss/global.h      Sun Aug 31 16:14:19 2003
57663 @@ -8,6 +8,7 @@
57664  #include <linux/in.h>
57665  #include <linux/spinlock.h>
57666  #include <linux/sched.h>
57667 +#include <linux/vmalloc.h>
57668  
57669  #include "flask.h"
57670  #include "avc.h"
57671 diff -Nru a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
57672 --- a/security/selinux/ss/policydb.c    Mon Aug 18 22:27:19 2003
57673 +++ b/security/selinux/ss/policydb.c    Sun Aug 31 16:14:19 2003
57674 @@ -1074,7 +1074,7 @@
57675         len = buf[1];
57676         if (len != strlen(POLICYDB_STRING)) {
57677                 printk(KERN_ERR "security:  policydb string length %d does not "
57678 -                      "match expected length %d\n",
57679 +                      "match expected length %Zd\n",
57680                        len, strlen(POLICYDB_STRING));
57681                 goto bad;
57682         }
57683 diff -Nru a/sound/core/control.c b/sound/core/control.c
57684 --- a/sound/core/control.c      Mon Jul 21 02:29:40 2003
57685 +++ b/sound/core/control.c      Tue Aug 26 09:25:41 2003
57686 @@ -42,7 +42,7 @@
57687  
57688  static int snd_ctl_open(struct inode *inode, struct file *file)
57689  {
57690 -       int cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
57691 +       int cardnum = SNDRV_MINOR_CARD(iminor(inode));
57692         unsigned long flags;
57693         snd_card_t *card;
57694         snd_ctl_file_t *ctl;
57695 diff -Nru a/sound/core/hwdep.c b/sound/core/hwdep.c
57696 --- a/sound/core/hwdep.c        Sun Jun  1 11:47:53 2003
57697 +++ b/sound/core/hwdep.c        Tue Aug 26 09:25:41 2003
57698 @@ -73,7 +73,7 @@
57699  
57700  static int snd_hwdep_open(struct inode *inode, struct file * file)
57701  {
57702 -       int major = major(inode->i_rdev);
57703 +       int major = imajor(inode);
57704         int cardnum;
57705         int device;
57706         snd_hwdep_t *hw;
57707 @@ -82,12 +82,12 @@
57708  
57709         switch (major) {
57710         case CONFIG_SND_MAJOR:
57711 -               cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
57712 -               device = SNDRV_MINOR_DEVICE(minor(inode->i_rdev)) - SNDRV_MINOR_HWDEP;
57713 +               cardnum = SNDRV_MINOR_CARD(iminor(inode));
57714 +               device = SNDRV_MINOR_DEVICE(iminor(inode)) - SNDRV_MINOR_HWDEP;
57715                 break;
57716  #ifdef CONFIG_SND_OSSEMUL
57717         case SOUND_MAJOR:
57718 -               cardnum = SNDRV_MINOR_OSS_CARD(minor(inode->i_rdev));
57719 +               cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode));
57720                 device = 0;
57721                 break;
57722  #endif
57723 diff -Nru a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
57724 --- a/sound/core/oss/mixer_oss.c        Sun Jun  1 11:47:53 2003
57725 +++ b/sound/core/oss/mixer_oss.c        Tue Aug 26 09:25:41 2003
57726 @@ -36,7 +36,7 @@
57727  
57728  static int snd_mixer_oss_open(struct inode *inode, struct file *file)
57729  {
57730 -       int cardnum = SNDRV_MINOR_OSS_CARD(minor(inode->i_rdev));
57731 +       int cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode));
57732         snd_card_t *card;
57733         snd_mixer_oss_file_t *fmixer;
57734         int err;
57735 diff -Nru a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
57736 --- a/sound/core/oss/pcm_oss.c  Fri Aug 15 19:54:09 2003
57737 +++ b/sound/core/oss/pcm_oss.c  Tue Aug 26 09:25:41 2003
57738 @@ -1681,7 +1681,7 @@
57739  
57740  static int snd_pcm_oss_open(struct inode *inode, struct file *file)
57741  {
57742 -       int minor = minor(inode->i_rdev);
57743 +       int minor = iminor(inode);
57744         int cardnum = SNDRV_MINOR_OSS_CARD(minor);
57745         int device;
57746         int err;
57747 diff -Nru a/sound/core/pcm_native.c b/sound/core/pcm_native.c
57748 --- a/sound/core/pcm_native.c   Mon Jul 28 04:35:00 2003
57749 +++ b/sound/core/pcm_native.c   Tue Aug 26 09:25:41 2003
57750 @@ -1431,11 +1431,11 @@
57751                 return 0;
57752         inode = file->f_dentry->d_inode;
57753         if (!S_ISCHR(inode->i_mode) ||
57754 -           major(inode->i_rdev) != snd_major) {
57755 +           imajor(inode) != snd_major) {
57756                 fput(file);
57757                 return 0;
57758         }
57759 -       minor = minor(inode->i_rdev);
57760 +       minor = iminor(inode);
57761         if (minor >= 256 || 
57762             minor % SNDRV_MINOR_DEVICES < SNDRV_MINOR_PCM_PLAYBACK) {
57763                 fput(file);
57764 @@ -1940,8 +1940,8 @@
57765  
57766  int snd_pcm_open(struct inode *inode, struct file *file)
57767  {
57768 -       int cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
57769 -       int device = SNDRV_MINOR_DEVICE(minor(inode->i_rdev));
57770 +       int cardnum = SNDRV_MINOR_CARD(iminor(inode));
57771 +       int device = SNDRV_MINOR_DEVICE(iminor(inode));
57772         int err;
57773         snd_pcm_t *pcm;
57774         snd_pcm_file_t *pcm_file;
57775 diff -Nru a/sound/core/rawmidi.c b/sound/core/rawmidi.c
57776 --- a/sound/core/rawmidi.c      Mon Jul 28 04:35:00 2003
57777 +++ b/sound/core/rawmidi.c      Tue Aug 26 09:25:41 2003
57778 @@ -345,7 +345,7 @@
57779  
57780  static int snd_rawmidi_open(struct inode *inode, struct file *file)
57781  {
57782 -       int maj = major(inode->i_rdev);
57783 +       int maj = imajor(inode);
57784         int cardnum;
57785         snd_card_t *card;
57786         int device, subdevice;
57787 @@ -359,16 +359,16 @@
57788  
57789         switch (maj) {
57790         case CONFIG_SND_MAJOR:
57791 -               cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev));
57792 +               cardnum = SNDRV_MINOR_CARD(iminor(inode));
57793                 cardnum %= SNDRV_CARDS;
57794 -               device = SNDRV_MINOR_DEVICE(minor(inode->i_rdev)) - SNDRV_MINOR_RAWMIDI;
57795 +               device = SNDRV_MINOR_DEVICE(iminor(inode)) - SNDRV_MINOR_RAWMIDI;
57796                 device %= SNDRV_MINOR_RAWMIDIS;
57797                 break;
57798  #ifdef CONFIG_SND_OSSEMUL
57799         case SOUND_MAJOR:
57800 -               cardnum = SNDRV_MINOR_OSS_CARD(minor(inode->i_rdev));
57801 +               cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode));
57802                 cardnum %= SNDRV_CARDS;
57803 -               device = SNDRV_MINOR_OSS_DEVICE(minor(inode->i_rdev)) == SNDRV_MINOR_OSS_MIDI ?
57804 +               device = SNDRV_MINOR_OSS_DEVICE(iminor(inode)) == SNDRV_MINOR_OSS_MIDI ?
57805                         midi_map[cardnum] : amidi_map[cardnum];
57806                 break;
57807  #endif
57808 diff -Nru a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c
57809 --- a/sound/core/seq/oss/seq_oss.c      Sun Jun  1 11:47:54 2003
57810 +++ b/sound/core/seq/oss/seq_oss.c      Tue Aug 26 09:25:41 2003
57811 @@ -121,7 +121,7 @@
57812  {
57813         int level, rc;
57814  
57815 -       if (minor(inode->i_rdev) == SNDRV_MINOR_OSS_MUSIC)
57816 +       if (iminor(inode) == SNDRV_MINOR_OSS_MUSIC)
57817                 level = SNDRV_SEQ_OSS_MODE_MUSIC;
57818         else
57819                 level = SNDRV_SEQ_OSS_MODE_SYNTH;
57820 diff -Nru a/sound/core/sound.c b/sound/core/sound.c
57821 --- a/sound/core/sound.c        Mon Jul 28 04:35:00 2003
57822 +++ b/sound/core/sound.c        Tue Aug 26 09:25:41 2003
57823 @@ -117,7 +117,7 @@
57824  
57825  static int snd_open(struct inode *inode, struct file *file)
57826  {
57827 -       int minor = minor(inode->i_rdev);
57828 +       int minor = iminor(inode);
57829         int card = SNDRV_MINOR_CARD(minor);
57830         int dev = SNDRV_MINOR_DEVICE(minor);
57831         snd_minor_t *mptr = NULL;
57832 diff -Nru a/sound/oss/ad1889.c b/sound/oss/ad1889.c
57833 --- a/sound/oss/ad1889.c        Sat Aug  2 23:59:09 2003
57834 +++ b/sound/oss/ad1889.c        Tue Aug 26 09:25:41 2003
57835 @@ -755,7 +755,7 @@
57836  static int ad1889_open(struct inode *inode, struct file *file)
57837  {
57838         /* check minor; only support /dev/dsp atm */
57839 -       if (minor(inode->i_rdev) != 3)
57840 +       if (iminor(inode) != 3)
57841                 return -ENXIO;
57842         
57843         file->private_data = ad1889_dev;
57844 @@ -788,7 +788,7 @@
57845  /************************* /dev/mixer interfaces ************************ */
57846  static int ad1889_mixer_open(struct inode *inode, struct file *file)
57847  {
57848 -       if (ad1889_dev->ac97_codec->dev_mixer != minor(inode->i_rdev))
57849 +       if (ad1889_dev->ac97_codec->dev_mixer != iminor(inode))
57850                 return -ENODEV;
57851  
57852         file->private_data = ad1889_dev->ac97_codec;
57853 diff -Nru a/sound/oss/ali5455.c b/sound/oss/ali5455.c
57854 --- a/sound/oss/ali5455.c       Sat Aug  2 23:59:09 2003
57855 +++ b/sound/oss/ali5455.c       Tue Aug 26 09:25:41 2003
57856 @@ -3026,7 +3026,7 @@
57857  static int ali_open_mixdev(struct inode *inode, struct file *file)
57858  {
57859         int i;
57860 -       int minor = minor(inode->i_rdev);
57861 +       int minor = iminor(inode);
57862         struct ali_card *card = devs;
57863         for (card = devs; card != NULL; card = card->next) {
57864                 /*
57865 diff -Nru a/sound/oss/au1000.c b/sound/oss/au1000.c
57866 --- a/sound/oss/au1000.c        Sat Aug  2 23:59:09 2003
57867 +++ b/sound/oss/au1000.c        Tue Aug 26 09:25:41 2003
57868 @@ -1842,7 +1842,7 @@
57869  
57870  static int  au1000_open(struct inode *inode, struct file *file)
57871  {
57872 -       int             minor = MINOR(inode->i_rdev);
57873 +       int             minor = iminor(inode);
57874         DECLARE_WAITQUEUE(wait, current);
57875         struct au1000_state *s = &au1000_state;
57876         int             ret;
57877 diff -Nru a/sound/oss/btaudio.c b/sound/oss/btaudio.c
57878 --- a/sound/oss/btaudio.c       Tue Aug 12 13:28:49 2003
57879 +++ b/sound/oss/btaudio.c       Tue Aug 26 09:25:41 2003
57880 @@ -299,7 +299,7 @@
57881  
57882  static int btaudio_mixer_open(struct inode *inode, struct file *file)
57883  {
57884 -       int minor = minor(inode->i_rdev);
57885 +       int minor = iminor(inode);
57886         struct btaudio *bta;
57887  
57888         for (bta = btaudios; bta != NULL; bta = bta->next)
57889 @@ -458,7 +458,7 @@
57890  
57891  static int btaudio_dsp_open_digital(struct inode *inode, struct file *file)
57892  {
57893 -       int minor = minor(inode->i_rdev);
57894 +       int minor = iminor(inode);
57895         struct btaudio *bta;
57896  
57897         for (bta = btaudios; bta != NULL; bta = bta->next)
57898 @@ -474,7 +474,7 @@
57899  
57900  static int btaudio_dsp_open_analog(struct inode *inode, struct file *file)
57901  {
57902 -       int minor = minor(inode->i_rdev);
57903 +       int minor = iminor(inode);
57904         struct btaudio *bta;
57905  
57906         for (bta = btaudios; bta != NULL; bta = bta->next)
57907 diff -Nru a/sound/oss/cmpci.c b/sound/oss/cmpci.c
57908 --- a/sound/oss/cmpci.c Wed Jul 23 08:32:08 2003
57909 +++ b/sound/oss/cmpci.c Tue Aug 26 09:25:41 2003
57910 @@ -1448,7 +1448,7 @@
57911  
57912  static int cm_open_mixdev(struct inode *inode, struct file *file)
57913  {
57914 -       int minor = minor(inode->i_rdev);
57915 +       int minor = iminor(inode);
57916         struct cm_state *s = devs;
57917  
57918         while (s && s->dev_mixer != minor)
57919 @@ -2207,7 +2207,7 @@
57920  
57921  static int cm_open(struct inode *inode, struct file *file)
57922  {
57923 -       int minor = minor(inode->i_rdev);
57924 +       int minor = iminor(inode);
57925         struct cm_state *s = devs;
57926         unsigned char fmtm = ~0, fmts = 0;
57927  
57928 @@ -2462,7 +2462,7 @@
57929  
57930  static int cm_midi_open(struct inode *inode, struct file *file)
57931  {
57932 -       int minor = minor(inode->i_rdev);
57933 +       int minor = iminor(inode);
57934         struct cm_state *s = devs;
57935         unsigned long flags;
57936  
57937 @@ -2679,7 +2679,7 @@
57938  
57939  static int cm_dmfm_open(struct inode *inode, struct file *file)
57940  {
57941 -       int minor = minor(inode->i_rdev);
57942 +       int minor = iminor(inode);
57943         struct cm_state *s = devs;
57944  
57945         while (s && s->dev_dmfm != minor)
57946 diff -Nru a/sound/oss/cs4281/cs4281m.c b/sound/oss/cs4281/cs4281m.c
57947 --- a/sound/oss/cs4281/cs4281m.c        Thu Jul 31 08:58:39 2003
57948 +++ b/sound/oss/cs4281/cs4281m.c        Tue Aug 26 09:25:41 2003
57949 @@ -2567,7 +2567,7 @@
57950  
57951  static int cs4281_open_mixdev(struct inode *inode, struct file *file)
57952  {
57953 -       unsigned int minor = minor(inode->i_rdev);
57954 +       unsigned int minor = iminor(inode);
57955         struct cs4281_state *s=NULL;
57956         struct list_head *entry;
57957  
57958 @@ -3624,7 +3624,7 @@
57959  
57960  static int cs4281_open(struct inode *inode, struct file *file)
57961  {
57962 -       unsigned int minor = minor(inode->i_rdev);
57963 +       unsigned int minor = iminor(inode);
57964         struct cs4281_state *s=NULL;
57965         struct list_head *entry;
57966  
57967 @@ -3966,7 +3966,7 @@
57968  static int cs4281_midi_open(struct inode *inode, struct file *file)
57969  {
57970         unsigned long flags, temp1;
57971 -       unsigned int minor = minor(inode->i_rdev);
57972 +       unsigned int minor = iminor(inode);
57973         struct cs4281_state *s=NULL;
57974         struct list_head *entry;
57975         list_for_each(entry, &cs4281_devs)
57976 diff -Nru a/sound/oss/cs46xx.c b/sound/oss/cs46xx.c
57977 --- a/sound/oss/cs46xx.c        Tue Aug 12 13:28:49 2003
57978 +++ b/sound/oss/cs46xx.c        Tue Aug 26 09:25:41 2003
57979 @@ -1838,7 +1838,7 @@
57980  
57981  static int cs_midi_open(struct inode *inode, struct file *file)
57982  {
57983 -        unsigned int minor = minor(inode->i_rdev);
57984 +        unsigned int minor = iminor(inode);
57985          struct cs_card *card=NULL;
57986          unsigned long flags;
57987         struct list_head *entry;
57988 @@ -3200,7 +3200,7 @@
57989         struct cs_state *state = NULL;
57990         struct dmabuf *dmabuf = NULL;
57991         struct list_head *entry;
57992 -        unsigned int minor = minor(inode->i_rdev);
57993 +        unsigned int minor = iminor(inode);
57994         int ret=0;
57995         unsigned int tmp;
57996  
57997 @@ -4066,7 +4066,7 @@
57998  static int cs_open_mixdev(struct inode *inode, struct file *file)
57999  {
58000         int i=0;
58001 -       unsigned int minor = minor(inode->i_rdev);
58002 +       unsigned int minor = iminor(inode);
58003         struct cs_card *card=NULL;
58004         struct list_head *entry;
58005         unsigned int tmp;
58006 @@ -4113,7 +4113,7 @@
58007  
58008  static int cs_release_mixdev(struct inode *inode, struct file *file)
58009  {
58010 -       unsigned int minor = minor(inode->i_rdev);
58011 +       unsigned int minor = iminor(inode);
58012         struct cs_card *card=NULL;
58013         struct list_head *entry;
58014         int i;
58015 diff -Nru a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c
58016 --- a/sound/oss/dmasound/dmasound_core.c        Tue Aug 12 13:28:49 2003
58017 +++ b/sound/oss/dmasound/dmasound_core.c        Tue Aug 26 09:25:41 2003
58018 @@ -904,7 +904,7 @@
58019           O_RDONLY and dsp1 could be opened O_WRONLY
58020         */
58021  
58022 -       dmasound.minDev = minor(inode->i_rdev) & 0x0f;
58023 +       dmasound.minDev = iminor(inode) & 0x0f;
58024  
58025         /* OK. - we should make some attempt at consistency. At least the H'ware
58026            options should be set with a valid mode.  We will make it that the LL
58027 diff -Nru a/sound/oss/emu10k1/audio.c b/sound/oss/emu10k1/audio.c
58028 --- a/sound/oss/emu10k1/audio.c Tue Jul 15 10:35:45 2003
58029 +++ b/sound/oss/emu10k1/audio.c Tue Aug 26 09:25:41 2003
58030 @@ -1112,7 +1112,7 @@
58031  
58032  static int emu10k1_audio_open(struct inode *inode, struct file *file)
58033  {
58034 -       int minor = minor(inode->i_rdev);
58035 +       int minor = iminor(inode);
58036         struct emu10k1_card *card = NULL;
58037         struct list_head *entry;
58038         struct emu10k1_wavedevice *wave_dev;
58039 diff -Nru a/sound/oss/emu10k1/midi.c b/sound/oss/emu10k1/midi.c
58040 --- a/sound/oss/emu10k1/midi.c  Thu Apr  3 14:52:57 2003
58041 +++ b/sound/oss/emu10k1/midi.c  Tue Aug 26 09:25:41 2003
58042 @@ -86,7 +86,7 @@
58043  
58044  static int emu10k1_midi_open(struct inode *inode, struct file *file)
58045  {
58046 -       int minor = minor(inode->i_rdev);
58047 +       int minor = iminor(inode);
58048         struct emu10k1_card *card = NULL;
58049         struct emu10k1_mididevice *midi_dev;
58050         struct list_head *entry;
58051 diff -Nru a/sound/oss/emu10k1/mixer.c b/sound/oss/emu10k1/mixer.c
58052 --- a/sound/oss/emu10k1/mixer.c Tue Jul 15 10:35:45 2003
58053 +++ b/sound/oss/emu10k1/mixer.c Tue Aug 26 09:25:41 2003
58054 @@ -654,7 +654,7 @@
58055  
58056  static int emu10k1_mixer_open(struct inode *inode, struct file *file)
58057  {
58058 -       int minor = minor(inode->i_rdev);
58059 +       int minor = iminor(inode);
58060         struct emu10k1_card *card = NULL;
58061         struct list_head *entry;
58062  
58063 diff -Nru a/sound/oss/es1370.c b/sound/oss/es1370.c
58064 --- a/sound/oss/es1370.c        Tue Aug 12 16:21:59 2003
58065 +++ b/sound/oss/es1370.c        Tue Aug 26 09:25:41 2003
58066 @@ -1023,7 +1023,7 @@
58067  
58068  static int es1370_open_mixdev(struct inode *inode, struct file *file)
58069  {
58070 -       unsigned int minor = minor(inode->i_rdev);
58071 +       unsigned int minor = iminor(inode);
58072         struct list_head *list;
58073         struct es1370_state *s;
58074  
58075 @@ -1727,7 +1727,7 @@
58076  
58077  static int es1370_open(struct inode *inode, struct file *file)
58078  {
58079 -       unsigned int minor = minor(inode->i_rdev);
58080 +       unsigned int minor = iminor(inode);
58081         DECLARE_WAITQUEUE(wait, current);
58082         unsigned long flags;
58083         struct list_head *list;
58084 @@ -2165,7 +2165,7 @@
58085  
58086  static int es1370_open_dac(struct inode *inode, struct file *file)
58087  {
58088 -       unsigned int minor = minor(inode->i_rdev);
58089 +       unsigned int minor = iminor(inode);
58090         DECLARE_WAITQUEUE(wait, current);
58091         unsigned long flags;
58092         struct list_head *list;
58093 @@ -2408,7 +2408,7 @@
58094  
58095  static int es1370_midi_open(struct inode *inode, struct file *file)
58096  {
58097 -       unsigned int minor = minor(inode->i_rdev);
58098 +       unsigned int minor = iminor(inode);
58099         DECLARE_WAITQUEUE(wait, current);
58100         unsigned long flags;
58101         struct list_head *list;
58102 diff -Nru a/sound/oss/es1371.c b/sound/oss/es1371.c
58103 --- a/sound/oss/es1371.c        Tue Aug 12 13:28:49 2003
58104 +++ b/sound/oss/es1371.c        Tue Aug 26 09:25:41 2003
58105 @@ -1210,7 +1210,7 @@
58106  
58107  static int es1371_open_mixdev(struct inode *inode, struct file *file)
58108  {
58109 -       int minor = minor(inode->i_rdev);
58110 +       int minor = iminor(inode);
58111         struct list_head *list;
58112         struct es1371_state *s;
58113  
58114 @@ -1914,7 +1914,7 @@
58115  
58116  static int es1371_open(struct inode *inode, struct file *file)
58117  {
58118 -       int minor = minor(inode->i_rdev);
58119 +       int minor = iminor(inode);
58120         DECLARE_WAITQUEUE(wait, current);
58121         unsigned long flags;
58122         struct list_head *list;
58123 @@ -2345,7 +2345,7 @@
58124  
58125  static int es1371_open_dac(struct inode *inode, struct file *file)
58126  {
58127 -       int minor = minor(inode->i_rdev);
58128 +       int minor = iminor(inode);
58129         DECLARE_WAITQUEUE(wait, current);
58130         unsigned long flags;
58131         struct list_head *list;
58132 @@ -2587,7 +2587,7 @@
58133  
58134  static int es1371_midi_open(struct inode *inode, struct file *file)
58135  {
58136 -       int minor = minor(inode->i_rdev);
58137 +       int minor = iminor(inode);
58138         DECLARE_WAITQUEUE(wait, current);
58139         unsigned long flags;
58140         struct list_head *list;
58141 diff -Nru a/sound/oss/esssolo1.c b/sound/oss/esssolo1.c
58142 --- a/sound/oss/esssolo1.c      Thu Jul 31 08:58:39 2003
58143 +++ b/sound/oss/esssolo1.c      Tue Aug 26 09:25:41 2003
58144 @@ -913,7 +913,7 @@
58145  
58146  static int solo1_open_mixdev(struct inode *inode, struct file *file)
58147  {
58148 -       unsigned int minor = minor(inode->i_rdev);
58149 +       unsigned int minor = iminor(inode);
58150         struct solo1_state *s = NULL;
58151         struct pci_dev *pci_dev = NULL;
58152  
58153 @@ -1594,7 +1594,7 @@
58154  
58155  static int solo1_open(struct inode *inode, struct file *file)
58156  {
58157 -       unsigned int minor = minor(inode->i_rdev);
58158 +       unsigned int minor = iminor(inode);
58159         DECLARE_WAITQUEUE(wait, current);
58160         struct solo1_state *s = NULL;
58161         struct pci_dev *pci_dev = NULL;
58162 @@ -1884,7 +1884,7 @@
58163  
58164  static int solo1_midi_open(struct inode *inode, struct file *file)
58165  {
58166 -       unsigned int minor = minor(inode->i_rdev);
58167 +       unsigned int minor = iminor(inode);
58168         DECLARE_WAITQUEUE(wait, current);
58169         unsigned long flags;
58170         struct solo1_state *s = NULL;
58171 @@ -2106,7 +2106,7 @@
58172  
58173  static int solo1_dmfm_open(struct inode *inode, struct file *file)
58174  {
58175 -       unsigned int minor = minor(inode->i_rdev);
58176 +       unsigned int minor = iminor(inode);
58177         DECLARE_WAITQUEUE(wait, current);
58178         struct solo1_state *s = NULL;
58179         struct pci_dev *pci_dev = NULL;
58180 diff -Nru a/sound/oss/hal2.c b/sound/oss/hal2.c
58181 --- a/sound/oss/hal2.c  Sat Aug  2 23:59:09 2003
58182 +++ b/sound/oss/hal2.c  Tue Aug 26 09:25:41 2003
58183 @@ -867,7 +867,7 @@
58184  
58185  static int hal2_open_mixdev(struct inode *inode, struct file *file)
58186  {
58187 -       hal2_card_t *hal2 = hal2_mixer_find_card(MINOR(inode->i_rdev));
58188 +       hal2_card_t *hal2 = hal2_mixer_find_card(iminor(inode));
58189  
58190         if (hal2) {
58191                 file->private_data = hal2;
58192 @@ -1242,7 +1242,7 @@
58193  static int hal2_open(struct inode *inode, struct file *file)
58194  {
58195         int err;
58196 -       hal2_card_t *hal2 = hal2_dsp_find_card(MINOR(inode->i_rdev));
58197 +       hal2_card_t *hal2 = hal2_dsp_find_card(iminor(inode));
58198  
58199         DEBUG("opening audio device.\n");
58200  
58201 diff -Nru a/sound/oss/i810_audio.c b/sound/oss/i810_audio.c
58202 --- a/sound/oss/i810_audio.c    Tue Aug 12 16:21:48 2003
58203 +++ b/sound/oss/i810_audio.c    Tue Aug 26 09:25:41 2003
58204 @@ -2648,7 +2648,7 @@
58205  static int i810_open_mixdev(struct inode *inode, struct file *file)
58206  {
58207         int i;
58208 -       int minor = minor(inode->i_rdev);
58209 +       int minor = iminor(inode);
58210         struct i810_card *card = devs;
58211  
58212         for (card = devs; card != NULL; card = card->next) {
58213 diff -Nru a/sound/oss/ite8172.c b/sound/oss/ite8172.c
58214 --- a/sound/oss/ite8172.c       Sun Aug  3 00:02:01 2003
58215 +++ b/sound/oss/ite8172.c       Sun Aug 31 16:14:08 2003
58216 @@ -867,7 +867,7 @@
58217  
58218  static int it8172_open_mixdev(struct inode *inode, struct file *file)
58219  {
58220 -       int minor = MINOR(inode->i_rdev);
58221 +       int minor = iminor(inode);
58222         struct list_head *list;
58223         struct it8172_state *s;
58224  
58225 @@ -1771,7 +1771,7 @@
58226  
58227  static int it8172_open(struct inode *inode, struct file *file)
58228  {
58229 -       int minor = MINOR(inode->i_rdev);
58230 +       int minor = iminor(inode);
58231         DECLARE_WAITQUEUE(wait, current);
58232         unsigned long flags;
58233         struct list_head *list;
58234 @@ -2198,10 +2198,10 @@
58235  MODULE_DEVICE_TABLE(pci, id_table);
58236  
58237  static struct pci_driver it8172_driver = {
58238 -       name: IT8172_MODULE_NAME,
58239 -       id_table: id_table,
58240 -       probe: it8172_probe,
58241 -       remove: it8172_remove
58242 +       .name = IT8172_MODULE_NAME,
58243 +       .id_table = id_table,
58244 +       .probe = it8172_probe,
58245 +       .remove = it8172_remove
58246  };
58247  
58248  static int __init init_it8172(void)
58249 diff -Nru a/sound/oss/maestro.c b/sound/oss/maestro.c
58250 --- a/sound/oss/maestro.c       Tue Aug 12 13:28:49 2003
58251 +++ b/sound/oss/maestro.c       Tue Aug 26 09:25:41 2003
58252 @@ -2138,7 +2138,7 @@
58253  /* --------------------------------------------------------------------- */
58254  static int ess_open_mixdev(struct inode *inode, struct file *file)
58255  {
58256 -       unsigned int minor = minor(inode->i_rdev);
58257 +       unsigned int minor = iminor(inode);
58258         struct ess_card *card = NULL;
58259         struct pci_dev *pdev = NULL;
58260         struct pci_driver *drvr;
58261 @@ -2983,7 +2983,7 @@
58262  static int 
58263  ess_open(struct inode *inode, struct file *file)
58264  {
58265 -       unsigned int minor = minor(inode->i_rdev);
58266 +       unsigned int minor = iminor(inode);
58267         struct ess_state *s = NULL;
58268         unsigned char fmtm = ~0, fmts = 0;
58269         struct pci_dev *pdev = NULL;
58270 diff -Nru a/sound/oss/maestro3.c b/sound/oss/maestro3.c
58271 --- a/sound/oss/maestro3.c      Thu Jul 31 08:58:39 2003
58272 +++ b/sound/oss/maestro3.c      Tue Aug 26 09:25:41 2003
58273 @@ -1980,7 +1980,7 @@
58274  
58275  static int m3_open(struct inode *inode, struct file *file)
58276  {
58277 -    unsigned int minor = minor(inode->i_rdev);
58278 +    unsigned int minor = iminor(inode);
58279      struct m3_card *c;
58280      struct m3_state *s = NULL;
58281      int i;
58282 @@ -2149,7 +2149,7 @@
58283  /* OSS /dev/mixer file operation methods */
58284  static int m3_open_mixdev(struct inode *inode, struct file *file)
58285  {
58286 -    unsigned int minor = minor(inode->i_rdev);
58287 +    unsigned int minor = iminor(inode);
58288      struct m3_card *card = devs;
58289  
58290      for (card = devs; card != NULL; card = card->next) {
58291 diff -Nru a/sound/oss/msnd_pinnacle.c b/sound/oss/msnd_pinnacle.c
58292 --- a/sound/oss/msnd_pinnacle.c Wed Jul 23 08:32:08 2003
58293 +++ b/sound/oss/msnd_pinnacle.c Tue Aug 26 09:25:41 2003
58294 @@ -646,7 +646,7 @@
58295  
58296  static int dev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
58297  {
58298 -       int minor = minor(inode->i_rdev);
58299 +       int minor = iminor(inode);
58300  
58301         if (cmd == OSS_GETVERSION) {
58302                 int sound_version = SOUND_VERSION;
58303 @@ -758,7 +758,7 @@
58304  
58305  static int dev_open(struct inode *inode, struct file *file)
58306  {
58307 -       int minor = minor(inode->i_rdev);
58308 +       int minor = iminor(inode);
58309         int err = 0;
58310  
58311         if (minor == dev.dsp_minor) {
58312 @@ -793,7 +793,7 @@
58313  
58314  static int dev_release(struct inode *inode, struct file *file)
58315  {
58316 -       int minor = minor(inode->i_rdev);
58317 +       int minor = iminor(inode);
58318         int err = 0;
58319  
58320         lock_kernel();
58321 @@ -983,7 +983,7 @@
58322  
58323  static ssize_t dev_read(struct file *file, char *buf, size_t count, loff_t *off)
58324  {
58325 -       int minor = minor(file->f_dentry->d_inode->i_rdev);
58326 +       int minor = iminor(file->f_dentry->d_inode);
58327         if (minor == dev.dsp_minor)
58328                 return dsp_read(buf, count);
58329         else
58330 @@ -992,7 +992,7 @@
58331  
58332  static ssize_t dev_write(struct file *file, const char *buf, size_t count, loff_t *off)
58333  {
58334 -       int minor = minor(file->f_dentry->d_inode->i_rdev);
58335 +       int minor = iminor(file->f_dentry->d_inode);
58336         if (minor == dev.dsp_minor)
58337                 return dsp_write(buf, count);
58338         else
58339 diff -Nru a/sound/oss/nec_vrc5477.c b/sound/oss/nec_vrc5477.c
58340 --- a/sound/oss/nec_vrc5477.c   Tue Aug 12 13:28:49 2003
58341 +++ b/sound/oss/nec_vrc5477.c   Tue Aug 26 09:25:41 2003
58342 @@ -857,7 +857,7 @@
58343  
58344  static int vrc5477_ac97_open_mixdev(struct inode *inode, struct file *file)
58345  {
58346 -       int minor = minor(inode->i_rdev);
58347 +       int minor = iminor(inode);
58348         struct list_head *list;
58349         struct vrc5477_ac97_state *s;
58350  
58351 @@ -1569,7 +1569,7 @@
58352  
58353  static int vrc5477_ac97_open(struct inode *inode, struct file *file)
58354  {
58355 -       int minor = minor(inode->i_rdev);
58356 +       int minor = iminor(inode);
58357         DECLARE_WAITQUEUE(wait, current);
58358         unsigned long flags;
58359         struct list_head *list;
58360 diff -Nru a/sound/oss/rme96xx.c b/sound/oss/rme96xx.c
58361 --- a/sound/oss/rme96xx.c       Thu Jul 31 08:58:39 2003
58362 +++ b/sound/oss/rme96xx.c       Tue Aug 26 09:25:41 2003
58363 @@ -1445,7 +1445,7 @@
58364  
58365  static int rme96xx_open(struct inode *in, struct file *f)
58366  {
58367 -       int minor = minor(in->i_rdev);
58368 +       int minor = iminor(in);
58369         struct list_head *list;
58370         int devnum;
58371         rme96xx_info *s;
58372 @@ -1769,7 +1769,7 @@
58373  
58374  static int rme96xx_mixer_open(struct inode *inode, struct file *file)
58375  {
58376 -       int minor = minor(inode->i_rdev);
58377 +       int minor = iminor(inode);
58378         struct list_head *list;
58379         rme96xx_info *s;
58380  
58381 diff -Nru a/sound/oss/sonicvibes.c b/sound/oss/sonicvibes.c
58382 --- a/sound/oss/sonicvibes.c    Tue Aug 12 13:28:49 2003
58383 +++ b/sound/oss/sonicvibes.c    Tue Aug 26 09:25:41 2003
58384 @@ -1238,7 +1238,7 @@
58385  
58386  static int sv_open_mixdev(struct inode *inode, struct file *file)
58387  {
58388 -       int minor = minor(inode->i_rdev);
58389 +       int minor = iminor(inode);
58390         struct list_head *list;
58391         struct sv_state *s;
58392  
58393 @@ -1900,7 +1900,7 @@
58394  
58395  static int sv_open(struct inode *inode, struct file *file)
58396  {
58397 -       int minor = minor(inode->i_rdev);
58398 +       int minor = iminor(inode);
58399         DECLARE_WAITQUEUE(wait, current);
58400         unsigned char fmtm = ~0, fmts = 0;
58401         struct list_head *list;
58402 @@ -2149,7 +2149,7 @@
58403  
58404  static int sv_midi_open(struct inode *inode, struct file *file)
58405  {
58406 -       int minor = minor(inode->i_rdev);
58407 +       int minor = iminor(inode);
58408         DECLARE_WAITQUEUE(wait, current);
58409         unsigned long flags;
58410         struct list_head *list;
58411 @@ -2371,7 +2371,7 @@
58412  
58413  static int sv_dmfm_open(struct inode *inode, struct file *file)
58414  {
58415 -       int minor = minor(inode->i_rdev);
58416 +       int minor = iminor(inode);
58417         DECLARE_WAITQUEUE(wait, current);
58418         struct list_head *list;
58419         struct sv_state *s;
58420 diff -Nru a/sound/oss/soundcard.c b/sound/oss/soundcard.c
58421 --- a/sound/oss/soundcard.c     Tue Aug 12 13:28:49 2003
58422 +++ b/sound/oss/soundcard.c     Tue Aug 26 09:25:41 2003
58423 @@ -144,7 +144,7 @@
58424  
58425  static ssize_t sound_read(struct file *file, char *buf, size_t count, loff_t *ppos)
58426  {
58427 -       int dev = minor(file->f_dentry->d_inode->i_rdev);
58428 +       int dev = iminor(file->f_dentry->d_inode);
58429         int ret = -EINVAL;
58430  
58431         /*
58432 @@ -177,7 +177,7 @@
58433  
58434  static ssize_t sound_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
58435  {
58436 -       int dev = minor(file->f_dentry->d_inode->i_rdev);
58437 +       int dev = iminor(file->f_dentry->d_inode);
58438         int ret = -EINVAL;
58439         
58440         lock_kernel();
58441 @@ -204,7 +204,7 @@
58442  
58443  static int sound_open(struct inode *inode, struct file *file)
58444  {
58445 -       int dev = minor(inode->i_rdev);
58446 +       int dev = iminor(inode);
58447         int retval;
58448  
58449         DEB(printk("sound_open(dev=%d)\n", dev));
58450 @@ -253,7 +253,7 @@
58451  
58452  static int sound_release(struct inode *inode, struct file *file)
58453  {
58454 -       int dev = minor(inode->i_rdev);
58455 +       int dev = iminor(inode);
58456  
58457         lock_kernel();
58458         DEB(printk("sound_release(dev=%d)\n", dev));
58459 @@ -333,7 +333,7 @@
58460                        unsigned int cmd, unsigned long arg)
58461  {
58462         int err, len = 0, dtype;
58463 -       int dev = minor(inode->i_rdev);
58464 +       int dev = iminor(inode);
58465  
58466         if (_SIOC_DIR(cmd) != _SIOC_NONE && _SIOC_DIR(cmd) != 0) {
58467                 /*
58468 @@ -396,7 +396,7 @@
58469  static unsigned int sound_poll(struct file *file, poll_table * wait)
58470  {
58471         struct inode *inode = file->f_dentry->d_inode;
58472 -       int dev = minor(inode->i_rdev);
58473 +       int dev = iminor(inode);
58474  
58475         DEB(printk("sound_poll(dev=%d)\n", dev));
58476         switch (dev & 0x0f) {
58477 @@ -420,7 +420,7 @@
58478         int dev_class;
58479         unsigned long size;
58480         struct dma_buffparms *dmap = NULL;
58481 -       int dev = minor(file->f_dentry->d_inode->i_rdev);
58482 +       int dev = iminor(file->f_dentry->d_inode);
58483  
58484         dev_class = dev & 0x0f;
58485         dev >>= 4;
58486 diff -Nru a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
58487 --- a/sound/oss/swarm_cs4297a.c Sun Aug  3 00:04:24 2003
58488 +++ b/sound/oss/swarm_cs4297a.c Tue Aug 26 09:25:41 2003
58489 @@ -1537,7 +1537,7 @@
58490  
58491  static int cs4297a_open_mixdev(struct inode *inode, struct file *file)
58492  {
58493 -       int minor = MINOR(inode->i_rdev);
58494 +       int minor = iminor(inode);
58495         struct cs4297a_state *s=NULL;
58496         struct list_head *entry;
58497  
58498 @@ -2386,7 +2386,7 @@
58499  
58500  static int cs4297a_open(struct inode *inode, struct file *file)
58501  {
58502 -       int minor = MINOR(inode->i_rdev);
58503 +       int minor = iminor(inode);
58504         struct cs4297a_state *s=NULL;
58505         struct list_head *entry;
58506  
58507 diff -Nru a/sound/oss/trident.c b/sound/oss/trident.c
58508 --- a/sound/oss/trident.c       Sat Aug  9 11:53:08 2003
58509 +++ b/sound/oss/trident.c       Tue Aug 26 09:25:41 2003
58510 @@ -2600,7 +2600,7 @@
58511  static int trident_open(struct inode *inode, struct file *file)
58512  {
58513         int i = 0;
58514 -       int minor = minor(inode->i_rdev);
58515 +       int minor = iminor(inode);
58516         struct trident_card *card = devs;
58517         struct trident_state *state = NULL;
58518         struct dmabuf *dmabuf = NULL;
58519 @@ -3883,7 +3883,7 @@
58520  static int trident_open_mixdev(struct inode *inode, struct file *file)
58521  {
58522         int i = 0;
58523 -       int minor = minor(inode->i_rdev);
58524 +       int minor = iminor(inode);
58525         struct trident_card *card = devs;
58526  
58527         for (card = devs; card != NULL; card = card->next)
58528 diff -Nru a/sound/oss/via82cxxx_audio.c b/sound/oss/via82cxxx_audio.c
58529 --- a/sound/oss/via82cxxx_audio.c       Sun Aug  3 00:05:26 2003
58530 +++ b/sound/oss/via82cxxx_audio.c       Tue Aug 26 09:25:41 2003
58531 @@ -1556,7 +1556,7 @@
58532  
58533  static int via_mixer_open (struct inode *inode, struct file *file)
58534  {
58535 -       int minor = minor(inode->i_rdev);
58536 +       int minor = iminor(inode);
58537         struct via_info *card;
58538         struct pci_dev *pdev = NULL;
58539         struct pci_driver *drvr;
58540 @@ -3252,7 +3252,7 @@
58541  
58542  static int via_dsp_open (struct inode *inode, struct file *file)
58543  {
58544 -       int minor = minor(inode->i_rdev);
58545 +       int minor = iminor(inode);
58546         struct via_info *card;
58547         struct pci_dev *pdev = NULL;
58548         struct via_channel *chan;
58549 diff -Nru a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c
58550 --- a/sound/oss/vwsnd.c Mon Apr 21 00:32:53 2003
58551 +++ b/sound/oss/vwsnd.c Tue Aug 26 09:25:41 2003
58552 @@ -2916,7 +2916,7 @@
58553  static int vwsnd_audio_open(struct inode *inode, struct file *file)
58554  {
58555         vwsnd_dev_t *devc;
58556 -       dev_t minor = minor(inode->i_rdev);
58557 +       int minor = iminor(inode);
58558         int sw_samplefmt;
58559  
58560         DBGE("(inode=0x%p, file=0x%p)\n", inode, file);
58561 @@ -3063,7 +3063,7 @@
58562  
58563         INC_USE_COUNT;
58564         for (devc = vwsnd_dev_list; devc; devc = devc->next_dev)
58565 -               if (devc->mixer_minor == minor(inode->i_rdev))
58566 +               if (devc->mixer_minor == iminor(inode))
58567                         break;
58568  
58569         if (devc == NULL) {
58570 diff -Nru a/sound/oss/ymfpci.c b/sound/oss/ymfpci.c
58571 --- a/sound/oss/ymfpci.c        Mon Aug 18 22:27:20 2003
58572 +++ b/sound/oss/ymfpci.c        Tue Aug 26 09:25:41 2003
58573 @@ -1905,7 +1905,7 @@
58574         struct ymf_state *state;
58575         int err;
58576  
58577 -       minor = minor(inode->i_rdev);
58578 +       minor = iminor(inode);
58579         if ((minor & 0x0F) == 3) {      /* /dev/dspN */
58580                 ;
58581         } else {
58582 @@ -2019,7 +2019,7 @@
58583   */
58584  static int ymf_open_mixdev(struct inode *inode, struct file *file)
58585  {
58586 -       int minor = minor(inode->i_rdev);
58587 +       int minor = iminor(inode);
58588         struct list_head *list;
58589         ymfpci_t *unit;
58590         int i;
58591 diff -Nru a/sound/pcmcia/vx/vx_entry.c b/sound/pcmcia/vx/vx_entry.c
58592 --- a/sound/pcmcia/vx/vx_entry.c        Tue Jun 10 07:32:30 2003
58593 +++ b/sound/pcmcia/vx/vx_entry.c        Fri Aug 22 05:02:18 2003
58594 @@ -34,10 +34,8 @@
58595  static int vxpocket_event(event_t event, int priority, event_callback_args_t *args);
58596  
58597  
58598 -static void vxpocket_release(u_long arg)
58599 +static void vxpocket_release(dev_link_t* link)
58600  {
58601 -       dev_link_t *link = (dev_link_t *)arg;
58602 -       
58603         if (link->state & DEV_CONFIG) {
58604                 /* release cs resources */
58605                 CardServices(ReleaseConfiguration, link->handle);
58606 @@ -56,7 +54,7 @@
58607         struct snd_vxp_entry *hw;
58608         dev_link_t *link = &vxp->link;
58609  
58610 -       vxpocket_release((u_long)link);
58611 +       vxpocket_release(link);
58612  
58613         /* Break the link with Card Services */
58614         if (link->handle)
58615 @@ -148,9 +146,6 @@
58616         link->irq.Handler = &snd_vx_irq_handler;
58617         link->irq.Instance = chip;
58618  
58619 -       link->release.function = &vxpocket_release;
58620 -       link->release.data = (u_long)link;
58621 -
58622         link->conf.Attributes = CONF_ENABLE_IRQ;
58623         link->conf.Vcc = 50;
58624         link->conf.IntType = INT_MEMORY_AND_IO;
58625 @@ -229,8 +224,6 @@
58626  {
58627         vx_core_t *chip = snd_magic_cast(vx_core_t, link->priv, return);
58628  
58629 -       del_timer(&link->release);
58630 -
58631         snd_printdd(KERN_DEBUG "vxpocket_detach called\n");
58632         /* Remove the interface data from the linked list */
58633         if (hw) {
58634 @@ -326,7 +319,6 @@
58635                 snd_printdd(KERN_DEBUG "CARD_REMOVAL..\n");
58636                 link->state &= ~DEV_PRESENT;
58637                 if (link->state & DEV_CONFIG) {
58638 -                       mod_timer(&link->release, jiffies + HZ/20);
58639                         chip->chip_status |= VX_STAT_IS_STALE;
58640                 }
58641                 break;
58642 diff -Nru a/sound/ppc/keywest.c b/sound/ppc/keywest.c
58643 --- a/sound/ppc/keywest.c       Tue May 20 14:13:01 2003
58644 +++ b/sound/ppc/keywest.c       Sun Aug 24 06:11:13 2003
58645 @@ -50,7 +50,7 @@
58646  
58647  
58648  #ifndef i2c_device_name
58649 -#define i2c_device_name(x)     ((x)->dev.name)
58650 +#define i2c_device_name(x)     ((x)->name)
58651  #endif
58652  
58653  static int keywest_attach_adapter(struct i2c_adapter *adapter)
58654 diff -Nru a/sound/sound_core.c b/sound/sound_core.c
58655 --- a/sound/sound_core.c        Sat May 17 12:39:14 2003
58656 +++ b/sound/sound_core.c        Tue Aug 26 09:25:41 2003
58657 @@ -483,7 +483,7 @@
58658  int soundcore_open(struct inode *inode, struct file *file)
58659  {
58660         int chain;
58661 -       int unit = minor(inode->i_rdev);
58662 +       int unit = iminor(inode);
58663         struct sound_unit *s;
58664         struct file_operations *new_fops = NULL;
58665  
This page took 5.198269 seconds and 3 git commands to generate.